|
|
@@ -887,6 +887,7 @@ 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 ivsize = crypto_ablkcipher_ivsize(ablkcipher);
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
@@ -911,10 +912,11 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
|
|
|
|
|
|
/*
|
|
|
* The crypto API expects us to set the IV (req->info) to the last
|
|
|
- * ciphertext block. This is used e.g. by the CTS mode.
|
|
|
+ * ciphertext block when running in CBC mode.
|
|
|
*/
|
|
|
- scatterwalk_map_and_copy(req->info, req->dst, req->nbytes - ivsize,
|
|
|
- ivsize, 0);
|
|
|
+ if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC)
|
|
|
+ scatterwalk_map_and_copy(req->info, req->dst, req->nbytes -
|
|
|
+ ivsize, ivsize, 0);
|
|
|
|
|
|
/* In case initial IV was generated, copy it in GIVCIPHER request */
|
|
|
if (edesc->iv_dir == DMA_FROM_DEVICE) {
|
|
|
@@ -1651,10 +1653,11 @@ static int ablkcipher_decrypt(struct ablkcipher_request *req)
|
|
|
|
|
|
/*
|
|
|
* The crypto API expects us to set the IV (req->info) to the last
|
|
|
- * ciphertext block.
|
|
|
+ * ciphertext block when running in CBC mode.
|
|
|
*/
|
|
|
- scatterwalk_map_and_copy(req->info, req->src, req->nbytes - ivsize,
|
|
|
- ivsize, 0);
|
|
|
+ if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC)
|
|
|
+ scatterwalk_map_and_copy(req->info, req->src, req->nbytes -
|
|
|
+ ivsize, ivsize, 0);
|
|
|
|
|
|
/* Create and submit job descriptor*/
|
|
|
init_ablkcipher_job(ctx->sh_desc_dec, ctx->sh_desc_dec_dma, edesc, req);
|