linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] KUnit tests for SHA-2 library functions
@ 2025-06-30 16:20 Eric Biggers
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2025-06-30 16:20 UTC (permalink / raw)
  To: linux-crypto
  Cc: linux-kernel, Ard Biesheuvel, Jason A . Donenfeld, Eric Biggers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-30 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30 16:20 [PATCH v3 0/2] KUnit tests for SHA-2 library functions Eric Biggers
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).