v1.5 branch refresh based upon upstream master @ c8677ca89e53e3be7988d54280fce166cc894a7e
[librecmc/librecmc.git] / target / linux / generic / hack-4.9 / 260-crypto_test_dependencies.patch
1 From fd1799b0bf5efa46dd3e6dfbbf3955564807e508 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Fri, 7 Jul 2017 17:12:51 +0200
4 Subject: kernel: prevent cryptomgr from pulling in useless extra dependencies for tests that are not run
5
6 Reduces kernel size after LZMA by about 5k on MIPS
7
8 lede-commit: 044c316167e076479a344c59905e5b435b84a77f
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11  crypto/Kconfig   | 13 ++++++-------
12  crypto/algboss.c |  4 ++++
13  2 files changed, 10 insertions(+), 7 deletions(-)
14
15 --- a/crypto/Kconfig
16 +++ b/crypto/Kconfig
17 @@ -132,12 +132,12 @@ config CRYPTO_MANAGER
18           cbc(aes).
19  
20  config CRYPTO_MANAGER2
21 -       def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y)
22 -       select CRYPTO_AEAD2
23 -       select CRYPTO_HASH2
24 -       select CRYPTO_BLKCIPHER2
25 -       select CRYPTO_AKCIPHER2
26 -       select CRYPTO_KPP2
27 +       def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y && !CRYPTO_MANAGER_DISABLE_TESTS)
28 +       select CRYPTO_AEAD2 if !CRYPTO_MANAGER_DISABLE_TESTS
29 +       select CRYPTO_HASH2 if !CRYPTO_MANAGER_DISABLE_TESTS
30 +       select CRYPTO_BLKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS
31 +       select CRYPTO_AKCIPHER2 if !CRYPTO_MANAGER_DISABLE_TESTS
32 +       select CRYPTO_KPP2 if !CRYPTO_MANAGER_DISABLE_TESTS
33  
34  config CRYPTO_USER
35         tristate "Userspace cryptographic algorithm configuration"
36 @@ -150,7 +150,6 @@ config CRYPTO_USER
37  config CRYPTO_MANAGER_DISABLE_TESTS
38         bool "Disable run-time self tests"
39         default y
40 -       depends on CRYPTO_MANAGER2
41         help
42           Disable run-time self tests that normally take place at
43           algorithm registration.
44 --- a/crypto/algboss.c
45 +++ b/crypto/algboss.c
46 @@ -248,12 +248,16 @@ static int cryptomgr_schedule_test(struc
47         type = alg->cra_flags;
48  
49         /* This piece of crap needs to disappear into per-type test hooks. */
50 +#ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
51 +       type |= CRYPTO_ALG_TESTED;
52 +#else
53         if (!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
54               CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
55             ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
56              CRYPTO_ALG_TYPE_BLKCIPHER ? alg->cra_blkcipher.ivsize :
57                                          alg->cra_ablkcipher.ivsize))
58                 type |= CRYPTO_ALG_TESTED;
59 +#endif
60  
61         param->type = type;
62