diff options
author | Boris BREZILLON <boris.brezillon@free-electrons.com> | 2016-03-17 05:21:35 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-03-17 07:09:04 -0400 |
commit | b0ef51067cb4fa51867ede1bac1d58b3dfb42f31 (patch) | |
tree | 99bdbd61fd52af516358cb4910eff5c427667770 | |
parent | 7850c91b175d765f09cea3a02a20c7779c79c11d (diff) |
crypto: marvell/cesa - initialize hash states
->export() might be called before we have done an update operation,
and in this case the ->state field is left uninitialized.
Put the correct default value when initializing the request.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/marvell/hash.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index f07c1fa31d1a..7ca2e0f9dc2e 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c | |||
@@ -810,9 +810,14 @@ static int mv_cesa_ahash_import(struct ahash_request *req, const void *hash, | |||
810 | 810 | ||
811 | static int mv_cesa_md5_init(struct ahash_request *req) | 811 | static int mv_cesa_md5_init(struct ahash_request *req) |
812 | { | 812 | { |
813 | struct mv_cesa_ahash_req *creq = ahash_request_ctx(req); | ||
813 | struct mv_cesa_op_ctx tmpl = { }; | 814 | struct mv_cesa_op_ctx tmpl = { }; |
814 | 815 | ||
815 | mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_MD5); | 816 | mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_MD5); |
817 | creq->state[0] = MD5_H0; | ||
818 | creq->state[1] = MD5_H1; | ||
819 | creq->state[2] = MD5_H2; | ||
820 | creq->state[3] = MD5_H3; | ||
816 | 821 | ||
817 | mv_cesa_ahash_init(req, &tmpl, true); | 822 | mv_cesa_ahash_init(req, &tmpl, true); |
818 | 823 | ||
@@ -873,9 +878,15 @@ struct ahash_alg mv_md5_alg = { | |||
873 | 878 | ||
874 | static int mv_cesa_sha1_init(struct ahash_request *req) | 879 | static int mv_cesa_sha1_init(struct ahash_request *req) |
875 | { | 880 | { |
881 | struct mv_cesa_ahash_req *creq = ahash_request_ctx(req); | ||
876 | struct mv_cesa_op_ctx tmpl = { }; | 882 | struct mv_cesa_op_ctx tmpl = { }; |
877 | 883 | ||
878 | mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA1); | 884 | mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA1); |
885 | creq->state[0] = SHA1_H0; | ||
886 | creq->state[1] = SHA1_H1; | ||
887 | creq->state[2] = SHA1_H2; | ||
888 | creq->state[3] = SHA1_H3; | ||
889 | creq->state[4] = SHA1_H4; | ||
879 | 890 | ||
880 | mv_cesa_ahash_init(req, &tmpl, false); | 891 | mv_cesa_ahash_init(req, &tmpl, false); |
881 | 892 | ||
@@ -936,9 +947,18 @@ struct ahash_alg mv_sha1_alg = { | |||
936 | 947 | ||
937 | static int mv_cesa_sha256_init(struct ahash_request *req) | 948 | static int mv_cesa_sha256_init(struct ahash_request *req) |
938 | { | 949 | { |
950 | struct mv_cesa_ahash_req *creq = ahash_request_ctx(req); | ||
939 | struct mv_cesa_op_ctx tmpl = { }; | 951 | struct mv_cesa_op_ctx tmpl = { }; |
940 | 952 | ||
941 | mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA256); | 953 | mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA256); |
954 | creq->state[0] = SHA256_H0; | ||
955 | creq->state[1] = SHA256_H1; | ||
956 | creq->state[2] = SHA256_H2; | ||
957 | creq->state[3] = SHA256_H3; | ||
958 | creq->state[4] = SHA256_H4; | ||
959 | creq->state[5] = SHA256_H5; | ||
960 | creq->state[6] = SHA256_H6; | ||
961 | creq->state[7] = SHA256_H7; | ||
942 | 962 | ||
943 | mv_cesa_ahash_init(req, &tmpl, false); | 963 | mv_cesa_ahash_init(req, &tmpl, false); |
944 | 964 | ||