summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2022-08-01 20:09:02 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2022-08-01 20:12:56 +0300
commita8f66410ca0ded040abea4790efaeb36bb4ccc91 (patch)
tree7948819f0e88599e54af111d2206222d7c5dd70c /tests
parenta0c933f6fed0612558ff75fb23cbf78e2dea1f16 (diff)
downloadlibgcrypt-a8f66410ca0ded040abea4790efaeb36bb4ccc91.tar.gz
basic: gcm-siv: add fips checks for SM4 and CAMELLIA128
* tests/basic.c (check_gcm_siv_cipher): Add 'flags' for test vectors and set FLAG_NOFIPS for SM4 and CAMELLIA128 test vectors; Add FIPS check for test vectors; Change printing "aes-gcm-siv" on fail messages to "algo %d GCM-SIV". -- Patch fixes tests/basic failing with "LIBGCRYPT_FORCE_FIPS_MODE=1". Reported-by: Clemens Lang <cllang@redhat.com> Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.c185
1 files changed, 101 insertions, 84 deletions
diff --git a/tests/basic.c b/tests/basic.c
index f88277cb..0d03636b 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -5329,6 +5329,7 @@ check_gcm_siv_cipher (void)
static const struct tv
{
int algo;
+ int flags;
char key[MAX_DATA_LEN];
char nonce[12];
char ad[MAX_DATA_LEN];
@@ -5341,7 +5342,7 @@ check_gcm_siv_cipher (void)
{
/* Test vectors from RFC8452 */
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xee\x8e\x1e\xd9\xff\x25\x40\xae\x8f\x2b\xa9\xf5\x0b\xc2\xf2\x7c",
"\x75\x2a\xba\xd3\xe0\xaf\xb5\xf4\x34\xdc\x43\x10",
"example",
@@ -5352,7 +5353,7 @@ check_gcm_siv_cipher (void)
"\x4f\xbc\xde\xb7\xe4\x79\x3f\x4a\x1d\x7e\x4f\xaa\x70\x10\x0a\xf1"
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5363,7 +5364,7 @@ check_gcm_siv_cipher (void)
"\xdc\x20\xe2\xd8\x3f\x25\x70\x5b\xb4\x9e\x43\x9e\xca\x56\xde\x25"
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5374,7 +5375,7 @@ check_gcm_siv_cipher (void)
"\xdc\x20\xe2\xd8\x3f\x25\x70\x5b\xb4\x9e\x43\x9e\xca\x56\xde\x25",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5385,7 +5386,7 @@ check_gcm_siv_cipher (void)
"\x57\x87\x82\xff\xf6\x01\x3b\x81\x5b\x28\x7c\x22\x49\x3a\x36\x4c",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5396,7 +5397,7 @@ check_gcm_siv_cipher (void)
"\xa4\x97\x8d\xb3\x57\x39\x1a\x0b\xc4\xfd\xec\x8b\x0d\x10\x66\x39",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5407,7 +5408,7 @@ check_gcm_siv_cipher (void)
"\x30\x3a\xaf\x90\xf6\xfe\x21\x19\x9c\x60\x68\x57\x74\x37\xa0\xc4",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5420,7 +5421,7 @@ check_gcm_siv_cipher (void)
"\x1a\x8e\x45\xdc\xd4\x57\x8c\x66\x7c\xd8\x68\x47\xbf\x61\x55\xff",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5435,7 +5436,7 @@ check_gcm_siv_cipher (void)
"\x5e\x6e\x31\x1d\xbf\x39\x5d\x35\xb0\xfe\x39\xc2\x71\x43\x88\xf8",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"",
@@ -5452,7 +5453,7 @@ check_gcm_siv_cipher (void)
"\x8a\x26\x3d\xd3\x17\xaa\x88\xd5\x6b\xdf\x39\x36\xdb\xa7\x5b\xb8",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01",
@@ -5463,7 +5464,7 @@ check_gcm_siv_cipher (void)
"\x3b\x0a\x1a\x25\x60\x96\x9c\xdf\x79\x0d\x99\x75\x9a\xbd\x15\x08",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01",
@@ -5474,7 +5475,7 @@ check_gcm_siv_cipher (void)
"\x08\x29\x9c\x51\x02\x74\x5a\xaa\x3a\x0c\x46\x9f\xad\x9e\x07\x5a",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01",
@@ -5485,7 +5486,7 @@ check_gcm_siv_cipher (void)
"\x8f\x89\x36\xec\x03\x9e\x4e\x4b\xb9\x7e\xbd\x8c\x44\x57\x44\x1f",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01",
@@ -5498,7 +5499,7 @@ check_gcm_siv_cipher (void)
"\xe6\xaf\x6a\x7f\x87\x28\x7d\xa0\x59\xa7\x16\x84\xed\x34\x98\xe1",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01",
@@ -5513,7 +5514,7 @@ check_gcm_siv_cipher (void)
"\x6a\x8c\xc3\x86\x5f\x76\x89\x7c\x2e\x4b\x24\x5c\xf3\x1c\x51\xf2",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01",
@@ -5530,7 +5531,7 @@ check_gcm_siv_cipher (void)
"\xcd\xc4\x6a\xe4\x75\x56\x3d\xe0\x37\x00\x1e\xf8\x4a\xe2\x17\x44",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5541,7 +5542,7 @@ check_gcm_siv_cipher (void)
"\x07\xeb\x1f\x84\xfb\x28\xf8\xcb\x73\xde\x8e\x99\xe2\xf4\x8a\x14",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -5555,7 +5556,7 @@ check_gcm_siv_cipher (void)
"\x24\xaf\xc9\x80\x5e\x97\x6f\x45\x1e\x6d\x87\xf6\xfe\x10\x65\x14",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -5569,7 +5570,7 @@ check_gcm_siv_cipher (void)
"\xbf\xf9\xb2\xef\x00\xfb\x47\x92\x0c\xc7\x2a\x0c\x0f\x13\xb9\xfd",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xe6\x60\x21\xd5\xeb\x8e\x4f\x40\x66\xd4\xad\xb9\xc3\x35\x60\xe4",
"\xf4\x6e\x44\xbb\x3d\xa0\x01\x5c\x94\xf7\x08\x87",
"",
@@ -5580,7 +5581,7 @@ check_gcm_siv_cipher (void)
"\xa4\x19\x4b\x79\x07\x1b\x01\xa8\x7d\x65\xf7\x06\xe3\x94\x95\x78",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x36\x86\x42\x00\xe0\xea\xf5\x28\x4d\x88\x4a\x0e\x77\xd3\x16\x46",
"\xba\xe8\xe3\x7f\xc8\x34\x41\xb1\x60\x34\x56\x6b",
"\x46\xbb\x91\xc3\xc5",
@@ -5591,7 +5592,7 @@ check_gcm_siv_cipher (void)
"\x71\x1b\xd8\x5b\xc1\xe4\xd3\xe0\xa4\x62\xe0\x74\xee\xa4\x28\xa8",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xae\xdb\x64\xa6\xc5\x90\xbc\x84\xd1\xa5\xe2\x69\xe4\xb4\x78\x01",
"\xaf\xc0\x57\x7e\x34\x69\x9b\x9e\x67\x1f\xdd\x4f",
"\xfc\x88\x0c\x94\xa9\x51\x98\x87\x42\x96",
@@ -5602,7 +5603,7 @@ check_gcm_siv_cipher (void)
"\xd6\xa9\xc4\x55\x45\xcf\xc1\x1f\x03\xad\x74\x3d\xba\x20\xf9\x66",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xd5\xcc\x1f\xd1\x61\x32\x0b\x69\x20\xce\x07\x78\x7f\x86\x74\x3b",
"\x27\x5d\x1a\xb3\x2f\x6d\x1f\x04\x34\xd8\x84\x8c",
"\x04\x67\x87\xf3\xea\x22\xc1\x27\xaa\xf1\x95\xd1\x89\x47\x28",
@@ -5613,7 +5614,7 @@ check_gcm_siv_cipher (void)
"\x1d\x02\xfd\x0c\xd1\x74\xc8\x4f\xc5\xda\xe2\xf6\x0f\x52\xfd\x2b",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xb3\xfe\xd1\x47\x3c\x52\x8b\x84\x26\xa5\x82\x99\x59\x29\xa1\x49",
"\x9e\x9a\xd8\x78\x0c\x8d\x63\xd0\xab\x41\x49\xc0",
"\xc9\x88\x2e\x53\x86\xfd\x9f\x92\xec\x48\x9c\x8f\xde\x2b\xe2\xcf"
@@ -5625,7 +5626,7 @@ check_gcm_siv_cipher (void)
"\xc1\xdc\x2f\x87\x1f\xb7\x56\x1d\xa1\x28\x6e\x65\x5e\x24\xb7\xb0",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x2d\x4e\xd8\x7d\xa4\x41\x02\x95\x2e\xf9\x4b\x02\xb8\x05\x24\x9b",
"\xac\x80\xe6\xf6\x14\x55\xbf\xac\x83\x08\xa2\xd4",
"\x29\x50\xa7\x0d\x5a\x1d\xb2\x31\x6f\xd5\x68\x37\x8d\xa1\x07\xb5"
@@ -5637,7 +5638,7 @@ check_gcm_siv_cipher (void)
"\x83\xb3\x44\x9b\x9f\x39\x55\x2d\xe9\x9d\xc2\x14\xa1\x19\x0b\x0b",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xbd\xe3\xb2\xf2\x04\xd1\xe9\xf8\xb0\x6b\xc4\x7f\x97\x45\xb3\xd1",
"\xae\x06\x55\x6f\xb6\xaa\x78\x90\xbe\xbc\x18\xfe",
"\x18\x60\xf7\x62\xeb\xfb\xd0\x82\x84\xe4\x21\x70\x2d\xe0\xde\x18"
@@ -5651,7 +5652,7 @@ check_gcm_siv_cipher (void)
"\x3e\x37\x70\x94\xf0\x47\x09\xf6\x4d\x7b\x98\x53\x10\xa4\xdb\x84",
},
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\xf9\x01\xcf\xe8\xa6\x96\x15\xa9\x3f\xdf\x7a\x98\xca\xd4\x81\x79",
"\x62\x45\x70\x9f\xb1\x88\x53\xf6\x8d\x83\x36\x40",
"\x75\x76\xf7\x02\x8e\xc6\xeb\x5e\xa7\xe2\x98\x34\x2a\x94\xd4\xb2"
@@ -5666,7 +5667,7 @@ check_gcm_siv_cipher (void)
"\x2d\x15\x50\x6c\x84\xa9\xed\xd6\x5e\x13\xe9\xd2\x4a\x2a\x6e\x70",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5678,7 +5679,7 @@ check_gcm_siv_cipher (void)
"\x07\xf5\xf4\x16\x9b\xbf\x55\xa8\x40\x0c\xd4\x7e\xa6\xfd\x40\x0f",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5690,7 +5691,7 @@ check_gcm_siv_cipher (void)
"\x84\x31\x22\x13\x0f\x73\x64\xb7\x61\xe0\xb9\x74\x27\xe3\xdf\x28",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5702,7 +5703,7 @@ check_gcm_siv_cipher (void)
"\x8c\xa5\x0d\xa9\xae\x65\x59\xe4\x8f\xd1\x0f\x6e\x5c\x9c\xa1\x7e",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5714,7 +5715,7 @@ check_gcm_siv_cipher (void)
"\xc9\xea\xc6\xfa\x70\x09\x42\x70\x2e\x90\x86\x23\x83\xc6\xc3\x66",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5728,7 +5729,7 @@ check_gcm_siv_cipher (void)
"\xe8\x19\xe6\x3a\xbc\xd0\x20\xb0\x06\xa9\x76\x39\x76\x32\xeb\x5d",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5744,7 +5745,7 @@ check_gcm_siv_cipher (void)
"\x79\x0b\xc9\x68\x80\xa9\x9b\xa8\x04\xbd\x12\xc0\xe6\xa2\x2c\xc4",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5762,7 +5763,7 @@ check_gcm_siv_cipher (void)
"\x11\x28\x64\xc2\x69\xfc\x0d\x9d\x88\xc6\x1f\xa4\x7e\x39\xaa\x08",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5774,7 +5775,7 @@ check_gcm_siv_cipher (void)
"\x91\x21\x3f\x26\x7e\x3b\x45\x2f\x02\xd0\x1a\xe3\x3e\x4e\xc8\x54",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5786,7 +5787,7 @@ check_gcm_siv_cipher (void)
"\xc1\xa4\xa1\x9a\xe8\x00\x94\x1c\xcd\xc5\x7c\xc8\x41\x3c\x27\x7f",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5798,7 +5799,7 @@ check_gcm_siv_cipher (void)
"\xb2\x92\xd2\x8f\xf6\x11\x89\xe8\xe4\x9f\x38\x75\xef\x91\xaf\xf7",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5812,7 +5813,7 @@ check_gcm_siv_cipher (void)
"\xae\xa1\xba\xd1\x27\x02\xe1\x96\x56\x04\x37\x4a\xab\x96\xdb\xbc",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5828,7 +5829,7 @@ check_gcm_siv_cipher (void)
"\x03\x33\x27\x42\xb2\x28\xc6\x47\x17\x36\x16\xcf\xd4\x4c\x54\xeb",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5846,7 +5847,7 @@ check_gcm_siv_cipher (void)
"\x5b\xde\x02\x85\x03\x7c\x5d\xe8\x1e\x5b\x57\x0a\x04\x9b\x62\xa0",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5858,7 +5859,7 @@ check_gcm_siv_cipher (void)
"\x18\x35\xe5\x17\x74\x1d\xfd\xdc\xcf\xa0\x7f\xa4\x66\x1b\x74\xcf",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5873,7 +5874,7 @@ check_gcm_siv_cipher (void)
"\xb8\x79\xad\x97\x6d\x82\x42\xac\xc1\x88\xab\x59\xca\xbf\xe3\x07",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -5888,7 +5889,7 @@ check_gcm_siv_cipher (void)
"\xcf\xcd\xf5\x04\x21\x12\xaa\x29\x68\x5c\x91\x2f\xc2\x05\x65\x43",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\xe6\x60\x21\xd5\xeb\x8e\x4f\x40\x66\xd4\xad\xb9\xc3\x35\x60\xe4"
"\xf4\x6e\x44\xbb\x3d\xa0\x01\x5c\x94\xf7\x08\x87\x36\x86\x42\x00",
"\xe0\xea\xf5\x28\x4d\x88\x4a\x0e\x77\xd3\x16\x46",
@@ -5900,7 +5901,7 @@ check_gcm_siv_cipher (void)
"\x16\x9f\xbb\x2f\xbf\x38\x9a\x99\x5f\x63\x90\xaf\x22\x22\x8a\x62",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\xba\xe8\xe3\x7f\xc8\x34\x41\xb1\x60\x34\x56\x6b\x7a\x80\x6c\x46"
"\xbb\x91\xc3\xc5\xae\xdb\x64\xa6\xc5\x90\xbc\x84\xd1\xa5\xe2\x69",
"\xe4\xb4\x78\x01\xaf\xc0\x57\x7e\x34\x69\x9b\x9e",
@@ -5912,7 +5913,7 @@ check_gcm_siv_cipher (void)
"\x93\xda\x9b\xb8\x13\x33\xae\xe0\xc7\x85\xb2\x40\xd3\x19\x71\x9d",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x65\x45\xfc\x88\x0c\x94\xa9\x51\x98\x87\x42\x96\xd5\xcc\x1f\xd1"
"\x61\x32\x0b\x69\x20\xce\x07\x78\x7f\x86\x74\x3b\x27\x5d\x1a\xb3",
"\x2f\x6d\x1f\x04\x34\xd8\x84\x8c\x11\x77\x44\x1f",
@@ -5924,7 +5925,7 @@ check_gcm_siv_cipher (void)
"\x6b\x62\xb8\x4d\xc4\x0c\x84\x63\x6a\x5e\xc1\x20\x20\xec\x8c\x2c",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\xd1\x89\x47\x28\xb3\xfe\xd1\x47\x3c\x52\x8b\x84\x26\xa5\x82\x99"
"\x59\x29\xa1\x49\x9e\x9a\xd8\x78\x0c\x8d\x63\xd0\xab\x41\x49\xc0",
"\x9f\x57\x2c\x61\x4b\x47\x45\x91\x44\x74\xe7\xc7",
@@ -5936,7 +5937,7 @@ check_gcm_siv_cipher (void)
"\xc0\xfd\x3d\xc6\x62\x8d\xfe\x55\xeb\xb0\xb9\xfb\x22\x95\xc8\xc2",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\xa4\x41\x02\x95\x2e\xf9\x4b\x02\xb8\x05\x24\x9b\xac\x80\xe6\xf6"
"\x14\x55\xbf\xac\x83\x08\xa2\xd4\x0d\x8c\x84\x51\x17\x80\x82\x35",
"\x5c\x9e\x94\x0f\xea\x2f\x58\x29\x50\xa7\x0d\x5a",
@@ -5949,7 +5950,7 @@ check_gcm_siv_cipher (void)
"\x40\x40\x99\xc2\x58\x7f\x64\x97\x9f\x21\x82\x67\x06\xd4\x97\xd5",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x97\x45\xb3\xd1\xae\x06\x55\x6f\xb6\xaa\x78\x90\xbe\xbc\x18\xfe"
"\x6b\x3d\xb4\xda\x3d\x57\xaa\x94\x84\x2b\x98\x03\xa9\x6e\x07\xfb",
"\x6d\xe7\x18\x60\xf7\x62\xeb\xfb\xd0\x82\x84\xe4",
@@ -5962,7 +5963,7 @@ check_gcm_siv_cipher (void)
"\xb3\x08\x0d\x28\xf6\xeb\xb5\xd3\x64\x8c\xe9\x7b\xd5\xba\x67\xfd",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\xb1\x88\x53\xf6\x8d\x83\x36\x40\xe4\x2a\x3c\x02\xc2\x5b\x64\x86"
"\x9e\x14\x6d\x7b\x23\x39\x87\xbd\xdf\xc2\x40\x87\x1d\x75\x76\xf7",
"\x02\x8e\xc6\xeb\x5e\xa7\xe2\x98\x34\x2a\x94\xd4",
@@ -5977,7 +5978,7 @@ check_gcm_siv_cipher (void)
"\x45\x4f\xc2\xa1\x54\xfe\xa9\x1f\x83\x63\xa3\x9f\xec\x7d\x0a\x49",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x3c\x53\x5d\xe1\x92\xea\xed\x38\x22\xa2\xfb\xbe\x2c\xa9\xdf\xc8"
"\x82\x55\xe1\x4a\x66\x1b\x8a\xa8\x2c\xc5\x42\x36\x09\x3b\xbc\x23",
"\x68\x80\x89\xe5\x55\x40\xdb\x18\x72\x50\x4e\x1c",
@@ -5993,7 +5994,7 @@ check_gcm_siv_cipher (void)
"\x9d\x6c\x70\x29\x67\x5b\x89\xea\xf4\xba\x1d\xed\x1a\x28\x65\x94",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -6007,7 +6008,7 @@ check_gcm_siv_cipher (void)
"\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
},
{
- GCRY_CIPHER_AES256,
+ GCRY_CIPHER_AES256, 0,
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -6022,7 +6023,7 @@ check_gcm_siv_cipher (void)
},
/* Large block testing */
{
- GCRY_CIPHER_AES128,
+ GCRY_CIPHER_AES128, 0,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -6160,7 +6161,7 @@ check_gcm_siv_cipher (void)
"\xce\xc3\x13\x6c\x40\x2a\xcc\x51\xa1\xce\xb3\xed\xe8\xa6\x5b\x04",
},
{
- GCRY_CIPHER_SM4,
+ GCRY_CIPHER_SM4, FLAG_NOFIPS,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -6298,7 +6299,7 @@ check_gcm_siv_cipher (void)
"\xe2\x32\xda\x3a\x5a\x0e\x45\x1b\x8e\xf8\xbb\xe6\x60\x71\x81\xeb",
},
{
- GCRY_CIPHER_CAMELLIA128,
+ GCRY_CIPHER_CAMELLIA128, FLAG_NOFIPS,
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
@@ -6564,7 +6565,6 @@ check_gcm_siv_cipher (void)
"\xc6\x54\xf9\xf0\x22\x2c\xc3\xee\xdd\x13\x02\xb8\xe7\x5a\x2e\x7e"
}
};
-
gcry_cipher_hd_t hde, hdd;
unsigned char out[MAX_DATA_LEN * 2];
unsigned char tag[16];
@@ -6577,10 +6577,23 @@ check_gcm_siv_cipher (void)
for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++)
{
- /* The AES algorithm is allowed in FIPS mode */
if ((err = gcry_cipher_test_algo (tv[i].algo)))
{
- fail ("aes-gcm-siv, gcry_cipher_test_algo failed: %s\n", gpg_strerror (err));
+ if (in_fips_mode && (tv[i].flags & FLAG_NOFIPS))
+ {
+ if (verbose)
+ fprintf (stderr, " algorithm %d not available in fips mode\n",
+ tv[i].algo);
+ }
+ else
+ fail ("algo %d GCM-SIV, gcry_cipher_test_algo unexpectedly failed: %s\n",
+ tv[i].algo, gpg_strerror (err));
+ continue;
+ }
+ else if (in_fips_mode && (tv[i].flags & FLAG_NOFIPS))
+ {
+ fail ("algo %d GCM-SIV, gcry_cipher_test_algo did not fail as expected\n",
+ tv[i].algo);
continue;
}
@@ -6593,14 +6606,16 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_GCM_SIV, 0);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_open failed: %s\n", gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_open failed: %s\n", tv[i].algo,
+ gpg_strerror (err));
return;
}
keylen = gcry_cipher_get_algo_keylen (tv[i].algo);
if (!keylen)
{
- fail ("aes-gcm-siv, gcry_cipher_get_algo_keylen failed\n");
+ fail ("algo %d GCM-SIV, gcry_cipher_get_algo_keylen failed\n",
+ tv[i].algo);
return;
}
@@ -6609,7 +6624,7 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_setkey (hdd, tv[i].key, keylen);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_setkey failed: %s\n",
+ fail ("algo %d GCM-SIV, gcry_cipher_setkey failed: %s\n", tv[i].algo,
gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
@@ -6621,7 +6636,7 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_setiv (hdd, tv[i].nonce, 12);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_setiv failed: %s\n",
+ fail ("algo %d GCM-SIV, gcry_cipher_setiv failed: %s\n", tv[i].algo,
gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
@@ -6635,8 +6650,8 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_authenticate (hdd, tv[i].ad, tv[i].adlen);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_authenticate failed: %s\n",
- gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_authenticate failed: %s\n",
+ tv[i].algo, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6668,8 +6683,8 @@ check_gcm_siv_cipher (void)
tv[i].plaintext, tv[i].inlen);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_encrypt (%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_encrypt (%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6678,14 +6693,15 @@ check_gcm_siv_cipher (void)
if (memcmp (tv[i].out, out, tv[i].inlen))
{
mismatch (tv[i].out, tv[i].inlen, out, tv[i].inlen);
- fail ("aes-gcm-siv, encrypt mismatch entry %d\n", i);
+ fail ("algo %d GCM-SIV, encrypt mismatch entry %d\n",
+ tv[i].algo, i);
}
err = gcry_cipher_gettag (hde, tag, taglen2);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_gettag(%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_gettag(%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6694,14 +6710,14 @@ check_gcm_siv_cipher (void)
if (memcmp (tv[i].tag, tag, taglen2))
{
mismatch (tv[i].tag, taglen2, tag, taglen2);
- fail ("aes-gcm-siv, tag mismatch entry %d\n", i);
+ fail ("algo %d GCM-SIV, tag mismatch entry %d\n", tv[i].algo, i);
}
err = gcry_cipher_set_decryption_tag (hdd, tag, taglen2);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_set_decryption_tag (%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_set_decryption_tag (%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6710,21 +6726,22 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_decrypt (hdd, out, tv[i].inlen, NULL, 0);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_decrypt (%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_decrypt (%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
}
if (memcmp (tv[i].plaintext, out, tv[i].inlen))
- fail ("aes-gcm-siv, decrypt mismatch entry %d\n", i);
+ fail ("algo %d GCM-SIV, decrypt mismatch entry %d\n",
+ tv[i].algo, i);
err = gcry_cipher_checktag (hdd, tag, taglen2);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_checktag (%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_checktag (%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6735,8 +6752,8 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_gettag (hde, tag, taglen2);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_gettag(%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_gettag(%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6745,14 +6762,14 @@ check_gcm_siv_cipher (void)
if (memcmp (tv[i].tag, tag, taglen2))
{
mismatch (tv[i].tag, taglen2, tag, taglen2);
- fail ("aes-gcm-siv, tag mismatch entry %d\n", i);
+ fail ("algo %d GCM-SIV, tag mismatch entry %d\n", tv[i].algo, i);
}
err = gcry_cipher_checktag (hdd, tv[i].tag, taglen2);
if (err)
{
- fail ("aes-gcm-siv, gcry_cipher_checktag (%d) failed: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_checktag (%d) failed: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;
@@ -6762,8 +6779,8 @@ check_gcm_siv_cipher (void)
err = gcry_cipher_checktag (hdd, tag, taglen2);
if (gpg_err_code (err) != GPG_ERR_CHECKSUM)
{
- fail ("aes-gcm-siv, gcry_cipher_checktag (%d) expected checksum fail: %s\n",
- i, gpg_strerror (err));
+ fail ("algo %d GCM-SIV, gcry_cipher_checktag (%d) expected checksum fail: %s\n",
+ tv[i].algo, i, gpg_strerror (err));
gcry_cipher_close (hde);
gcry_cipher_close (hdd);
return;