diff options
author | Radu Solea <radu.solea@nxp.com> | 2017-04-13 15:22:41 +0300 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:26:20 +0800 |
commit | 886be06477a79f4fea012bd52a35c61c9d8a2b24 (patch) | |
tree | dc0dda6fbc059bf92811b797be826faf5b74bbf6 /drivers/crypto/caam/caamalg.c | |
parent | a44d2fe0540fe5d620d22f49dc54bbcaaf95f1eb (diff) |
MLK-14611 Fix CBC mode support by returning a correct IV
Current CBC mode does not return the last cyphertext block
as IV for operation chaining. CTS fails because of incorrect IV.
Signed-off-by: Radu Solea <radu.solea@nxp.com>
Diffstat (limited to 'drivers/crypto/caam/caamalg.c')
-rw-r--r-- | drivers/crypto/caam/caamalg.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 904cc92e6b10..ad56c99d3efd 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -880,7 +880,10 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, struct ablkcipher_request *req = context; struct ablkcipher_edesc *edesc; struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req); + struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher); + int bsize = crypto_ablkcipher_blocksize(ablkcipher); int ivsize = crypto_ablkcipher_ivsize(ablkcipher); + size_t ivcopy = min_t(size_t, bsize, ivsize); #ifdef DEBUG dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); @@ -923,6 +926,12 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, kfree(edesc); + /* Pass IV along for cbc */ + if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) { + scatterwalk_map_and_copy(req->info, req->dst, + req->nbytes - bsize, ivcopy, 0); + } + ablkcipher_request_complete(req, err); } |