[crypto] Add SHA-512/224 algorithm

SHA-512/224 is almost identical to SHA-512, with differing initial
hash values and a truncated output length.

This implementation has been verified using the NIST SHA-512/224 test
vectors.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2015-04-12 16:57:25 +01:00
parent e5e91ab471
commit ea3d5875cd
4 changed files with 122 additions and 0 deletions

View File

@@ -181,6 +181,13 @@ struct asn1_builder_header {
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 4 )
/** ASN.1 OID for id-sha512-224 (2.16.840.1.101.3.4.2.5) */
#define ASN1_OID_SHA512_224 \
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \
ASN1_OID_SINGLE ( 1 ), ASN1_OID_SINGLE ( 101 ), \
ASN1_OID_SINGLE ( 3 ), ASN1_OID_SINGLE ( 4 ), \
ASN1_OID_SINGLE ( 2 ), ASN1_OID_SINGLE ( 5 )
/** ASN.1 OID for id-sha512-256 (2.16.840.1.101.3.4.2.6) */
#define ASN1_OID_SHA512_256 \
ASN1_OID_INITIAL ( 2, 16 ), ASN1_OID_DOUBLE ( 840 ), \

View File

@@ -81,6 +81,9 @@ struct sha512_context {
/** SHA-512/256 digest size */
#define SHA512_256_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 256 / 512 )
/** SHA-512/224 digest size */
#define SHA512_224_DIGEST_SIZE ( SHA512_DIGEST_SIZE * 224 / 512 )
extern void sha512_family_init ( struct sha512_context *context,
const struct sha512_digest *init,
size_t digestsize );
@@ -90,5 +93,6 @@ extern void sha512_final ( void *ctx, void *out );
extern struct digest_algorithm sha512_algorithm;
extern struct digest_algorithm sha384_algorithm;
extern struct digest_algorithm sha512_256_algorithm;
extern struct digest_algorithm sha512_224_algorithm;
#endif /* IPXE_SHA512_H */