]> git.itanic.dy.fi Git - linux-stable/commit
crypto: crypto4xx - fix ctr-aes missing output IV
authorChristian Lamparter <chunkeey@gmail.com>
Mon, 22 Apr 2019 11:25:58 +0000 (13:25 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 May 2019 06:03:28 +0000 (14:03 +0800)
commit25baaf8e2c93197d063b372ef7b62f2767c7ac0b
tree41181dfeafe607d8e251f4a8e7cc979ab57f3b3e
parent1036633e10f86b793e60dd8698c65df6712cad2a
crypto: crypto4xx - fix ctr-aes missing output IV

Commit 8efd972ef96a ("crypto: testmgr - support checking skcipher output IV")
caused the crypto4xx driver to produce the following error:

| ctr-aes-ppc4xx encryption test failed (wrong output IV)
| on test vector 0, cfg="in-place"

This patch fixes this by reworking the crypto4xx_setkey_aes()
function to:

 - not save the iv for ECB (as per 18.2.38 CRYP0_SA_CMD_0:
   "This bit mut be cleared for DES ECB mode or AES ECB mode,
   when no IV is used.")

 - instruct the hardware to save the generated IV for all
   other modes of operations that have IV and then supply
   it back to the callee in pretty much the same way as we
   do it for cbc-aes already.

 - make it clear that the DIR_(IN|OUT)BOUND is the important
   bit that tells the hardware to encrypt or decrypt the data.
   (this is cosmetic - but it hopefully prevents me from
    getting confused again).

 - don't load any bogus hash when we don't use any hash
   operation to begin with.

Cc: stable@vger.kernel.org
Fixes: f2a13e7cba9e ("crypto: crypto4xx - enable AES RFC3686, ECB, CFB and OFB offloads")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/amcc/crypto4xx_alg.c