diff mbox

[6/8] crypto: caam - Convert GCM to new AEAD interface

Message ID 20150615135947.GA3363@gondor.apana.org.au (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show

Commit Message

Herbert Xu June 15, 2015, 1:59 p.m. UTC
On Mon, Jun 15, 2015 at 08:59:51PM +0800, Herbert Xu wrote:
> On Mon, Jun 15, 2015 at 03:33:20PM +0300, Horia Geant? wrote:
> > 
> > Testing on P2041RDB I see the following failures:
> > 
> > caam_jr ffe301000.jr: 40000f10: DECO: desc idx 15: Invalid Sequence
> > Command. A SEQ IN PTR OR SEQ OUT PTR Command is invalid or a SEQ KEY,
> > SEQ LOAD, SEQ FIFO LOAD, or SEQ FIFO STORE decremented the input or
> > output sequence length below 0. This error may result if a built-in
> > PROTOCOL Command has encountered a malformed PDU.
> > alg: aead: encryption failed on test 1 for rfc4106-gcm-aes-caam:
> > ret=-1073745680

OK I see a bug here where I used the wrong length so it's off by
authsize and that could explain the error.

> > caam_jr ffe301000.jr: 40000e10: DECO: desc idx 14: Invalid Sequence
> > Command. A SEQ IN PTR OR SEQ OUT PTR Command is invalid or a SEQ KEY,
> > SEQ LOAD, SEQ FIFO LOAD, or SEQ FIFO STORE decremented the input or
> > output sequence length below 0. This error may result if a built-in
> > PROTOCOL Command has encountered a malformed PDU.
> > alg: aead: encryption failed on test 1 for rfc4543-gcm-aes-caam:
> > ret=-1073745424

I still don't understand this one though.

Here's an incremental patch for rfc4106.


Thanks,
diff mbox

Patch

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index ca8948e..066a488 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -986,10 +986,10 @@  static int rfc4106_set_sh_desc(struct crypto_aead *aead)
 			     FIFOLD_TYPE_AAD | FIFOLD_TYPE_FLUSH1);
 
 	/* cryptlen = seqoutlen - assoclen */
-	append_math_sub(desc, VARSEQOUTLEN, SEQOUTLEN, REG0, CAAM_CMD_SZ);
+	append_math_sub(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
 
 	/* Will read cryptlen bytes */
-	append_math_add(desc, VARSEQINLEN, SEQOUTLEN, REG0, CAAM_CMD_SZ);
+	append_math_sub(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
 
 	/* Write encrypted data */
 	append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | FIFOLDST_VLF);
@@ -1054,10 +1054,10 @@  static int rfc4106_set_sh_desc(struct crypto_aead *aead)
 			     FIFOLD_TYPE_AAD | FIFOLD_TYPE_FLUSH1);
 
 	/* Will write cryptlen bytes */
-	append_math_sub(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
+	append_math_sub(desc, VARSEQOUTLEN, SEQOUTLEN, REG0, CAAM_CMD_SZ);
 
 	/* Will read cryptlen bytes */
-	append_math_sub(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ);
+	append_math_sub(desc, VARSEQINLEN, SEQOUTLEN, REG0, CAAM_CMD_SZ);
 
 	/* Store payload data */
 	append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | FIFOLDST_VLF);