]> git.itanic.dy.fi Git - linux-stable/commit
crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues
authorChristian Lamparter <chunkeey@gmail.com>
Mon, 22 Apr 2019 11:25:59 +0000 (13:25 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 May 2019 06:03:29 +0000 (14:03 +0800)
commit7e92e1717e3eaf6b322c252947c696b3059f05be
treeb3cae93392b87a41f5db49d90cb63b89d12b10a3
parent25baaf8e2c93197d063b372ef7b62f2767c7ac0b
crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues

Currently, crypto4xx CFB and OFB AES ciphers are
failing testmgr's test vectors.

|cfb-aes-ppc4xx encryption overran dst buffer on test vector 3, cfg="in-place"
|ofb-aes-ppc4xx encryption overran dst buffer on test vector 1, cfg="in-place"

This is because of a very subtile "bug" in the hardware that
gets indirectly mentioned in 18.1.3.5 Encryption/Decryption
of the hardware spec:

the OFB and CFB modes for AES are listed there as operation
modes for >>> "Block ciphers" <<<. Which kind of makes sense,
but we would like them to be considered as stream ciphers just
like the CTR mode.

To workaround this issue and stop the hardware from causing
"overran dst buffer" on crypttexts that are not a multiple
of 16 (AES_BLOCK_SIZE), we force the driver to use the scatter
buffers as the go-between.

As a bonus this patch also kills redundant pd_uinfo->num_gd
and pd_uinfo->num_sd setters since the value has already been
set before.

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_core.c