From bc23edcba2a24176af576ba92dc9a4fa05c2d7f4 Mon Sep 17 00:00:00 2001 From: Franck LENORMAND Date: Fri, 28 Sep 2018 17:27:30 +0200 Subject: MLK-19656: crypto: dcp: Copy IV for CBC chaining Properly copy the IV for external chaining if we are performing a CBC operation. Signed-off-by: Franck LENORMAND --- drivers/crypto/mxs-dcp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/crypto/mxs-dcp.c') diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c index dea36707321a..c94481739306 100644 --- a/drivers/crypto/mxs-dcp.c +++ b/drivers/crypto/mxs-dcp.c @@ -381,9 +381,15 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq) if (limit_hit) break; } - if (last_out_len >= AES_BLOCK_SIZE) { - memcpy(req->info, out_buf+(last_out_len-AES_BLOCK_SIZE), - AES_BLOCK_SIZE); + + /* Copy the IV for CBC for chaining */ + if (!rctx->ecb) { + if (rctx->enc) + memcpy(req->info, out_buf+(last_out_len-AES_BLOCK_SIZE), + AES_BLOCK_SIZE); + else + memcpy(req->info, in_buf+(last_out_len-AES_BLOCK_SIZE), + AES_BLOCK_SIZE); } return ret; -- cgit v1.2.3