BACKPORT: crypto: arch - conditionalize crypto api in arch glue for lib code

For glue code that's used by Zinc, the actual Crypto API functions might
not necessarily exist, and don't need to exist either. Before this
patch, there are valid build configurations that lead to a unbuildable
kernel. This fixes it to conditionalize those symbols on the existence
of the proper config entry.

(backport required changing CONFIG_CRYPTO_SKCIPHER to
CONFIG_CRYPTO_BLKCIPHER in a few places)

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 8394bfec51e0e565556101bcc4e2fe7551104cd8)
Bug: 152722841
[adelva: Removed all algos except blake2s]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Change-Id: Iedddadcd70a85587daadf1a8511b82fbdd574018
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Jason A. Donenfeld 2019-11-25 11:31:12 +01:00 committed by Alistair Delva
parent 514e31d6a1
commit 47c8de47e1

View File

@ -108,12 +108,14 @@ static int __init blake2s_mod_init(void)
XFEATURE_MASK_AVX512, NULL)) XFEATURE_MASK_AVX512, NULL))
static_branch_enable(&blake2s_use_avx512); static_branch_enable(&blake2s_use_avx512);
return crypto_register_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs)); return IS_REACHABLE(CONFIG_CRYPTO_HASH) ?
crypto_register_shashes(blake2s_algs,
ARRAY_SIZE(blake2s_algs)) : 0;
} }
static void __exit blake2s_mod_exit(void) static void __exit blake2s_mod_exit(void)
{ {
if (boot_cpu_has(X86_FEATURE_SSSE3)) if (IS_REACHABLE(CONFIG_CRYPTO_HASH) && boot_cpu_has(X86_FEATURE_SSSE3))
crypto_unregister_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs)); crypto_unregister_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
} }