lib/crypto: sha256: Add HMAC-SHA224 and HMAC-SHA256 support
authorEric Biggers <ebiggers@kernel.org>
Mon, 30 Jun 2025 16:06:39 +0000 (09:06 -0700)
committerEric Biggers <ebiggers@kernel.org>
Fri, 4 Jul 2025 17:23:11 +0000 (10:23 -0700)
commit077833cd600908359391bd22d5350c9106ea238c
tree6920c7ea3d8c1ddec7818b5969c993f276d93afb
parent4c855d5069ee2edbcf62fafc7f1a5d4cfea1bce1
lib/crypto: sha256: Add HMAC-SHA224 and HMAC-SHA256 support

Since HMAC support is commonly needed and is fairly simple, include it
as a first-class citizen of the SHA-256 library.

The API supports both incremental and one-shot computation, and either
preparing the key ahead of time or just using a raw key.  The
implementation is much more streamlined than crypto/hmac.c.

I've kept it consistent with the HMAC-SHA384 and HMAC-SHA512 code as
much as possible.

Testing of these functions will be via sha224_kunit and sha256_kunit,
added by a later commit.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250630160645.3198-9-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
include/crypto/sha2.h
lib/crypto/sha256.c