diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-04-12 14:50:18 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-04-12 17:01:10 +0100 |
commit | 4dbc44348ca9011465c3bce38757173c059309ec (patch) | |
tree | c5f0790a71bc74fe3083a18e164416b0ecf3ed4b /src/include/ipxe/sha256.h | |
parent | a9da1291227735fdae475e21b02b2a5fa29dd956 (diff) | |
download | ipxe-4dbc44348ca9011465c3bce38757173c059309ec.tar.gz |
[crypto] Add SHA-224 algorithm
SHA-224 is almost identical to SHA-256, with differing initial hash
values and a truncated output length.
This implementation has been verified using the NIST SHA-224 test
vectors.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/sha256.h')
-rw-r--r-- | src/include/ipxe/sha256.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/include/ipxe/sha256.h b/src/include/ipxe/sha256.h index 1e4dceceb..811279a64 100644 --- a/src/include/ipxe/sha256.h +++ b/src/include/ipxe/sha256.h @@ -58,6 +58,8 @@ union sha256_digest_data_dwords { struct sha256_context { /** Amount of accumulated data */ size_t len; + /** Digest size */ + size_t digestsize; /** Digest and accumulated data */ union sha256_digest_data_dwords ddd; } __attribute__ (( packed )); @@ -68,6 +70,16 @@ struct sha256_context { /** SHA-256 digest size */ #define SHA256_DIGEST_SIZE sizeof ( struct sha256_digest ) +/** SHA-224 digest size */ +#define SHA224_DIGEST_SIZE ( SHA256_DIGEST_SIZE * 224 / 256 ) + +extern void sha256_family_init ( struct sha256_context *context, + const struct sha256_digest *init, + size_t digestsize ); +extern void sha256_update ( void *ctx, const void *data, size_t len ); +extern void sha256_final ( void *ctx, void *out ); + extern struct digest_algorithm sha256_algorithm; +extern struct digest_algorithm sha224_algorithm; #endif /* _IPXE_SHA256_H */ |