lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250630162014.6463-1-ebiggers@kernel.org>
Date: Mon, 30 Jun 2025 09:20:12 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: linux-crypto@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
	Ard Biesheuvel <ardb@...nel.org>,
	"Jason A . Donenfeld" <Jason@...c4.com>,
	Eric Biggers <ebiggers@...nel.org>
Subject: [PATCH v3 0/2] KUnit tests for SHA-2 library functions

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ