diff mbox

crypto: caam - fix IV loading for authenc (giv)decryption

Message ID 1472220822-18888-1-git-send-email-horia.geanta@nxp.com (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show

Commit Message

Horia Geanta Aug. 26, 2016, 2:13 p.m. UTC
For algorithms that implement IV generators before the crypto ops,
the IV needed for decryption is initially located in req->src
scatterlist, not in req->iv.
aead_givdecrypt() is updated to put the IV in place.

Cc: <stable@vger.kernel.org> # 4.3+
Fixes: 479bcc7c5b9e ("crypto: caam - Convert authenc to new AEAD interface")
Suggested-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---

Herbert, as you suggested, aead_givdecrypt() is now setting the IV.

In terms of optimizations, would it be safe to assume all "geniv" authenc
algorithms - {echainiv, seqiv}(authenc) - get assoc,iv,ciphertext in
req->src for decryption?
The idea would be to avoid copying IV into req->iv and instruct
the crypto engine to access it directly from req->src scatterlist.

 drivers/crypto/caam/caamalg.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Herbert Xu Aug. 26, 2016, 2:39 p.m. UTC | #1
On Fri, Aug 26, 2016 at 05:13:42PM +0300, Horia Geantă wrote:
> 
> In terms of optimizations, would it be safe to assume all "geniv" authenc
> algorithms - {echainiv, seqiv}(authenc) - get assoc,iv,ciphertext in
> req->src for decryption?

Yes.  They all get the raw IPsec packet, apart from the ESN munging.

Cheers,
diff mbox

Patch

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 6dc597126b79..78be2bea1273 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -2545,6 +2545,7 @@  static int aead_givdecrypt(struct aead_request *req)
 	if (req->cryptlen < ivsize)
 		return -EINVAL;
 
+	scatterwalk_map_and_copy(req->iv, req->src, req->assoclen, ivsize, 0);
 	req->cryptlen -= ivsize;
 	req->assoclen += ivsize;