]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nvme-auth: common: add KUnit tests for TLS key derivation
authorEric Biggers <ebiggers@kernel.org>
Mon, 2 Mar 2026 07:59:42 +0000 (23:59 -0800)
committerKeith Busch <kbusch@kernel.org>
Fri, 27 Mar 2026 14:35:00 +0000 (07:35 -0700)
commitf990ad67f0febc51274adb604d5bdeab0d06d024
tree1dbb91c931b757c04d0003217fdf26148d4f9030
parentbf0e2567a639c455110f9be5db8c92032175e222
nvme-auth: common: add KUnit tests for TLS key derivation

Unit-test the sequence of function calls that derive tls_psk, so that we
can be more confident that changes in the implementation don't break it.

Since the NVMe specification doesn't seem to include any test vectors
for this (nor does its description of the algorithm seem to match what
was actually implemented, for that matter), I just set the expected
values to the values that the code currently produces.  In the case
of SHA-512, nvme_auth_generate_digest() currently returns -EINVAL, so
for now the test tests for that too.  If it is later determined that
some other behavior is needed, the test can be updated accordingly.

Tested with:

    tools/testing/kunit/kunit.py run --kunitconfig drivers/nvme/common/

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/common/.kunitconfig [new file with mode: 0644]
drivers/nvme/common/Kconfig
drivers/nvme/common/Makefile
drivers/nvme/common/tests/auth_kunit.c [new file with mode: 0644]