linux/lib/crypto/tests
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
..
blake2b-testvecs.h lib/crypto: tests: Add KUnit tests for BLAKE2b 2025-11-11 11:07:36 -08:00
blake2b_kunit.c lib/crypto: tests: Add KUnit tests for BLAKE2b 2025-11-11 11:07:36 -08:00
blake2s-testvecs.h lib/crypto: tests: Add KUnit tests for BLAKE2s 2025-08-29 09:50:19 -07:00
blake2s_kunit.c lib/crypto: blake2s: Rename blake2s_state to blake2s_ctx 2025-10-29 22:04:24 -07:00
curve25519_kunit.c lib/crypto: tests: Add Curve25519 benchmark 2025-09-06 16:32:42 -07:00
hash-test-template.h kunit, lib/crypto: Move run_irq_test() to common header 2025-08-11 11:28:00 -07:00
Kconfig lib/crypto: tests: Depend on library options rather than selecting them 2026-02-28 19:17:30 -08:00
Makefile lib/crypto: tests: Add KUnit tests for NH 2026-01-12 11:07:49 -08:00
md5-testvecs.h lib/crypto: tests: Add KUnit tests for MD5 and HMAC-MD5 2025-08-27 08:15:35 -07:00
md5_kunit.c lib/crypto: tests: Add KUnit tests for MD5 and HMAC-MD5 2025-08-27 08:15:35 -07:00
mldsa-testvecs.h lib/crypto: tests: Add KUnit tests for ML-DSA verification 2026-01-12 11:07:49 -08:00
mldsa_kunit.c lib/crypto: tests: Add KUnit tests for ML-DSA verification 2026-01-12 11:07:49 -08:00
nh-testvecs.h lib/crypto: tests: Add KUnit tests for NH 2026-01-12 11:07:49 -08:00
nh_kunit.c lib/crypto: tests: Add KUnit tests for NH 2026-01-12 11:07:49 -08:00
poly1305-testvecs.h lib/crypto: tests: Add KUnit tests for Poly1305 2025-07-14 11:29:36 -07:00
poly1305_kunit.c lib/crypto: tests: Add KUnit tests for Poly1305 2025-07-14 11:29:36 -07:00
polyval-testvecs.h lib/crypto: tests: Add KUnit tests for POLYVAL 2025-11-11 11:07:52 -08:00
polyval_kunit.c lib/crypto: tests: polyval_kunit: Increase iterations for preparekey in IRQs 2026-01-08 11:14:59 -08:00
sha1-testvecs.h lib/crypto: tests: Add KUnit tests for SHA-1 and HMAC-SHA1 2025-07-14 11:29:36 -07:00
sha1_kunit.c lib/crypto: tests: Add KUnit tests for SHA-1 and HMAC-SHA1 2025-07-14 11:29:36 -07:00
sha3-testvecs.h lib/crypto: tests: Add additional SHAKE tests 2025-11-11 11:07:36 -08:00
sha3_kunit.c lib/crypto: tests: Add additional SHAKE tests 2025-11-11 11:07:36 -08:00
sha224-testvecs.h
sha224_kunit.c
sha256-testvecs.h
sha256_kunit.c lib/crypto: tests: Fix KMSAN warning in test_sha256_finup_2x() 2025-11-21 10:22:24 -08:00
sha384-testvecs.h lib/crypto: tests: Add KUnit tests for SHA-384 and SHA-512 2025-07-14 11:29:36 -07:00
sha384_kunit.c lib/crypto: tests: Add KUnit tests for SHA-384 and SHA-512 2025-07-14 11:29:36 -07:00
sha512-testvecs.h lib/crypto: tests: Add KUnit tests for SHA-384 and SHA-512 2025-07-14 11:29:36 -07:00
sha512_kunit.c lib/crypto: tests: Add KUnit tests for SHA-384 and SHA-512 2025-07-14 11:29:36 -07:00