diff options
author | Franck LENORMAND <franck.lenormand@nxp.com> | 2018-09-28 17:27:30 +0200 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:34:20 +0800 |
commit | bc23edcba2a24176af576ba92dc9a4fa05c2d7f4 (patch) | |
tree | 625bb6b9b06bcb8661a4e9cd82056299c6082885 /drivers/crypto/mxs-dcp.c | |
parent | 72fe03b51d7898849bc3e78998f481f4632e35fd (diff) |
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 <franck.lenormand@nxp.com>
Diffstat (limited to 'drivers/crypto/mxs-dcp.c')
-rw-r--r-- | drivers/crypto/mxs-dcp.c | 12 |
1 files changed, 9 insertions, 3 deletions
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; |