From c90fb0d8fb7a84bbcc8d6832de6a554405591850 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 18 Dec 2020 14:54:53 +0900 Subject: Reorganize self-tests for HMAC. * cipher/Makefile.am: Prepare merge of hmac-test.c into mac-hmac.c. * cipher/hmac-tests.c: Ifdef-out run_selftests and _gcry_hmac_selftest. * cipher/mac-internal.h: Include cipher-proto.h for selftest. (gcry_mac_spec_ops): Add selftest field. * cipher/mac-hmac.c: Include hmac-tests.c for migration. (hmac_selftest) New. (hmac_ops): Add hmac_selftest. * cipher/gost28147.c, cipher/mac-cmac.c: Add new field for selftest. * cipher/mac-gmac.c, cipher/mac-poly1305.c: Likewise.. * cipher/mac.c (_gcry_mac_selftest): New. * src/fips.c (run_mac_selftests): Rename from run_hmac_selftests. Use GCRY_MAC_HMAC_*, and call _gcry_mac_selftest. (_gcry_fips_run_selftests): Use run_mac_selftests. Signed-off-by: NIIBE Yutaka --- src/fips.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/fips.c b/src/fips.c index 1ac7f477..94ffbd20 100644 --- a/src/fips.c +++ b/src/fips.c @@ -493,21 +493,21 @@ run_digest_selftests (int extended) } -/* Run self-tests for all HMAC algorithms. Return 0 on success. */ +/* Run self-tests for MAC algorithms. Return 0 on success. */ static int -run_hmac_selftests (int extended) +run_mac_selftests (int extended) { static int algos[] = { - GCRY_MD_SHA1, - GCRY_MD_SHA224, - GCRY_MD_SHA256, - GCRY_MD_SHA384, - GCRY_MD_SHA512, - GCRY_MD_SHA3_224, - GCRY_MD_SHA3_256, - GCRY_MD_SHA3_384, - GCRY_MD_SHA3_512, + GCRY_MAC_HMAC_SHA1, + GCRY_MAC_HMAC_SHA224, + GCRY_MAC_HMAC_SHA256, + GCRY_MAC_HMAC_SHA384, + GCRY_MAC_HMAC_SHA512, + GCRY_MAC_HMAC_SHA3_224, + GCRY_MAC_HMAC_SHA3_256, + GCRY_MAC_HMAC_SHA3_384, + GCRY_MAC_HMAC_SHA3_512, 0 }; int idx; @@ -516,8 +516,8 @@ run_hmac_selftests (int extended) for (idx=0; algos[idx]; idx++) { - err = _gcry_hmac_selftest (algos[idx], extended, reporter); - reporter ("hmac", algos[idx], NULL, + err = _gcry_mac_selftest (algos[idx], extended, reporter); + reporter ("mac", algos[idx], NULL, err? gpg_strerror (err):NULL); if (err) anyerr = 1; @@ -678,7 +678,7 @@ _gcry_fips_run_selftests (int extended) if (run_digest_selftests (extended)) goto leave; - if (run_hmac_selftests (extended)) + if (run_mac_selftests (extended)) goto leave; /* Run random tests before the pubkey tests because the latter -- cgit v1.2.1