eebcd0067a73a2d3925eaae57612ed9f1db0ecb0
[openwrt/staging/chunkeey.git] / target / linux / apm821xx / patches-4.14 / 023-0013-crypto-crypto4xx-fix-AES-CTR-blocksize-value.patch
1 From bfa2ba7d9e6b20aca82b99e6842fe18842ae3a0f Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Fri, 17 May 2019 23:15:57 +0200
4 Subject: [PATCH 13/15] crypto: crypto4xx - fix AES CTR blocksize value
5
6 This patch fixes a issue with crypto4xx's ctr(aes) that was
7 discovered by libcapi's kcapi-enc-test.sh test.
8
9 The some of the ctr(aes) encryptions test were failing on the
10 non-power-of-two test:
11
12 kcapi-enc - Error: encryption failed with error 0
13 kcapi-enc - Error: decryption failed with error 0
14 [FAILED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (128 bits):
15 original file (1d100e..cc96184c) and generated file (e3b0c442..1b7852b855)
16 [FAILED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (128 bits)
17 (openssl generated CT): original file (e3b0..5) and generated file (3..8e)
18 [PASSED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (128 bits)
19 (openssl generated PT)
20 [FAILED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (password):
21 original file (1d1..84c) and generated file (e3b..852b855)
22
23 But the 16, 32, 512, 65536 tests always worked.
24
25 Thankfully, this isn't a hidden hardware problem like previously,
26 instead this turned out to be a copy and paste issue.
27
28 With this patch, all the tests are passing with and
29 kcapi-enc-test.sh gives crypto4xx's a clean bill of health:
30 "Number of failures: 0" :).
31
32 Cc: stable@vger.kernel.org
33 Fixes: 98e87e3d933b ("crypto: crypto4xx - add aes-ctr support")
34 Fixes: f2a13e7cba9e ("crypto: crypto4xx - enable AES RFC3686, ECB, CFB and OFB offloads")
35 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
36 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
37 ---
38 drivers/crypto/amcc/crypto4xx_core.c | 4 ++--
39 1 file changed, 2 insertions(+), 2 deletions(-)
40
41 --- a/drivers/crypto/amcc/crypto4xx_core.c
42 +++ b/drivers/crypto/amcc/crypto4xx_core.c
43 @@ -1248,7 +1248,7 @@ static struct crypto4xx_alg_common crypt
44 .cra_flags = CRYPTO_ALG_NEED_FALLBACK |
45 CRYPTO_ALG_ASYNC |
46 CRYPTO_ALG_KERN_DRIVER_ONLY,
47 - .cra_blocksize = AES_BLOCK_SIZE,
48 + .cra_blocksize = 1,
49 .cra_ctxsize = sizeof(struct crypto4xx_ctx),
50 .cra_module = THIS_MODULE,
51 },
52 @@ -1268,7 +1268,7 @@ static struct crypto4xx_alg_common crypt
53 .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
54 .cra_flags = CRYPTO_ALG_ASYNC |
55 CRYPTO_ALG_KERN_DRIVER_ONLY,
56 - .cra_blocksize = AES_BLOCK_SIZE,
57 + .cra_blocksize = 1,
58 .cra_ctxsize = sizeof(struct crypto4xx_ctx),
59 .cra_module = THIS_MODULE,
60 },