summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2021-12-02 13:59:06 +0100
committerNIIBE Yutaka <gniibe@fsij.org>2021-12-06 09:42:46 +0900
commit57b61b0f4f1be7513ed064a90321849bb9f47f29 (patch)
treea140c7d91e35988392d51cc007def13c18abb30b /tests
parentb601ef4dc9f9a337e3019fc5ad3c7b31fcdc43f3 (diff)
downloadlibgcrypt-57b61b0f4f1be7513ed064a90321849bb9f47f29.tar.gz
tests: Conditionalize other algorithms that might not be built-in
* tests/basic.c (check_cbc_mac_cipher): Do not run DES tests without DES being built-in. (check_ecb_cipher): Do not run blowfish and DES tests without them being built-in (check_cfb_cipher): Do not run DES tests without DES being built-in. (check_ccm_cipher): Do not run camellia tests without it being built-in. (check_ocb_cipher): Do not run Camellia, Twofish and Serpent tests without them being built-in. (check_digests): Do not run SM3 tests without them being built-in. (check_digests): Do not run DES, Camellia and GOST tests without them being built-in. -- Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/basic.c b/tests/basic.c
index 36420917..a2dc4869 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -465,6 +465,7 @@ check_cbc_mac_cipher (void)
"chicken teriyaki",
"This is a sample plaintext for CBC MAC of sixtyfour bytes.......",
0, "\x23\x8f\x6d\xc7\x53\x6a\x62\x97\x11\xc4\xa5\x16\x43\xea\xb0\xb6" },
+#if USE_DES
{ GCRY_CIPHER_3DES,
"abcdefghABCDEFGH01234567",
"This is a sample plaintext for CBC MAC of sixtyfour bytes.......",
@@ -473,6 +474,7 @@ check_cbc_mac_cipher (void)
"abcdefgh",
"This is a sample plaintext for CBC MAC of sixtyfour bytes.......",
0, "\xfa\x4b\xdf\x9d\xfa\xab\x01\x70" }
+#endif /* USE_DES */
};
gcry_cipher_hd_t hd;
unsigned char out[MAX_DATA_LEN];
@@ -718,6 +720,7 @@ check_ecb_cipher (void)
} data[MAX_DATA_LEN];
} tv[] =
{
+#if USE_BLOWFISH
/* Test vectors from OpenSSL for key lengths of 8 to 200 bits */
{ GCRY_CIPHER_BLOWFISH,
"\xf0\xe1\xd2\xc3\xb4\xa5\x96\x87\x78\x69\x5a\x4b\x3c\x2d\x1e\x0f"
@@ -840,6 +843,8 @@ check_ecb_cipher (void)
{ }
}
},
+#endif /* USE_BLOWFISH */
+#if USE_DES
/* Weak-key testing */
{ GCRY_CIPHER_DES,
"\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe",
@@ -862,6 +867,7 @@ check_ecb_cipher (void)
{ }
}
},
+#endif /* USE_DES */
#if USE_SM4
{ GCRY_CIPHER_SM4,
"\x01\x23\x45\x67\x89\xab\xcd\xef\xfe\xdc\xba\x98\x76\x54\x32\x10",
@@ -2502,6 +2508,7 @@ check_cfb_cipher (void)
"\x63\x8c\x68\x23\xe7\x25\x6f\xb5\x62\x6e"},
}
},
+#if USE_DES
{ GCRY_CIPHER_3DES, FLAG_CFB8 | FLAG_NOFIPS,
"\xe3\x34\x7a\x6b\x0b\xc1\x15\x2c\x64\x2a\x25\xcb\xd3\xbc\x31\xab"
"\xfb\xa1\x62\xa8\x1f\x19\x7c\x15",
@@ -2520,6 +2527,7 @@ check_cfb_cipher (void)
"\xf2\x0e\x53\x66\x74\xa6\x6f\xa7\x38\x05"},
}
},
+#endif /* USE_DES */
#ifdef USE_GOST28147
{ GCRY_CIPHER_GOST28147_MESH, FLAG_NOFIPS,
"\x48\x0c\x74\x1b\x02\x6b\x55\xd5\xb6\x6d\xd7\x1d\x40\x48\x05\x6b"
@@ -7070,6 +7078,7 @@ check_ccm_cipher (void)
"\xAB\xF2\x1C\x0B\x02\xFE\xB8\x8F\x85\x6D\xF4\xA3\x73\x81\xBC\xE3\xCC\x12\x85\x17\xD4",
31,
"\xF3\x29\x05\xB8\x8A\x64\x1B\x04\xB9\xC9\xFF\xB5\x8C\xC3\x90\x90\x0F\x3D\xA1\x2A\xB1\x6D\xCE\x9E\x82\xEF\xA1\x6D\xA6\x20\x59"},
+#if USE_CAMELLIA
/* RFC 5528 */
{ GCRY_CIPHER_CAMELLIA128, FLAG_NOFIPS, /* Packet Vector #1 */
16, "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF",
@@ -7263,6 +7272,7 @@ check_ccm_cipher (void)
"\x9D\xC9\xED\xAE\x2F\xF5\xDF\x86\x36\xE8\xC6\xDE\x0E\xED\x55\xF7\x86\x7E\x33\x33\x7D",
31,
"\x4B\x19\x81\x56\x39\x3B\x0F\x77\x96\x08\x6A\xAF\xB4\x54\xF8\xC3\xF0\x34\xCC\xA9\x66\x94\x5F\x1F\xCE\xA7\xE1\x1B\xEE\x6A\x2F"}
+#endif /* USE_CAMELLIA */
};
static const int cut[] = { 0, 1, 8, 10, 16, 19, -1 };
gcry_cipher_hd_t hde, hdd;
@@ -8850,22 +8860,28 @@ check_ocb_cipher (void)
"\x4a\x00\x7f\x8d\xbe\x38\x32\x48\xb2\x2f\x7f\x27\xd8\x15\x7f\xb0");
check_ocb_cipher_largebuf(GCRY_CIPHER_AES256, 32,
"\xec\xc5\xe9\x2b\x24\x91\xba\x64\xbc\xe3\x62\xb6\x83\x20\xad\xbd");
+#if USE_CAMELLIA
check_ocb_cipher_largebuf(GCRY_CIPHER_CAMELLIA128, 16,
"\xd5\xbd\x76\xec\x75\x4a\xab\x6c\x13\xec\x87\x95\x11\xd4\xf0\x3d");
check_ocb_cipher_largebuf(GCRY_CIPHER_CAMELLIA192, 24,
"\xde\xdd\x6b\xbf\xce\x15\x01\x39\x7c\xc5\x69\x19\x72\xa2\x67\x23");
check_ocb_cipher_largebuf(GCRY_CIPHER_CAMELLIA256, 32,
"\x0c\xf3\xd5\x82\x20\x73\xee\x0f\xbd\x6b\x32\x38\xf9\x10\xef\xe5");
+#endif /* USE_CAMELLIA */
+#if USE_TWOFISH
check_ocb_cipher_largebuf(GCRY_CIPHER_TWOFISH, 16,
"\x54\x87\x68\xb6\x17\xe6\xd7\xa6\x76\x0d\x7e\x9f\x57\x8b\xec\x88");
check_ocb_cipher_largebuf(GCRY_CIPHER_TWOFISH, 32,
"\x0b\xc3\x93\x52\xfa\x97\x22\xe6\x88\x6e\x29\x4d\x77\x35\x48\x84");
+#endif /* USE_TWOFISH */
+#if USE_SERPENT
check_ocb_cipher_largebuf(GCRY_CIPHER_SERPENT128, 16,
"\x7e\x49\x3b\xd6\xde\x6e\x9e\x53\x67\xcd\x00\xad\xc9\xd9\xa5\xbc");
check_ocb_cipher_largebuf(GCRY_CIPHER_SERPENT192, 24,
"\x1e\x33\x0e\x06\xc8\x27\x6a\x0b\x41\x5e\x93\xae\x39\xf4\x50\x12");
check_ocb_cipher_largebuf(GCRY_CIPHER_SERPENT256, 32,
"\x6b\x4c\x3f\x8f\x77\x75\xf2\x4d\xaf\xde\x2c\x5f\x1a\x80\xb8\x4d");
+#endif /* USE_SERPENT */
#if USE_SM4
check_ocb_cipher_largebuf(GCRY_CIPHER_SM4, 16,
"\x3c\x32\x54\x5d\xc5\x17\xa1\x16\x3f\x8e\xc7\x1d\x8d\x8b\x2d\xb0");
@@ -13440,6 +13456,7 @@ check_digests (void)
{ GCRY_MD_BLAKE2S_128, "?",
"\x70\x0b\x8a\x71\x1d\x34\x0a\xf0\x13\x93\x19\x93\x5e\xd7\x54\x9c" },
+#if USE_SM3
{ GCRY_MD_SM3, "abc",
"\x66\xc7\xf0\xf4\x62\xee\xed\xd9\xd1\xf2\xd4\x6b\xdc\x10\xe4\xe2"
"\x41\x67\xc4\x87\x5c\xf2\xf7\xa2\x29\x7d\xa0\x2b\x8f\x4b\xa8\xe0" },
@@ -13464,6 +13481,7 @@ check_digests (void)
"ral Public License for more details.",
"\x8b\x91\x3f\x0e\x85\xae\x43\x25\x6d\x28\x38\x6c\x09\x5c\xc7\x72"
"\xcc\x2e\x78\x89\x7e\x2e\x4e\x5a\x3d\xf6\x55\xfe\x87\xbe\xa6\xbc" },
+#endif /* USE_SM3 */
{ GCRY_MD_GOSTR3411_CP,
"*",
@@ -13521,10 +13539,12 @@ check_digests (void)
"\xa5\xae\xe0\x05\x1c\x77\x0f\x29\x5b\x3f\xba\xab\x88\x0c\x0b\x8e"
"\x10\xcf\x3d\xa9\x0d\x1e\x97\x98\x96\xeb\x24\x2e\x70\x30\xd0\x78"
"\x2b\x9e\x30\xad\x5d\xcf\x56\xcf\xd0\xc1\x58\x95\x53\x09\x78\xd6" },
+#if USE_SM3
{ GCRY_MD_SM3,
"*",
"\xb6\xfc\x1e\xc4\xad\x9b\x88\xbd\x08\xaa\xf3\xb3\xfa\x4f\x1b\x9c"
"\xd6\x9a\x32\x09\x28\x9e\xda\x3a\x99\xb6\x09\x8f\x35\x99\xa6\x11" },
+#endif /* USE_SM3 */
{ GCRY_MD_STRIBOG256,
"*",
"\x35\x0b\xec\x46\x1f\x98\x19\xe7\x33\x12\xda\x9f\xaf\x3d\x32\xa6"
@@ -14839,6 +14859,7 @@ check_mac (void)
"\xe1\x99\x21\x90\x54\x9f\x6e\xd5\x69\x6a\x2c\x05\x6c\x31\x54\x10" },
{ GCRY_MAC_CMAC_AES, "?", "????????????????????????????????",
"\x9f\x72\x73\x68\xb0\x49\x2e\xb1\x35\xa0\x1d\xf9\xa8\x0a\xf6\xee" },
+#if USE_DES
{ GCRY_MAC_CMAC_3DES,
"",
"\x8a\xa8\x3b\xf8\xcb\xda\x10\x62\x0b\xc1\xbf\x19\xfb\xb6\xcd\x58"
@@ -14885,6 +14906,8 @@ check_mac (void)
"\x31\xb1\xe4\x31\xda\xbc\x4e\xb8" },
{ GCRY_MAC_CMAC_3DES, "?", "????????????????????????",
"\xc1\x38\x13\xb2\x31\x8f\x3a\xdf" },
+#endif /* USE_DES */
+#if USE_CAMELLIA
/* CMAC Camellia test vectors from
http://tools.ietf.org/html/draft-kato-ipsec-camellia-cmac96and128-05 */
{ GCRY_MAC_CMAC_CAMELLIA,
@@ -14910,6 +14933,7 @@ check_mac (void)
"\xc2\x69\x9a\x6e\xba\x55\xce\x9d\x93\x9a\x8a\x4e\x19\x46\x6e\xe9" },
{ GCRY_MAC_CMAC_CAMELLIA, "?", "????????????????????????????????",
"\xba\x8a\x5a\x8d\xa7\x54\x26\x83\x3e\xb1\x20\xb5\x45\xd0\x9f\x4e" },
+#endif /* USE_CAMELLIA */
/* http://csrc.nist.gov/groups/STM/cavp/documents/mac/gcmtestvectors.zip */
{ GCRY_MAC_GMAC_AES,
"",
@@ -15156,6 +15180,7 @@ check_mac (void)
"\x9d\xeb\xb0\xcd\x24\x90\xd3\x9b\x47\x78\x37\x0a\x81\xf2\x83\x2a",
"\x61\xee\x09\x21\x8d\x29\xb0\xaa\xed\x7e\x15\x4a\x2c\x55\x09\xcc",
0, 32 },
+#ifdef USE_GOST28147
{ GCRY_MAC_GOST28147_IMIT,
"\xb5\xa1\xf0\xe3\xce\x2f\x02\x1d\x67\x61\x94\x34\x5c\x41\xe3\x6e",
"\x9d\x05\xb7\x9e\x90\xca\xd0\x0a\x2c\xda\xd2\x2e\xf4\xe8\x6f\x5c"
@@ -15163,6 +15188,7 @@ check_mac (void)
"\xf8\x1f\x08\xa3",
NULL,
16, 32 },
+#endif /* USE_GOST28147 */
{ 0 },
};
int i;