diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2019-04-05 20:10:32 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2019-04-05 20:10:32 +0300 |
commit | a3683b6f623189a4b65bb584bb9e65e3ad7b3139 (patch) | |
tree | 78b33be41807cd928b2115b8a88da219e9d00768 /cipher/mac.c | |
parent | c6055aaccac86e1ca8a9d35c980d7abbacf2a9ff (diff) | |
download | libgcrypt-a3683b6f623189a4b65bb584bb9e65e3ad7b3139.tar.gz |
Add SHA512/224 and SHA512/256 algorithms
* cipher/mac-hmac.c (map_mac_algo_to_md): Add mapping for SHA512/224
and SHA512/256.
(_gcry_mac_type_spec_hmac_sha512_256)
(_gcry_mac_type_spec_hmac_sha512_224): New.
* cipher/mac-internal.h (_gcry_mac_type_spec_hmac_sha512_256)
(_gcry_mac_type_spec_hmac_sha512_224): New.
* cipher/mac.c (mac_list, mac_list_algo101): Add SHA512/224 and
SHA512/256.
* cipher/md.c (digest_list, digest_list_algo301)
(prepare_macpads): Ditto.
* cipher/sha512.c (run_selftests): Ditto.
(sha512_init_common): Move common initialization here.
(sha512_init, sha384_init): Use common initialization function.
(sha512_224_init, sha512_256_init, _gcry_sha512_224_hash_buffer)
(_gcry_sha512_224_hash_buffers, _gcry_sha512_256_hash_buffer)
(_gcry_sha512_256_hash_buffers, selftests_sha512_224)
(selftests_sha512_256, sha512_224_asn, oid_spec_sha512_224)
(_gcry_digest_spec_sha512_224, sha512_256_asn, oid_spec_sha512_256)
(_gcry_digest_spec_sha512_256): New.
* doc/gcrypt.texi: Add SHA512/224 and SHA512/256; Add missing
HMAC-BLAKE2s and HMAC-BLAKE2b.
* src/cipher.h (_gcry_digest_spec_sha512_224)
(_gcry_digest_spec_sha512_256): New.
* src/gcrypt.h.in (GCRY_MD_SHA512_256, GCRY_MD_SHA512_224): New.
(GCRY_MAC_HMAC_SHA512_256, GCRY_MAC_HMAC_SHA512_224): New.
* tests/basic.c (check_digests): Add SHA512/224 and SHA512/256
test vectors.
--
This change adds truncated SHA512/224 and SHA512/256 algorithms
specified in FIPS 180-4.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/mac.c')
-rw-r--r-- | cipher/mac.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cipher/mac.c b/cipher/mac.c index 1b79bf31..0bbac3e4 100644 --- a/cipher/mac.c +++ b/cipher/mac.c @@ -40,6 +40,8 @@ static gcry_mac_spec_t * const mac_list[] = { #if USE_SHA512 &_gcry_mac_type_spec_hmac_sha512, &_gcry_mac_type_spec_hmac_sha384, + &_gcry_mac_type_spec_hmac_sha512_256, + &_gcry_mac_type_spec_hmac_sha512_224, #endif #if USE_SHA3 &_gcry_mac_type_spec_hmac_sha3_224, @@ -230,9 +232,16 @@ static gcry_mac_spec_t * const mac_list_algo101[] = NULL, #endif #if USE_SM3 - &_gcry_mac_type_spec_hmac_sm3 + &_gcry_mac_type_spec_hmac_sm3, #else - NULL + NULL, +#endif +#if USE_SHA512 + &_gcry_mac_type_spec_hmac_sha512_256, + &_gcry_mac_type_spec_hmac_sha512_224, +#else + NULL, + NULL, #endif }; |