Re: [PATCH] lib/crypto: tests: Migrate ChaCha20Poly1305 self-test to KUnit

From: Eric Biggers

Date: Mon Mar 30 2026 - 15:42:27 EST


On Fri, Mar 27, 2026 at 03:42:29PM -0700, Eric Biggers wrote:
> Move the ChaCha20Poly1305 test from an ad-hoc self-test to a KUnit test.
>
> Keep the same test logic for now, just translated to KUnit.
>
> Moving to KUnit has multiple benefits, such as:
>
> - Consistency with the rest of the lib/crypto/ tests.
>
> - Kernel developers familiar with KUnit, which is used kernel-wide, can
> quickly understand the test and how to enable and run it.
>
> - The test will be automatically run by anyone using
> lib/crypto/.kunitconfig or KUnit's all_tests.config.
>
> - Results are reported using the standard KUnit mechanism.
>
> - It eliminates one of the few remaining back-references to crypto/ from
> lib/crypto/, specifically a reference to CONFIG_CRYPTO_SELFTESTS.
>
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> ---
> include/crypto/chacha20poly1305.h | 2 -
> lib/crypto/.kunitconfig | 1 +
> lib/crypto/Makefile | 1 -
> lib/crypto/chacha20poly1305.c | 14 -
> lib/crypto/tests/Kconfig | 10 +
> lib/crypto/tests/Makefile | 1 +
> .../chacha20poly1305_kunit.c} | 1493 +++++++++--------
> 7 files changed, 760 insertions(+), 762 deletions(-)
> rename lib/crypto/{chacha20poly1305-selftest.c => tests/chacha20poly1305_kunit.c} (91%)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric