lib/crypto: blake2s: Disable self test if CONFIG_CRYPTO isn't enabled
Subsystems (2)
PATCH 1/1 lib/crypto: blake2s: Disable self test if CONFIG_CRYPTO isn't enabled
From: Daniel Palmer <[email protected]>
Currently CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is used to remove the self test code. CONFIG_CRYPTO_MANAGER_DISABLE_TESTS depends on CONFIG_CRYPTO so its impossible to disable the self test without enabling CONFIG_CRYPTO.
If you don't want CONFIG_CRYPTO you probably don't want self tests so remove the self tests in that case too.
--- lib/crypto/blake2s.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/crypto/blake2s.c +2 -1
@@ -60,7 +60,8 @@ EXPORT_SYMBOL(blake2s_final);static int __init blake2s_mod_init (void ) { -if (!IS_ENABLED (CONFIG_CRYPTO_MANAGER_DISABLE_TESTS ) && +if (IS_ENABLED (CONFIG_CRYPTO ) && + !IS_ENABLED (CONFIG_CRYPTO_MANAGER_DISABLE_TESTS ) &&WARN_ON (!blake2s_selftest ()))return -ENODEV ;return 0 ;
Signature · 1 line
2.47.2
Quoted 10 lines · Daniel Palmer
From: Daniel Palmer <[email protected]>
Currently
CONFIG_CRYPTO_MANAGER_DISABLE_TESTSis used to remove the self test code.CONFIG_CRYPTO_MANAGER_DISABLE_TESTSdepends onCONFIG_CRYPTOso its impossible to disable the self test without enablingCONFIG_CRYPTO.If you don't want
CONFIG_CRYPTOyou probably don't want self tests so remove the self tests in that case too.
Quoted 6 lines
Fixes 66d7fb94e4ff ("crypto: blake2s - generic C library implementation and selftest")Signed-off-by Daniel Palmer <[email protected]>--- lib/crypto/blake2s.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
This is okay as a quick fix, but really the lib/crypto/ tests should be refactored into KUnit tests that aren't dependent on CRYPTO. FWIW, I recently fixed this for the CRC functions: lib/tests/crc_kunit.c.
- Eric
Eric Biggers
maintainerQuoted 18 lines · Eric Biggers
Quoted 10 lines · Daniel Palmer
From: Daniel Palmer <[email protected]>
Currently
CONFIG_CRYPTO_MANAGER_DISABLE_TESTSis used to remove the self test code.CONFIG_CRYPTO_MANAGER_DISABLE_TESTSdepends onCONFIG_CRYPTOso its impossible to disable the self test without enablingCONFIG_CRYPTO.If you don't want
CONFIG_CRYPTOyou probably don't want self tests so remove the self tests in that case too.Quoted 6 lines
Fixes 66d7fb94e4ff ("crypto: blake2s - generic C library implementation and selftest")Signed-off-by Daniel Palmer <[email protected]>--- lib/crypto/blake2s.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 6 lines
Acked-by Eric Biggers <[email protected]>This is okay as a quick fix, but really the
lib/crypto/tests should be refactored into KUnit tests that aren't dependent on CRYPTO. FWIW, I recently fixed this for the CRC functions:lib/tests/crc_kunit.c.
My series "[PATCH 0/9] Clean up the crypto testing options"
(https://lore.kernel.org/r/[email protected]/) also fixes this by replacing CRYPTO_MANAGER_DISABLE_TESTS with a non-negated option. (But we should still disentangle the library tests from CRYPTO at some point.)
- Eric