diff options
-rw-r--r-- | drivers/crypto/ccp/ccp-crypto-aes-cmac.c | 4 | ||||
-rw-r--r-- | drivers/crypto/ccp/ccp-crypto-sha.c | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c index 646c8d1bd03c..c6b8f9e56aab 100644 --- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c +++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c | |||
@@ -43,7 +43,9 @@ static int ccp_aes_cmac_complete(struct crypto_async_request *async_req, | |||
43 | } else | 43 | } else |
44 | rctx->buf_count = 0; | 44 | rctx->buf_count = 0; |
45 | 45 | ||
46 | memcpy(req->result, rctx->iv, digest_size); | 46 | /* Update result area if supplied */ |
47 | if (req->result) | ||
48 | memcpy(req->result, rctx->iv, digest_size); | ||
47 | 49 | ||
48 | e_free: | 50 | e_free: |
49 | sg_free_table(&rctx->data_sg); | 51 | sg_free_table(&rctx->data_sg); |
diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c index bf913cbb3e96..183d16e46d20 100644 --- a/drivers/crypto/ccp/ccp-crypto-sha.c +++ b/drivers/crypto/ccp/ccp-crypto-sha.c | |||
@@ -74,6 +74,7 @@ static int ccp_sha_finish_hmac(struct crypto_async_request *async_req) | |||
74 | struct ahash_request *req = ahash_request_cast(async_req); | 74 | struct ahash_request *req = ahash_request_cast(async_req); |
75 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); | 75 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); |
76 | struct ccp_ctx *ctx = crypto_ahash_ctx(tfm); | 76 | struct ccp_ctx *ctx = crypto_ahash_ctx(tfm); |
77 | struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req); | ||
77 | struct scatterlist sg[2]; | 78 | struct scatterlist sg[2]; |
78 | unsigned int block_size = | 79 | unsigned int block_size = |
79 | crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); | 80 | crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); |
@@ -81,7 +82,7 @@ static int ccp_sha_finish_hmac(struct crypto_async_request *async_req) | |||
81 | 82 | ||
82 | sg_init_table(sg, ARRAY_SIZE(sg)); | 83 | sg_init_table(sg, ARRAY_SIZE(sg)); |
83 | sg_set_buf(&sg[0], ctx->u.sha.opad, block_size); | 84 | sg_set_buf(&sg[0], ctx->u.sha.opad, block_size); |
84 | sg_set_buf(&sg[1], req->result, digest_size); | 85 | sg_set_buf(&sg[1], rctx->ctx, digest_size); |
85 | 86 | ||
86 | return ccp_sync_hash(ctx->u.sha.hmac_tfm, req->result, sg, | 87 | return ccp_sync_hash(ctx->u.sha.hmac_tfm, req->result, sg, |
87 | block_size + digest_size); | 88 | block_size + digest_size); |
@@ -106,7 +107,9 @@ static int ccp_sha_complete(struct crypto_async_request *async_req, int ret) | |||
106 | } else | 107 | } else |
107 | rctx->buf_count = 0; | 108 | rctx->buf_count = 0; |
108 | 109 | ||
109 | memcpy(req->result, rctx->ctx, digest_size); | 110 | /* Update result area if supplied */ |
111 | if (req->result) | ||
112 | memcpy(req->result, rctx->ctx, digest_size); | ||
110 | 113 | ||
111 | /* If we're doing an HMAC, we need to perform that on the final op */ | 114 | /* If we're doing an HMAC, we need to perform that on the final op */ |
112 | if (rctx->final && ctx->u.sha.key_len) | 115 | if (rctx->final && ctx->u.sha.key_len) |