diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2021-09-09 11:57:15 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2021-09-09 11:57:15 +0900 |
commit | 33d98eeecadd4226adb0275e29d58001e8e17366 (patch) | |
tree | 1bb91e4fc51723b8a2b5821eaa028e5c9ee4cc69 | |
parent | a11095b2385669584faa9a4a9967176811ddf745 (diff) | |
download | libgcrypt-33d98eeecadd4226adb0275e29d58001e8e17366.tar.gz |
cipher: Support sha512-224 and sha512-256.
* cipher/pubkey-util.c (get_hash_algo): Add.
* cipher/sha512.c (sha512_256_asn, sha512_224_asn): Fill correct values.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r-- | cipher/pubkey-util.c | 2 | ||||
-rw-r--r-- | cipher/sha512.c | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/cipher/pubkey-util.c b/cipher/pubkey-util.c index faf5ad0e..d377932b 100644 --- a/cipher/pubkey-util.c +++ b/cipher/pubkey-util.c @@ -234,6 +234,8 @@ get_hash_algo (const char *s, size_t n) { "sm3", GCRY_MD_SM3 }, { "shake128", GCRY_MD_SHAKE128 }, { "shake256", GCRY_MD_SHAKE256 }, + { "sha512-224", GCRY_MD_SHA512_224 }, + { "sha512-256", GCRY_MD_SHA512_256 }, { NULL, 0 } }; int algo; diff --git a/cipher/sha512.c b/cipher/sha512.c index 6859cf52..45291567 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -1235,7 +1235,12 @@ gcry_md_spec_t _gcry_digest_spec_sha384 = run_selftests }; -static byte sha512_256_asn[] = { 0x30 }; +static byte sha512_256_asn[] = + { + 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, + 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x06, 0x05, + 0x00, 0x04, 0x20 + }; static gcry_md_oid_spec_t oid_spec_sha512_256[] = { @@ -1254,7 +1259,12 @@ gcry_md_spec_t _gcry_digest_spec_sha512_256 = run_selftests }; -static byte sha512_224_asn[] = { 0x30 }; +static byte sha512_224_asn[] = + { + 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, + 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x05, 0x05, + 0x00, 0x04, 0x1c + }; static gcry_md_oid_spec_t oid_spec_sha512_224[] = { |