<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/include/crypto/sha2.h, branch v6.17</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-07-14T15:20:37Z</updated>
<entry>
<title>lib/crypto: sha2: Add hmac_sha*_init_usingrawkey()</title>
<updated>2025-07-14T15:20:37Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-07-11T21:58:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7941ad696506917fa6228f44be2df0c2f0909a62'/>
<id>urn:sha1:7941ad696506917fa6228f44be2df0c2f0909a62</id>
<content type='text'>
While the HMAC library functions support both incremental and one-shot
computation and both prepared and raw keys, the combination of raw key
+ incremental was missing.  It turns out that several potential users of
the HMAC library functions (tpm2-sessions.c, smb2transport.c,
trusted_tpm1.c) want exactly that.

Therefore, add the missing functions hmac_sha*_init_usingrawkey().

Implement them in an optimized way that directly initializes the HMAC
context without a separate key preparation step.

Reimplement the one-shot raw key functions hmac_sha*_usingrawkey() on
top of the new functions, which makes them a bit more efficient.

Reviewed-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250711215844.41715-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha256: Document the SHA-224 and SHA-256 API</title>
<updated>2025-07-04T17:23:11Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:06:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b34c9803aabd85189ffacc0d3cdb9ce4515c2b4d'/>
<id>urn:sha1:b34c9803aabd85189ffacc0d3cdb9ce4515c2b4d</id>
<content type='text'>
Add kerneldoc comments, consistent with the kerneldoc comments of the
SHA-384 and SHA-512 API.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160645.3198-15-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha256: Add HMAC-SHA224 and HMAC-SHA256 support</title>
<updated>2025-07-04T17:23:11Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:06:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=077833cd600908359391bd22d5350c9106ea238c'/>
<id>urn:sha1:077833cd600908359391bd22d5350c9106ea238c</id>
<content type='text'>
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 &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160645.3198-9-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha256: Make library API use strongly-typed contexts</title>
<updated>2025-07-04T17:18:53Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:06:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b86ced882b8e667758afddffd8d6354197842110'/>
<id>urn:sha1:b86ced882b8e667758afddffd8d6354197842110</id>
<content type='text'>
Currently the SHA-224 and SHA-256 library functions can be mixed
arbitrarily, even in ways that are incorrect, for example using
sha224_init() and sha256_final().  This is because they operate on the
same structure, sha256_state.

Introduce stronger typing, as I did for SHA-384 and SHA-512.

Also as I did for SHA-384 and SHA-512, use the names *_ctx instead of
*_state.  The *_ctx names have the following small benefits:

- They're shorter.
- They avoid an ambiguity with the compression function state.
- They're consistent with the well-known OpenSSL API.
- Users usually name the variable 'sctx' anyway, which suggests that
  *_ctx would be the more natural name for the actual struct.

Therefore: update the SHA-224 and SHA-256 APIs, implementation, and
calling code accordingly.

In the new structs, also strongly-type the compression function state.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160645.3198-7-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha256: Add sha224() and sha224_update()</title>
<updated>2025-07-04T17:18:53Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:06:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6fa4b292204b15e0e269a9fd33bc99b5e36b6883'/>
<id>urn:sha1:6fa4b292204b15e0e269a9fd33bc99b5e36b6883</id>
<content type='text'>
Add a one-shot SHA-224 computation function sha224(), for consistency
with sha256(), sha384(), and sha512() which all already exist.

Similarly, add sha224_update().  While for now it's identical to
sha256_update(), omitting it makes the API harder to use since users
have to "know" which functions are the same between SHA-224 and SHA-256.
Also, this is a prerequisite for using different context types for each.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160645.3198-6-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha256: Reorder some code</title>
<updated>2025-07-04T17:18:52Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:06:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3135d5be7c27841526d98150c245304ab312e9f4'/>
<id>urn:sha1:3135d5be7c27841526d98150c245304ab312e9f4</id>
<content type='text'>
First, move the declarations of sha224_init/update/final to be just
above the corresponding SHA-256 code, matching the order that I used for
SHA-384 and SHA-512.  In sha2.h, the end result is that SHA-224,
SHA-256, SHA-384, and SHA-512 are all in the logical order.

Second, move sha224_block_init() and sha256_block_init() to be just
below crypto_sha256_state.  In later changes, these functions as well as
struct crypto_sha256_state will no longer be used by the library
functions.  They'll remain just for some legacy offload drivers.  This
gets them into a logical place in the file for that.

No code changes other than reordering.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160645.3198-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha512: Add HMAC-SHA384 and HMAC-SHA512 support</title>
<updated>2025-06-30T16:26:19Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:03:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=23e8b4371dbd5907d633262f36903144a378a114'/>
<id>urn:sha1:23e8b4371dbd5907d633262f36903144a378a114</id>
<content type='text'>
Since HMAC support is commonly needed and is fairly simple, include it
as a first-class citizen of the SHA-512 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.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160320.2888-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>lib/crypto: sha512: Add support for SHA-384 and SHA-512</title>
<updated>2025-06-30T16:26:19Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@kernel.org</email>
</author>
<published>2025-06-30T16:03:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b693c703accb08cbd52f0b94d810d6abbca3bfb9'/>
<id>urn:sha1:b693c703accb08cbd52f0b94d810d6abbca3bfb9</id>
<content type='text'>
Add basic support for SHA-384 and SHA-512 to lib/crypto/.

Various in-kernel users will be able to use this instead of the
old-school crypto API, which is harder to use and has more overhead.

The basic support added by this commit consists of the API and its
documentation, backed by a C implementation of the algorithms.
sha512_block_generic() is derived from crypto/sha512_generic.c.

Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Link: https://lore.kernel.org/r/20250630160320.2888-3-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@kernel.org&gt;
</content>
</entry>
<entry>
<title>crypto: sha256 - Use the partial block API for generic</title>
<updated>2025-05-05T10:20:45Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2025-05-02T05:30:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ff8f037d394f0900597ba527388a6eb95cd02695'/>
<id>urn:sha1:ff8f037d394f0900597ba527388a6eb95cd02695</id>
<content type='text'>
The shash interface already handles partial blocks, use it for
sha224-generic and sha256-generic instead of going through the
lib/sha256 interface.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: lib/sha256 - improve function prototypes</title>
<updated>2025-05-05T10:20:44Z</updated>
<author>
<name>Eric Biggers</name>
<email>ebiggers@google.com</email>
</author>
<published>2025-04-28T17:00:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7350fef56b7629a539897c332d7324629580671d'/>
<id>urn:sha1:7350fef56b7629a539897c332d7324629580671d</id>
<content type='text'>
Follow best practices by changing the length parameters to size_t and
explicitly specifying the length of the output digest arrays.

Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
</feed>
