|
|
6f4a73 |
diff -up libgcrypt-1.8.3/cipher/cipher-cmac.c.cmac-selftest libgcrypt-1.8.3/cipher/cipher-cmac.c
|
|
|
6f4a73 |
--- libgcrypt-1.8.3/cipher/cipher-cmac.c.cmac-selftest 2017-11-23 19:16:58.000000000 +0100
|
|
|
6f4a73 |
+++ libgcrypt-1.8.3/cipher/cipher-cmac.c 2019-05-31 17:33:35.594407152 +0200
|
|
|
6f4a73 |
@@ -251,3 +251,246 @@ _gcry_cipher_cmac_set_subkeys (gcry_ciph
|
|
|
6f4a73 |
|
|
|
6f4a73 |
return GPG_ERR_NO_ERROR;
|
|
|
6f4a73 |
}
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+/* CMAC selftests.
|
|
|
6f4a73 |
+ * Copyright (C) 2008 Free Software Foundation, Inc.
|
|
|
6f4a73 |
+ * Copyright (C) 2019 Red Hat, Inc.
|
|
|
6f4a73 |
+ */
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+/* Check one MAC with MAC ALGO using the regular MAC
|
|
|
6f4a73 |
+ * API. (DATA,DATALEN) is the data to be MACed, (KEY,KEYLEN) the key
|
|
|
6f4a73 |
+ * and (EXPECT,EXPECTLEN) the expected result. If TRUNC is set, the
|
|
|
6f4a73 |
+ * EXPECTLEN may be less than the digest length. Returns NULL on
|
|
|
6f4a73 |
+ * success or a string describing the failure. */
|
|
|
6f4a73 |
+static const char *
|
|
|
6f4a73 |
+check_one (int algo,
|
|
|
6f4a73 |
+ const void *data, size_t datalen,
|
|
|
6f4a73 |
+ const void *key, size_t keylen,
|
|
|
6f4a73 |
+ const void *expect, size_t expectlen)
|
|
|
6f4a73 |
+{
|
|
|
6f4a73 |
+ gcry_mac_hd_t hd;
|
|
|
6f4a73 |
+ unsigned char mac[512]; /* hardcoded to avoid allocation */
|
|
|
6f4a73 |
+ size_t macoutlen = expectlen;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+/* printf ("MAC algo %d\n", algo); */
|
|
|
6f4a73 |
+ if (_gcry_mac_get_algo_maclen (algo) != expectlen ||
|
|
|
6f4a73 |
+ expectlen > sizeof (mac))
|
|
|
6f4a73 |
+ return "invalid tests data";
|
|
|
6f4a73 |
+ if (_gcry_mac_open (&hd, algo, 0, NULL))
|
|
|
6f4a73 |
+ return "gcry_mac_open failed";
|
|
|
6f4a73 |
+ if (_gcry_mac_setkey (hd, key, keylen))
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ _gcry_mac_close (hd);
|
|
|
6f4a73 |
+ return "gcry_md_setkey failed";
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ if (_gcry_mac_write (hd, data, datalen))
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ _gcry_mac_close (hd);
|
|
|
6f4a73 |
+ return "gcry_mac_write failed";
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ if (_gcry_mac_read (hd, mac, &macoutlen))
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ _gcry_mac_close (hd);
|
|
|
6f4a73 |
+ return "gcry_mac_read failed";
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ _gcry_mac_close (hd);
|
|
|
6f4a73 |
+ if (macoutlen != expectlen || memcmp (mac, expect, expectlen))
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+/* int i; */
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+/* fputs (" {", stdout); */
|
|
|
6f4a73 |
+/* for (i=0; i < expectlen-1; i++) */
|
|
|
6f4a73 |
+/* { */
|
|
|
6f4a73 |
+/* if (i && !(i % 8)) */
|
|
|
6f4a73 |
+/* fputs ("\n ", stdout); */
|
|
|
6f4a73 |
+/* printf (" 0x%02x,", mac[i]); */
|
|
|
6f4a73 |
+/* } */
|
|
|
6f4a73 |
+/* printf (" 0x%02x } },\n", mac[i]); */
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ return "does not match";
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ return NULL;
|
|
|
6f4a73 |
+}
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+static gpg_err_code_t
|
|
|
6f4a73 |
+selftests_cmac_tdes (int extended, selftest_report_func_t report)
|
|
|
6f4a73 |
+{
|
|
|
6f4a73 |
+ const char *what;
|
|
|
6f4a73 |
+ const char *errtxt;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Basic TDES";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
|
|
6f4a73 |
+ "\xae\x2d\x8a\x57", 20,
|
|
|
6f4a73 |
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
|
|
6f4a73 |
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
|
|
6f4a73 |
+ "\x74\x3d\xdb\xe0\xce\x2d\xc2\xed", 8);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ if (extended)
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ what = "Extended TDES #1";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
|
|
6f4a73 |
+ "", 0,
|
|
|
6f4a73 |
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
|
|
6f4a73 |
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
|
|
6f4a73 |
+ "\xb7\xa6\x88\xe1\x22\xff\xaf\x95", 8);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Extended TDES #2";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96", 8,
|
|
|
6f4a73 |
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
|
|
6f4a73 |
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
|
|
6f4a73 |
+ "\x8e\x8f\x29\x31\x36\x28\x37\x97", 8);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Extended TDES #3";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_3DES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
|
|
6f4a73 |
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51", 32,
|
|
|
6f4a73 |
+ "\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
|
|
|
6f4a73 |
+ "\xbc\x31\x3d\x4a\x37\x1c\xa8\xb5", 24,
|
|
|
6f4a73 |
+ "\x33\xe6\xb1\x09\x24\x00\xea\xe5", 8);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ return 0; /* Succeeded. */
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ failed:
|
|
|
6f4a73 |
+ if (report)
|
|
|
6f4a73 |
+ report ("cmac", GCRY_MAC_CMAC_3DES, what, errtxt);
|
|
|
6f4a73 |
+ return GPG_ERR_SELFTEST_FAILED;
|
|
|
6f4a73 |
+}
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+static gpg_err_code_t
|
|
|
6f4a73 |
+selftests_cmac_aes (int extended, selftest_report_func_t report)
|
|
|
6f4a73 |
+{
|
|
|
6f4a73 |
+ const char *what;
|
|
|
6f4a73 |
+ const char *errtxt;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Basic AES128";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
|
|
6f4a73 |
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
|
|
6f4a73 |
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", 40,
|
|
|
6f4a73 |
+ "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", 16,
|
|
|
6f4a73 |
+ "\xdf\xa6\x67\x47\xde\x9a\xe6\x30\x30\xca\x32\x61\x14\x97\xc8\x27", 16);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Basic AES192";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
|
|
6f4a73 |
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
|
|
6f4a73 |
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", 40,
|
|
|
6f4a73 |
+ "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
|
|
|
6f4a73 |
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", 24,
|
|
|
6f4a73 |
+ "\x8a\x1d\xe5\xbe\x2e\xb3\x1a\xad\x08\x9a\x82\xe6\xee\x90\x8b\x0e", 16);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Basic AES256";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
|
|
6f4a73 |
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
|
|
6f4a73 |
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11", 40,
|
|
|
6f4a73 |
+ "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81"
|
|
|
6f4a73 |
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", 32,
|
|
|
6f4a73 |
+ "\xaa\xf3\xd8\xf1\xde\x56\x40\xc2\x32\xf5\xb1\x69\xb9\xc9\x11\xe6", 16);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+ if (extended)
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ what = "Extended AES #1";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
|
|
6f4a73 |
+ "", 0,
|
|
|
6f4a73 |
+ "\x2b\x7e\x15\x16\x28\xae\xd2\xa6\xab\xf7\x15\x88\x09\xcf\x4f\x3c", 16,
|
|
|
6f4a73 |
+ "\xbb\x1d\x69\x29\xe9\x59\x37\x28\x7f\xa3\x7d\x12\x9b\x75\x67\x46", 16);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Extended AES #2";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a", 16,
|
|
|
6f4a73 |
+ "\x8e\x73\xb0\xf7\xda\x0e\x64\x52\xc8\x10\xf3\x2b\x80\x90\x79\xe5"
|
|
|
6f4a73 |
+ "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", 24,
|
|
|
6f4a73 |
+ "\x9e\x99\xa7\xbf\x31\xe7\x10\x90\x06\x62\xf6\x5e\x61\x7c\x51\x84", 16);
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ what = "Extended AES #3";
|
|
|
6f4a73 |
+ errtxt = check_one (GCRY_MAC_CMAC_AES,
|
|
|
6f4a73 |
+ "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96\xe9\x3d\x7e\x11\x73\x93\x17\x2a"
|
|
|
6f4a73 |
+ "\xae\x2d\x8a\x57\x1e\x03\xac\x9c\x9e\xb7\x6f\xac\x45\xaf\x8e\x51"
|
|
|
6f4a73 |
+ "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11\xe5\xfb\xc1\x19\x1a\x0a\x52\xef"
|
|
|
6f4a73 |
+ "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17\xad\x2b\x41\x7b\xe6\x6c\x37\x10", 64,
|
|
|
6f4a73 |
+ "\x60\x3d\xeb\x10\x15\xca\x71\xbe\x2b\x73\xae\xf0\x85\x7d\x77\x81"
|
|
|
6f4a73 |
+ "\x1f\x35\x2c\x07\x3b\x61\x08\xd7\x2d\x98\x10\xa3\x09\x14\xdf\xf4", 32,
|
|
|
6f4a73 |
+ "\xe1\x99\x21\x90\x54\x9f\x6e\xd5\x69\x6a\x2c\x05\x6c\x31\x54\x10", 16 );
|
|
|
6f4a73 |
+ if (errtxt)
|
|
|
6f4a73 |
+ goto failed;
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ return 0; /* Succeeded. */
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ failed:
|
|
|
6f4a73 |
+ if (report)
|
|
|
6f4a73 |
+ report ("cmac", GCRY_MAC_CMAC_AES, what, errtxt);
|
|
|
6f4a73 |
+ return GPG_ERR_SELFTEST_FAILED;
|
|
|
6f4a73 |
+}
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+/* Run a full self-test for ALGO and return 0 on success. */
|
|
|
6f4a73 |
+static gpg_err_code_t
|
|
|
6f4a73 |
+run_cmac_selftests (int algo, int extended, selftest_report_func_t report)
|
|
|
6f4a73 |
+{
|
|
|
6f4a73 |
+ gpg_err_code_t ec;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ switch (algo)
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ case GCRY_MAC_CMAC_3DES:
|
|
|
6f4a73 |
+ ec = selftests_cmac_tdes (extended, report);
|
|
|
6f4a73 |
+ break;
|
|
|
6f4a73 |
+ case GCRY_MAC_CMAC_AES:
|
|
|
6f4a73 |
+ ec = selftests_cmac_aes (extended, report);
|
|
|
6f4a73 |
+ break;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ default:
|
|
|
6f4a73 |
+ ec = GPG_ERR_MAC_ALGO;
|
|
|
6f4a73 |
+ break;
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ return ec;
|
|
|
6f4a73 |
+}
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+/* Run the selftests for CMAC with CMAC algorithm ALGO with optional
|
|
|
6f4a73 |
+ reporting function REPORT. */
|
|
|
6f4a73 |
+gpg_error_t
|
|
|
6f4a73 |
+_gcry_cmac_selftest (int algo, int extended, selftest_report_func_t report)
|
|
|
6f4a73 |
+{
|
|
|
6f4a73 |
+ gcry_err_code_t ec = 0;
|
|
|
6f4a73 |
+
|
|
|
6f4a73 |
+ if (!_gcry_mac_algo_info( algo, GCRYCTL_TEST_ALGO, NULL, NULL ))
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ ec = run_cmac_selftests (algo, extended, report);
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ else
|
|
|
6f4a73 |
+ {
|
|
|
6f4a73 |
+ ec = GPG_ERR_MAC_ALGO;
|
|
|
6f4a73 |
+ if (report)
|
|
|
6f4a73 |
+ report ("mac", algo, "module", "algorithm not available");
|
|
|
6f4a73 |
+ }
|
|
|
6f4a73 |
+ return gpg_error (ec);
|
|
|
6f4a73 |
+}
|
|
|
6f4a73 |
diff -up libgcrypt-1.8.3/src/cipher-proto.h.cmac-selftest libgcrypt-1.8.3/src/cipher-proto.h
|
|
|
6f4a73 |
--- libgcrypt-1.8.3/src/cipher-proto.h.cmac-selftest 2017-11-23 19:16:58.000000000 +0100
|
|
|
6f4a73 |
+++ libgcrypt-1.8.3/src/cipher-proto.h 2019-05-31 17:29:34.574588234 +0200
|
|
|
6f4a73 |
@@ -256,6 +256,8 @@ gcry_error_t _gcry_pk_selftest (int algo
|
|
|
6f4a73 |
selftest_report_func_t report);
|
|
|
6f4a73 |
gcry_error_t _gcry_hmac_selftest (int algo, int extended,
|
|
|
6f4a73 |
selftest_report_func_t report);
|
|
|
6f4a73 |
+gcry_error_t _gcry_cmac_selftest (int algo, int extended,
|
|
|
6f4a73 |
+ selftest_report_func_t report);
|
|
|
6f4a73 |
|
|
|
6f4a73 |
gcry_error_t _gcry_random_selftest (selftest_report_func_t report);
|
|
|
6f4a73 |
|
|
|
6f4a73 |
diff -up libgcrypt-1.8.3/src/fips.c.cmac-selftest libgcrypt-1.8.3/src/fips.c
|
|
|
6f4a73 |
--- libgcrypt-1.8.3/src/fips.c.cmac-selftest 2018-11-01 15:40:36.051865535 +0100
|
|
|
6f4a73 |
+++ libgcrypt-1.8.3/src/fips.c 2019-05-31 17:31:20.157756640 +0200
|
|
|
6f4a73 |
@@ -521,29 +521,32 @@ run_digest_selftests (int extended)
|
|
|
6f4a73 |
|
|
|
6f4a73 |
/* Run self-tests for all HMAC algorithms. Return 0 on success. */
|
|
|
6f4a73 |
static int
|
|
|
6f4a73 |
-run_hmac_selftests (int extended)
|
|
|
6f4a73 |
+run_mac_selftests (int extended)
|
|
|
6f4a73 |
{
|
|
|
6f4a73 |
- static int algos[] =
|
|
|
6f4a73 |
+ static int algos[][2] =
|
|
|
6f4a73 |
{
|
|
|
6f4a73 |
- GCRY_MD_SHA1,
|
|
|
6f4a73 |
- GCRY_MD_SHA224,
|
|
|
6f4a73 |
- GCRY_MD_SHA256,
|
|
|
6f4a73 |
- GCRY_MD_SHA384,
|
|
|
6f4a73 |
- GCRY_MD_SHA512,
|
|
|
6f4a73 |
- GCRY_MD_SHA3_224,
|
|
|
6f4a73 |
- GCRY_MD_SHA3_256,
|
|
|
6f4a73 |
- GCRY_MD_SHA3_384,
|
|
|
6f4a73 |
- GCRY_MD_SHA3_512,
|
|
|
6f4a73 |
- 0
|
|
|
6f4a73 |
+ { GCRY_MD_SHA1, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA224, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA256, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA384, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA512, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA3_224, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA3_256, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA3_384, 0 },
|
|
|
6f4a73 |
+ { GCRY_MD_SHA3_512, 0 },
|
|
|
6f4a73 |
+ { GCRY_MAC_CMAC_3DES, 1 },
|
|
|
6f4a73 |
+ { GCRY_MAC_CMAC_AES, 1 },
|
|
|
6f4a73 |
+ { 0, 0 }
|
|
|
6f4a73 |
};
|
|
|
6f4a73 |
int idx;
|
|
|
6f4a73 |
gpg_error_t err;
|
|
|
6f4a73 |
int anyerr = 0;
|
|
|
6f4a73 |
|
|
|
6f4a73 |
- for (idx=0; algos[idx]; idx++)
|
|
|
6f4a73 |
+ for (idx=0; algos[idx][0]; idx++)
|
|
|
6f4a73 |
{
|
|
|
6f4a73 |
- err = _gcry_hmac_selftest (algos[idx], extended, reporter);
|
|
|
6f4a73 |
- reporter ("hmac", algos[idx], NULL,
|
|
|
6f4a73 |
+ err = algos[idx][1] ? _gcry_cmac_selftest (algos[idx][0], extended, reporter) :
|
|
|
6f4a73 |
+ _gcry_hmac_selftest (algos[idx][0], extended, reporter);
|
|
|
6f4a73 |
+ reporter (algos[idx][1] ? "cmac" : "hmac", algos[idx][0], NULL,
|
|
|
6f4a73 |
err? gpg_strerror (err):NULL);
|
|
|
6f4a73 |
if (err)
|
|
|
6f4a73 |
anyerr = 1;
|
|
|
6f4a73 |
@@ -747,7 +750,7 @@ _gcry_fips_run_selftests (int extended)
|
|
|
6f4a73 |
if (run_digest_selftests (extended))
|
|
|
6f4a73 |
goto leave;
|
|
|
6f4a73 |
|
|
|
6f4a73 |
- if (run_hmac_selftests (extended))
|
|
|
6f4a73 |
+ if (run_mac_selftests (extended))
|
|
|
6f4a73 |
goto leave;
|
|
|
6f4a73 |
|
|
|
6f4a73 |
/* Run random tests before the pubkey tests because the latter
|