aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/crypto/mxs-dcp.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
index 430174be6f92..6bcd9157a02f 100644
--- a/drivers/crypto/mxs-dcp.c
+++ b/drivers/crypto/mxs-dcp.c
@@ -99,6 +99,11 @@ struct dcp_sha_req_ctx {
99 unsigned int fini:1; 99 unsigned int fini:1;
100}; 100};
101 101
102struct dcp_export_state {
103 struct dcp_sha_req_ctx req_ctx;
104 struct dcp_async_ctx async_ctx;
105};
106
102/* 107/*
103 * There can even be only one instance of the MXS DCP due to the 108 * There can even be only one instance of the MXS DCP due to the
104 * design of Linux Crypto API. 109 * design of Linux Crypto API.
@@ -758,14 +763,32 @@ static int dcp_sha_digest(struct ahash_request *req)
758 return dcp_sha_finup(req); 763 return dcp_sha_finup(req);
759} 764}
760 765
761static int dcp_sha_noimport(struct ahash_request *req, const void *in) 766static int dcp_sha_import(struct ahash_request *req, const void *in)
762{ 767{
763 return -ENOSYS; 768 struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
769 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
770 struct dcp_async_ctx *actx = crypto_ahash_ctx(tfm);
771 const struct dcp_export_state *export = in;
772
773 memset(rctx, 0, sizeof(struct dcp_sha_req_ctx));
774 memset(actx, 0, sizeof(struct dcp_async_ctx));
775 memcpy(rctx, &export->req_ctx, sizeof(struct dcp_sha_req_ctx));
776 memcpy(actx, &export->async_ctx, sizeof(struct dcp_async_ctx));
777
778 return 0;
764} 779}
765 780
766static int dcp_sha_noexport(struct ahash_request *req, void *out) 781static int dcp_sha_export(struct ahash_request *req, void *out)
767{ 782{
768 return -ENOSYS; 783 struct dcp_sha_req_ctx *rctx_state = ahash_request_ctx(req);
784 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
785 struct dcp_async_ctx *actx_state = crypto_ahash_ctx(tfm);
786 struct dcp_export_state *export = out;
787
788 memcpy(&export->req_ctx, rctx_state, sizeof(struct dcp_sha_req_ctx));
789 memcpy(&export->async_ctx, actx_state, sizeof(struct dcp_async_ctx));
790
791 return 0;
769} 792}
770 793
771static int dcp_sha_cra_init(struct crypto_tfm *tfm) 794static int dcp_sha_cra_init(struct crypto_tfm *tfm)
@@ -838,10 +861,11 @@ static struct ahash_alg dcp_sha1_alg = {
838 .final = dcp_sha_final, 861 .final = dcp_sha_final,
839 .finup = dcp_sha_finup, 862 .finup = dcp_sha_finup,
840 .digest = dcp_sha_digest, 863 .digest = dcp_sha_digest,
841 .import = dcp_sha_noimport, 864 .import = dcp_sha_import,
842 .export = dcp_sha_noexport, 865 .export = dcp_sha_export,
843 .halg = { 866 .halg = {
844 .digestsize = SHA1_DIGEST_SIZE, 867 .digestsize = SHA1_DIGEST_SIZE,
868 .statesize = sizeof(struct dcp_export_state),
845 .base = { 869 .base = {
846 .cra_name = "sha1", 870 .cra_name = "sha1",
847 .cra_driver_name = "sha1-dcp", 871 .cra_driver_name = "sha1-dcp",
@@ -864,10 +888,11 @@ static struct ahash_alg dcp_sha256_alg = {
864 .final = dcp_sha_final, 888 .final = dcp_sha_final,
865 .finup = dcp_sha_finup, 889 .finup = dcp_sha_finup,
866 .digest = dcp_sha_digest, 890 .digest = dcp_sha_digest,
867 .import = dcp_sha_noimport, 891 .import = dcp_sha_import,
868 .export = dcp_sha_noexport, 892 .export = dcp_sha_export,
869 .halg = { 893 .halg = {
870 .digestsize = SHA256_DIGEST_SIZE, 894 .digestsize = SHA256_DIGEST_SIZE,
895 .statesize = sizeof(struct dcp_export_state),
871 .base = { 896 .base = {
872 .cra_name = "sha256", 897 .cra_name = "sha256",
873 .cra_driver_name = "sha256-dcp", 898 .cra_driver_name = "sha256-dcp",