summaryrefslogtreecommitdiffstats
path: root/test/evp_test.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-08-22 12:50:00 +0200
committerRichard Levitte <levitte@openssl.org>2019-08-24 13:01:15 +0200
commit703170d4b9da1b3adc0e4d87719a5156080b2dca (patch)
tree5223ce61f34a098ed497c54ac271ee26a3d30f15 /test/evp_test.c
parent9f57e2184de330e83d0636586e88a8524c513b8e (diff)
Get rid of the diversity of names for MAC parameters
The EVP_PKEY MAC implementations had a diversity of controls that were really the same thing. We did reproduce that for the provider based MACs, but are changing our minds on this. Instead of that, we now use one parameter name for passing the name of the underlying ciphers or digests to a MAC implementation, "cipher" and "digest", and one parameter name for passing the output size of the MAC, "size". Then we leave it to the EVP_PKEY->EVP_MAC bridge to translate "md" to "digest", and "digestsize" to "size". Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9667)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r--test/evp_test.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index 2dfa8d0318..17b9fc0dfb 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -1163,11 +1163,29 @@ static int mac_test_run_mac(EVP_TEST *t)
}
#endif
- if (expected->alg != NULL)
- params[params_n++] =
- OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM,
- expected->alg,
- strlen(expected->alg) + 1);
+ if (expected->alg != NULL) {
+ /*
+ * The underlying algorithm may be a cipher or a digest.
+ * We don't know which it is, but we can ask the MAC what it
+ * should be and bet on that.
+ */
+ if (OSSL_PARAM_locate_const(defined_params,
+ OSSL_MAC_PARAM_CIPHER) != NULL) {
+ params[params_n++] =
+ OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,
+ expected->alg,
+ strlen(expected->alg) + 1);
+ } else if (OSSL_PARAM_locate_const(defined_params,
+ OSSL_MAC_PARAM_DIGEST) != NULL) {
+ params[params_n++] =
+ OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
+ expected->alg,
+ strlen(expected->alg) + 1);
+ } else {
+ t->err = "MAC_BAD_PARAMS";
+ goto err;
+ }
+ }
if (expected->key != NULL)
params[params_n++] =
OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,