evp_test: updates for the new additional MAC_init arguments
authorPauli <ppzgs1@gmail.com>
Thu, 25 Feb 2021 03:49:37 +0000 (13:49 +1000)
committerPauli <ppzgs1@gmail.com>
Sun, 28 Feb 2021 07:25:49 +0000 (17:25 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14310)

test/evp_test.c
test/recipes/30-test_evp_data/evpmac_blake.txt
test/recipes/30-test_evp_data/evpmac_common.txt
test/recipes/30-test_evp_data/evpmac_siphash.txt

index d3b02a2e464d7069bf7c4dc291ccbbe25201a4bb..b9b1597be1688da4ca675f006b6d50ab8403d614 100644 (file)
@@ -1279,11 +1279,6 @@ static int mac_test_run_mac(EVP_TEST *t)
             goto err;
         }
     }
-    if (expected->key != NULL)
-        params[params_n++] =
-            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
-                                              expected->key,
-                                              expected->key_len);
     if (expected->custom != NULL)
         params[params_n++] =
             OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_CUSTOM,
@@ -1339,11 +1334,7 @@ static int mac_test_run_mac(EVP_TEST *t)
         goto err;
     }
 
-    if (!EVP_MAC_CTX_set_params(ctx, params)) {
-        t->err = "MAC_BAD_PARAMS";
-        goto err;
-    }
-    if (!EVP_MAC_init(ctx)) {
+    if (!EVP_MAC_init(ctx, expected->key, expected->key_len, params)) {
         t->err = "MAC_INIT_ERROR";
         goto err;
     }
index ad5836a175a28767ee45a7411ac348a7ddbd8f4b..416d6b25dd49a37356d0da15d187e899427d0fec 100644 (file)
@@ -169,7 +169,7 @@ Output = 233a6c732212f4813ec4c9f357e35297e59a652fd24155205f00363f7c54734ee1e8c73
 MAC = BLAKE2BMAC
 Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
 Ctrl = size:128
-Result = MAC_BAD_PARAMS
+Result = MAC_INIT_ERROR
 
 MAC = BLAKE2BMAC
 Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
@@ -225,7 +225,7 @@ Output = e9f7704dfe5080a4aafe62a806f53ea7f98ffc24175164158f18ec5497b961f5
 MAC = BLAKE2SMAC
 Key = 000102030405060708090a0b0c0d0e0f
 Ctrl = size:64
-Result = MAC_BAD_PARAMS
+Result = MAC_INIT_ERROR
 
 MAC = BLAKE2SMAC
 Key = 000102030405060708090a0b0c0d0e0f
index dcea924695fdd4d238e32d899d8ed46d8346d4f3..67a0d3482d90dad630160b4afccb259b084f67a6 100644 (file)
@@ -213,7 +213,7 @@ MAC = HMAC
 Algorithm = SHAKE128
 Input = "Test that SHAKE128 fails"
 Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f
-Result = MAC_BAD_PARAMS
+Result = MAC_INIT_ERROR
 
 
 Title = CMAC tests (from FIPS module)
index 2e24f8b1e55bb206dfc70a0cfcf0aecb61656744..028b2d656fd5653c7eba21d57279824dd47d7177 100644 (file)
@@ -155,7 +155,7 @@ Output = 5150d1772f50834a503e069a973fbd7c
 MAC = SipHash
 Ctrl = size:13
 Key = 000102030405060708090A0B0C0D0E0F
-Result = MAC_BAD_PARAMS
+Result = MAC_INIT_ERROR
 
 # SIPHASH - default values: 2,4 rounds, explicit 13-byte mac (invalid size)
 # by EVP_PKEY this time
@@ -164,3 +164,24 @@ MAC = SipHash by EVP_PKEY
 Ctrl = size:13
 Key = 000102030405060708090A0B0C0D0E0F
 Result = EVPPKEYCTXCTRL_ERROR
+
+Title = SIPHASH - explicit rounds
+
+MAC = SipHash
+Ctrl = size:0
+Ctrl = c-rounds:2
+Ctrl = d-rounds:4
+Key = 000102030405060708090A0B0C0D0E0F
+Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
+Output = 5150d1772f50834a503e069a973fbd7c
+
+# Generated by the reference implementation
+Title = SIPHASH - non-default values: 4,8 rounds
+
+MAC = SipHash
+Ctrl = size:8
+Ctrl = c-rounds:4
+Ctrl = d-rounds:8
+Key = 000102030405060708090A0B0C0D0E0F
+Input = 000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E
+Output = E67784BC5503DE23