From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH v3 0/2] KUnit tests for SHA-2 library functions
Date: Mon, 30 Jun 2025 09:20:12 -0700 [thread overview]
Message-ID: <20250630162014.6463-1-ebiggers@kernel.org> (raw)
This series is also available at:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git sha2-kunit-v3
This series adds KUnit tests for the SHA-2 library functions.
Most of this code was originally part of my series
"SHA-512 library functions". I made a few updates in
"SHA-256 library improvements". As per the request from Linus that the
tests be kept last on the branch for a separate pull request, I've
reordered the history to add the tests last. Thus this patch series.
Testing strategy:
- Each SHA variant gets its own KUnit test suite, but a header is used
to share most of the test code among the SHA variants.
- Test against vectors generated by the Python hashlib and hmac modules.
- Test incremental computation.
- Test with a guard page to catch buffer overruns even in assembly code.
- Test various overlap and alignment cases.
- Compute hashes in task, softirq, and hardirq context in parallel, to
verify that the functions work as expected in all contexts and that
fallback code paths are exercised.
- Test that the finalization functions zeroize their context.
- Include benchmarks, guarded by a separate Kconfig option.
Eric Biggers (2):
lib/crypto: sha512: Add KUnit tests for SHA-384 and SHA-512
lib/crypto: sha256: Add KUnit tests for SHA-224 and SHA-256
lib/crypto/Kconfig | 2 +
lib/crypto/Makefile | 2 +
lib/crypto/tests/Kconfig | 25 +
lib/crypto/tests/Makefile | 6 +
lib/crypto/tests/hash-test-template.h | 512 ++++++++++++++++++++
lib/crypto/tests/sha224-testvecs.h | 470 ++++++++++++++++++
lib/crypto/tests/sha224_kunit.c | 48 ++
lib/crypto/tests/sha256-testvecs.h | 470 ++++++++++++++++++
lib/crypto/tests/sha256_kunit.c | 48 ++
lib/crypto/tests/sha384-testvecs.h | 566 ++++++++++++++++++++++
lib/crypto/tests/sha384_kunit.c | 48 ++
lib/crypto/tests/sha512-testvecs.h | 662 ++++++++++++++++++++++++++
lib/crypto/tests/sha512_kunit.c | 48 ++
scripts/crypto/gen-hash-testvecs.py | 83 ++++
14 files changed, 2990 insertions(+)
create mode 100644 lib/crypto/tests/Kconfig
create mode 100644 lib/crypto/tests/Makefile
create mode 100644 lib/crypto/tests/hash-test-template.h
create mode 100644 lib/crypto/tests/sha224-testvecs.h
create mode 100644 lib/crypto/tests/sha224_kunit.c
create mode 100644 lib/crypto/tests/sha256-testvecs.h
create mode 100644 lib/crypto/tests/sha256_kunit.c
create mode 100644 lib/crypto/tests/sha384-testvecs.h
create mode 100644 lib/crypto/tests/sha384_kunit.c
create mode 100644 lib/crypto/tests/sha512-testvecs.h
create mode 100644 lib/crypto/tests/sha512_kunit.c
create mode 100755 scripts/crypto/gen-hash-testvecs.py
--
2.50.0
next reply other threads:[~2025-06-30 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 16:20 Eric Biggers [this message]
2025-06-30 16:20 ` [PATCH v3 1/2] lib/crypto: sha512: Add KUnit tests for SHA-384 and SHA-512 Eric Biggers
2025-06-30 16:20 ` [PATCH v3 2/2] lib/crypto: sha256: Add KUnit tests for SHA-224 and SHA-256 Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250630162014.6463-1-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.