Skip to content

Commit a68a193

Browse files
horiagherbertx
authored andcommitted
crypto: caam/qi - properly set IV after {en,de}crypt
caam/qi needs a fix similar to what was done for caam/jr in commit "crypto: caam/qi - properly set IV after {en,de}crypt", to allow for ablkcipher/skcipher chunking/streaming. Cc: <[email protected]> Fixes: b189817 ("crypto: caam/qi - add ablkcipher and authenc algorithms") Suggested-by: David Gstir <[email protected]> Signed-off-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 1ed289f commit a68a193

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/crypto/caam/caamalg_qi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,9 @@ static void ablkcipher_done(struct caam_drv_req *drv_req, u32 status)
776776
struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
777777
struct caam_ctx *caam_ctx = crypto_ablkcipher_ctx(ablkcipher);
778778
struct device *qidev = caam_ctx->qidev;
779-
#ifdef DEBUG
780779
int ivsize = crypto_ablkcipher_ivsize(ablkcipher);
781780

781+
#ifdef DEBUG
782782
dev_err(qidev, "%s %d: status 0x%x\n", __func__, __LINE__, status);
783783
#endif
784784

@@ -799,6 +799,13 @@ static void ablkcipher_done(struct caam_drv_req *drv_req, u32 status)
799799
ablkcipher_unmap(qidev, edesc, req);
800800
qi_cache_free(edesc);
801801

802+
/*
803+
* The crypto API expects us to set the IV (req->info) to the last
804+
* ciphertext block. This is used e.g. by the CTS mode.
805+
*/
806+
scatterwalk_map_and_copy(req->info, req->dst, req->nbytes - ivsize,
807+
ivsize, 0);
808+
802809
ablkcipher_request_complete(req, status);
803810
}
804811

0 commit comments

Comments
 (0)