linux/lib/crypto
Eric Biggers 4478e8eeb8 lib/crypto: tests: Depend on library options rather than selecting them
The convention for KUnit tests is to have the test kconfig options
visible only when the code they depend on is already enabled.  This way
only the tests that are relevant to the particular kernel build can be
enabled, either manually or via KUNIT_ALL_TESTS.

Update lib/crypto/tests/Kconfig to follow that convention, i.e. depend
on the corresponding library options rather than selecting them.  This
fixes an issue where enabling KUNIT_ALL_TESTS enabled non-test code.

This does mean that it becomes a bit more difficult to enable *all* the
crypto library tests (which is what I do as a maintainer of the code),
since doing so will now require enabling other options that select the
libraries.  Regardless, we should follow the standard KUnit convention.
I'll also add a .kunitconfig file that does enable all these options.

Note: currently most of the crypto library options are selected by
visible options in crypto/Kconfig, which can be used to enable them
without too much trouble.  If in the future we end up with more cases
like CRYPTO_LIB_CURVE25519 which is selected only by WIREGUARD (thus
making CRYPTO_LIB_CURVE25519_KUNIT_TEST effectively depend on WIREGUARD
after this commit), we could consider adding a new kconfig option that
enables all the library code specifically for testing.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Closes: https://lore.kernel.org/r/CAMuHMdULzMdxuTVfg8_4jdgzbzjfx-PHkcgbGSthcUx_sHRNMg@mail.gmail.com
Fixes: 4dcf6cadda ("lib/crypto: tests: Add KUnit tests for SHA-224 and SHA-256")
Fixes: 571eaeddb6 ("lib/crypto: tests: Add KUnit tests for SHA-384 and SHA-512")
Fixes: 6dd4d9f791 ("lib/crypto: tests: Add KUnit tests for Poly1305")
Fixes: 66b1306079 ("lib/crypto: tests: Add KUnit tests for SHA-1 and HMAC-SHA1")
Fixes: d6b6aac0cd ("lib/crypto: tests: Add KUnit tests for MD5 and HMAC-MD5")
Fixes: afc4e4a5f1 ("lib/crypto: tests: Migrate Curve25519 self-test to KUnit")
Fixes: 6401fd334d ("lib/crypto: tests: Add KUnit tests for BLAKE2b")
Fixes: 15c64c47e4 ("lib/crypto: tests: Add SHA3 kunit tests")
Fixes: b3aed551b3 ("lib/crypto: tests: Add KUnit tests for POLYVAL")
Fixes: ed894faccb ("lib/crypto: tests: Add KUnit tests for ML-DSA verification")
Fixes: 7246fe6cd6 ("lib/crypto: tests: Add KUnit tests for NH")
Cc: stable@vger.kernel.org
Reviewed-by: David Gow <david@davidgow.net>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20260226191749.39397-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
2026-02-28 19:17:30 -08:00
..
arm lib/crypto: arm/aes: Migrate optimized code into library 2026-01-12 11:39:58 -08:00
arm64 lib/crypto: arm64/aes: Migrate optimized code into library 2026-01-12 11:39:58 -08:00
mips lib/crypto: chacha: Consolidate into single module 2025-08-29 09:50:19 -07:00
mpi Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
powerpc lib/crypto: powerpc/aes: Fix rndkey_from_vsx() on big endian CPUs 2026-02-18 13:38:14 -08:00
riscv lib/crypto: riscv/aes: Migrate optimized code into library 2026-01-12 11:39:58 -08:00
s390 lib/crypto: s390/aes: Migrate optimized code into library 2026-01-15 14:08:55 -08:00
sparc lib/crypto: sparc/aes: Migrate optimized code into library 2026-01-15 14:09:07 -08:00
tests lib/crypto: tests: Depend on library options rather than selecting them 2026-02-28 19:17:30 -08:00
x86 lib/crypto: x86/aes: Add AES-NI optimization 2026-01-15 14:09:07 -08:00
aes.c lib/crypto: aes: Drop 'volatile' from aes_sbox and aes_inv_sbox 2026-01-15 14:09:09 -08:00
aescfb.c lib/crypto: aescfb: Use new AES library API 2026-01-15 14:09:08 -08:00
aesgcm.c lib/crypto: aesgcm: Use new AES library API 2026-01-15 14:09:09 -08:00
arc4.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00
blake2b.c lib/crypto: blake2b: Roll up BLAKE2b round loop on 32-bit 2025-12-09 15:10:21 -08:00
blake2s.c lib/crypto: blake2s: Replace manual unrolling with unrolled_full 2025-12-09 15:10:21 -08:00
chacha-block-generic.c lib/crypto: chacha: Rename chacha.c to chacha-block-generic.c 2025-08-29 09:50:19 -07:00
chacha.c lib/crypto: chacha: Consolidate into single module 2025-08-29 09:50:19 -07:00
chacha20poly1305-selftest.c crypto: lib/chacha - strongly type the ChaCha state 2025-05-12 13:32:53 +08:00
chacha20poly1305.c lib/crypto: chacha20poly1305: Statically check fixed array lengths 2025-11-23 12:19:21 -08:00
curve25519-fiat32.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
curve25519-hacl64.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
curve25519.c lib/crypto: curve25519: Consolidate into single module 2025-09-06 16:32:43 -07:00
des.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00
fips-mldsa.h lib/crypto: mldsa: Add FIPS cryptographic algorithm self-test 2026-01-12 11:07:50 -08:00
fips.h lib/crypto: sha3: Add FIPS cryptographic algorithm self-test 2025-11-05 20:02:35 -08:00
gf128mul.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
hash_info.c lib/crypto: hash_info: Move hash_info.c into lib/crypto/ 2025-07-08 12:03:44 -07:00
Kconfig lib/crypto: x86/aes: Add AES-NI optimization 2026-01-15 14:09:07 -08:00
Makefile lib/crypto: x86/aes: Add AES-NI optimization 2026-01-15 14:09:07 -08:00
md5.c lib/crypto: md5: Use rol32() instead of open-coding it 2026-01-12 11:07:50 -08:00
memneq.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00
mldsa.c lib/crypto: mldsa: Clarify the documentation for mldsa_verify() slightly 2026-02-03 19:28:51 -08:00
nh.c lib/crypto: nh: Add NH library 2026-01-12 11:07:49 -08:00
poly1305-donna32.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00
poly1305-donna64.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00
poly1305.c lib/crypto: poly1305: Consolidate into single module 2025-08-29 09:49:18 -07:00
polyval.c lib/crypto: polyval: Add POLYVAL library 2025-11-11 11:03:38 -08:00
sha1.c lib/crypto: sha1: Remove low-level functions from API 2026-01-27 15:47:41 -08:00
sha3.c lib/crypto: sha3: Support arch overrides of one-shot digest functions 2025-11-05 20:02:35 -08:00
sha256.c lib/crypto: Add FIPS self-tests for SHA-1 and SHA-2 2025-10-29 22:04:24 -07:00
sha512.c lib/crypto: Add FIPS self-tests for SHA-1 and SHA-2 2025-10-29 22:04:24 -07:00
simd.c crypto: api - move crypto_simd_disabled_for_test to lib 2024-10-28 18:33:11 +08:00
sm3.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00
utils.c lib/crypto: Explicitly include <linux/export.h> 2025-06-30 09:26:19 -07:00