All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Horia Geantă" <horia.geanta@nxp.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
	<linux-crypto@vger.kernel.org>,
	Dan Douglass <dan.douglass@nxp.com>,
	Tudor Ambarus <tudor.ambarus@microchip.com>
Subject: [PATCH 04/13] crypto: caam/qi - properly set IV after {en,de}crypt
Date: Fri, 7 Jul 2017 16:05:14 +0300	[thread overview]
Message-ID: <20170707130523.32427-5-horia.geanta@nxp.com> (raw)
In-Reply-To: <20170707130523.32427-1-horia.geanta@nxp.com>

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: <stable@vger.kernel.org>
Fixes: b189817cf789 ("crypto: caam/qi - add ablkcipher and authenc algorithms")
Suggested-by: David Gstir <david@sigma-star.at>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg_qi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index 2dde23abbd3a..a5d634e0aef3 100644
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -776,9 +776,9 @@ static void ablkcipher_done(struct caam_drv_req *drv_req, u32 status)
 	struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
 	struct caam_ctx *caam_ctx = crypto_ablkcipher_ctx(ablkcipher);
 	struct device *qidev = caam_ctx->qidev;
-#ifdef DEBUG
 	int ivsize = crypto_ablkcipher_ivsize(ablkcipher);
 
+#ifdef DEBUG
 	dev_err(qidev, "%s %d: status 0x%x\n", __func__, __LINE__, status);
 #endif
 
@@ -799,6 +799,13 @@ static void ablkcipher_done(struct caam_drv_req *drv_req, u32 status)
 	ablkcipher_unmap(qidev, edesc, req);
 	qi_cache_free(edesc);
 
+	/*
+	 * 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.
+	 */
+	scatterwalk_map_and_copy(req->info, req->dst, req->nbytes - ivsize,
+				 ivsize, 0);
+
 	ablkcipher_request_complete(req, status);
 }
 
-- 
2.12.0.264.gd6db3f216544

  parent reply	other threads:[~2017-07-07 13:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07 13:05 [PATCH 00/13] crypto: caam - fixes, clean-up Horia Geantă
2017-07-07 13:05 ` [PATCH 01/13] crypto: caam/qi - fix typo in authenc alg driver name Horia Geantă
2017-07-07 13:05 ` [PATCH 02/13] crypto: caam/qi - fix compilation with DEBUG enabled Horia Geantă
2017-07-07 13:05 ` [PATCH 03/13] crypto: caam/qi - fix compilation with CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y Horia Geantă
2017-07-07 13:05 ` Horia Geantă [this message]
2017-07-07 13:05 ` [PATCH 05/13] crypto: caam/qi - handle large number of S/Gs case Horia Geantă
2017-07-10  5:23   ` Horia Geantă
2017-07-07 13:05 ` [PATCH 06/13] crypto: caam/qi - fix AD length endianness in S/G entry Horia Geantă
2017-07-07 13:05 ` [PATCH 07/13] crypto: caam/qi - explicitly set dma_ops Horia Geantă
2017-07-07 13:05 ` [PATCH 08/13] crypto: caam/qi - remove unused header sg_sw_sec4.h Horia Geantă
2017-07-07 13:05 ` [PATCH 09/13] crypto: caam/qi - lower driver verbosity Horia Geantă
2017-07-07 13:05 ` [PATCH 10/13] crypto: caam - remove unused sg_to_sec4_sg_len() Horia Geantă
2017-07-07 13:05 ` [PATCH 11/13] crypto: caam - remove unused variables in caam_drv_private Horia Geantă
2017-07-07 13:05 ` [PATCH 12/13] crypto: caam - clean-up in caam_init_rng() Horia Geantă
2017-07-07 13:16   ` Horia Geantă
2017-07-07 13:05 ` [PATCH 13/13] crypto: caam - fix condition for the jump over key(s) command Horia Geantă
2017-07-10  5:40 ` [PATCH v2 00/13] crypto: caam - fixes, clean-up Horia Geantă
2017-07-10  5:40   ` [PATCH v2 01/13] crypto: caam/qi - fix typo in authenc alg driver name Horia Geantă
2017-07-10  5:40   ` [PATCH v2 02/13] crypto: caam/qi - fix compilation with DEBUG enabled Horia Geantă
2017-07-10  5:40   ` [PATCH v2 03/13] crypto: caam/qi - fix compilation with CONFIG_DEBUG_FORCE_WEAK_PER_CPU=y Horia Geantă
2017-07-10  5:40   ` [PATCH v2 04/13] crypto: caam/qi - properly set IV after {en,de}crypt Horia Geantă
2017-07-10  5:40   ` [PATCH v2 05/13] crypto: caam/qi - handle large number of S/Gs case Horia Geantă
2017-07-10  5:40   ` [PATCH v2 06/13] crypto: caam/qi - fix AD length endianness in S/G entry Horia Geantă
2017-07-10  5:40   ` [PATCH v2 07/13] crypto: caam/qi - explicitly set dma_ops Horia Geantă
2017-07-10  5:40   ` [PATCH v2 08/13] crypto: caam/qi - remove unused header sg_sw_sec4.h Horia Geantă
2017-07-10  5:40   ` [PATCH v2 09/13] crypto: caam/qi - lower driver verbosity Horia Geantă
2017-07-10  5:40   ` [PATCH v2 10/13] crypto: caam - remove unused sg_to_sec4_sg_len() Horia Geantă
2017-07-10  5:40   ` [PATCH v2 11/13] crypto: caam - remove unused variables in caam_drv_private Horia Geantă
2017-07-10  5:40   ` [PATCH v2 12/13] crypto: caam - clean-up in caam_init_rng() Horia Geantă
2017-07-10  5:40   ` [PATCH v2 13/13] crypto: caam - fix condition for the jump over key(s) command Horia Geantă
2017-07-18 10:39   ` [PATCH v2 00/13] crypto: caam - fixes, clean-up Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170707130523.32427-5-horia.geanta@nxp.com \
    --to=horia.geanta@nxp.com \
    --cc=dan.douglass@nxp.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=tudor.ambarus@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.