lib/crypto: sha256: Add sha224() and sha224_update()
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 <ardb@kernel.org> Link: https://lore.kernel.org/r/20250630160645.3198-6-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
@@ -70,6 +70,16 @@ void sha256_final(struct sha256_state *sctx, u8 out[SHA256_DIGEST_SIZE])
|
||||
}
|
||||
EXPORT_SYMBOL(sha256_final);
|
||||
|
||||
void sha224(const u8 *data, size_t len, u8 out[SHA224_DIGEST_SIZE])
|
||||
{
|
||||
struct sha256_state sctx;
|
||||
|
||||
sha224_init(&sctx);
|
||||
sha224_update(&sctx, data, len);
|
||||
sha224_final(&sctx, out);
|
||||
}
|
||||
EXPORT_SYMBOL(sha224);
|
||||
|
||||
void sha256(const u8 *data, size_t len, u8 out[SHA256_DIGEST_SIZE])
|
||||
{
|
||||
struct sha256_state sctx;
|
||||
|
||||
Reference in New Issue
Block a user