diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2022-01-19 11:41:40 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2022-01-19 11:41:40 +0900 |
commit | 76aad97dd312e83f2f9b8d086553f2b72ab6546f (patch) | |
tree | 40d41c810f9cff3ebbdae697fceaec5ee2d49928 /cipher/mac-hmac.c | |
parent | 6f225308d3e59f8749403ad743d8e6c591142f8f (diff) | |
download | libgcrypt-76aad97dd312e83f2f9b8d086553f2b72ab6546f.tar.gz |
fips: Reject shorter key for HMAC in FIPS mode.
* cipher/md.c (prepare_macpads): Reject < 112-bit key.
* cipher/kdf.c (selftest_pbkdf2): Remove selftest cases with shorter
key.
* cipher/mac-hmac.c (selftests_sha224, selftests_sha256): Likewise.
(selftests_sha384, selftests_sha512, selftests_sha3): Likewise.
* tests/basic.c (check_one_hmac) Handle an error when shorter key
is rejected.
(check_one_mac): Likewise.
* tests/t-kdf.c (check_pbkdf2, check_scrypt): Likewise.
--
GnuPG-bug-id: 5512
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'cipher/mac-hmac.c')
-rw-r--r-- | cipher/mac-hmac.c | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/cipher/mac-hmac.c b/cipher/mac-hmac.c index 108a4408..3f50f1c5 100644 --- a/cipher/mac-hmac.c +++ b/cipher/mac-hmac.c @@ -361,14 +361,6 @@ selftests_sha224 (int extended, selftest_report_func_t report) const char expect[28]; } tv[] = { - { "data-28 key-4", - "what do ya want for nothing?", - "Jefe", - { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf, - 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f, - 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00, - 0x8f, 0xd0, 0x5e, 0x44 } }, - { "data-9 key-20", "Hi There", "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -475,14 +467,6 @@ selftests_sha256 (int extended, selftest_report_func_t report) const char expect[32]; } tv[] = { - { "data-28 key-4", - "what do ya want for nothing?", - "Jefe", - { 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, - 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, - 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, - 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43 } }, - { "data-9 key-20", "Hi There", "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -589,16 +573,6 @@ selftests_sha384 (int extended, selftest_report_func_t report) const char expect[48]; } tv[] = { - { "data-28 key-4", - "what do ya want for nothing?", - "Jefe", - { 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31, - 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b, - 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47, - 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e, - 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7, - 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49 } }, - { "data-9 key-20", "Hi There", "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -715,18 +689,6 @@ selftests_sha512 (int extended, selftest_report_func_t report) const char expect[64]; } tv[] = { - { "data-28 key-4", - "what do ya want for nothing?", - "Jefe", - { 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2, - 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3, - 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6, - 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54, - 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a, - 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd, - 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b, - 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37 } }, - { "data-9 key-20", "Hi There", "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" @@ -889,35 +851,6 @@ selftests_sha3 (int hashalgo, int extended, selftest_report_func_t report) 0x37, 0xc0, 0xa0, 0xb8, 0x64, 0x07, 0x68, 0x9e } }, - { "data-28 key-4", /* Test 2 */ - /* Test with a key shorter than the length of the HMAC output. */ - "what do ya want for nothing?", - "Jefe", - - { 0x7f, 0xdb, 0x8d, 0xd8, 0x8b, 0xd2, 0xf6, 0x0d, - 0x1b, 0x79, 0x86, 0x34, 0xad, 0x38, 0x68, 0x11, - 0xc2, 0xcf, 0xc8, 0x5b, 0xfa, 0xf5, 0xd5, 0x2b, - 0xba, 0xce, 0x5e, 0x66 }, - { 0xc7, 0xd4, 0x07, 0x2e, 0x78, 0x88, 0x77, 0xae, - 0x35, 0x96, 0xbb, 0xb0, 0xda, 0x73, 0xb8, 0x87, - 0xc9, 0x17, 0x1f, 0x93, 0x09, 0x5b, 0x29, 0x4a, - 0xe8, 0x57, 0xfb, 0xe2, 0x64, 0x5e, 0x1b, 0xa5 }, - { 0xf1, 0x10, 0x1f, 0x8c, 0xbf, 0x97, 0x66, 0xfd, - 0x67, 0x64, 0xd2, 0xed, 0x61, 0x90, 0x3f, 0x21, - 0xca, 0x9b, 0x18, 0xf5, 0x7c, 0xf3, 0xe1, 0xa2, - 0x3c, 0xa1, 0x35, 0x08, 0xa9, 0x32, 0x43, 0xce, - 0x48, 0xc0, 0x45, 0xdc, 0x00, 0x7f, 0x26, 0xa2, - 0x1b, 0x3f, 0x5e, 0x0e, 0x9d, 0xf4, 0xc2, 0x0a }, - { 0x5a, 0x4b, 0xfe, 0xab, 0x61, 0x66, 0x42, 0x7c, - 0x7a, 0x36, 0x47, 0xb7, 0x47, 0x29, 0x2b, 0x83, - 0x84, 0x53, 0x7c, 0xdb, 0x89, 0xaf, 0xb3, 0xbf, - 0x56, 0x65, 0xe4, 0xc5, 0xe7, 0x09, 0x35, 0x0b, - 0x28, 0x7b, 0xae, 0xc9, 0x21, 0xfd, 0x7c, 0xa0, - 0xee, 0x7a, 0x0c, 0x31, 0xd0, 0x22, 0xa9, 0x5e, - 0x1f, 0xc9, 0x2b, 0xa9, 0xd7, 0x7d, 0xf8, 0x83, - 0x96, 0x02, 0x75, 0xbe, 0xb4, 0xe6, 0x20, 0x24 } - }, - { "data-50 key-20", /* Test 3 */ /* Test with a combined length of key and data that is larger * than 64 bytes (= block-size of SHA-224 and SHA-256). */ |