From 9442c8d7636a2bb257e76d4137a5d7305dedf28f Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 5 Mar 2018 16:22:41 +0000 Subject: [PATCH] Update the tests to use the new EVP_PKEY_new_private_key() function Also to use the new EVP_PKEY_new_CMAC_key() Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/5520) --- test/evp_test.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/test/evp_test.c b/test/evp_test.c index 265a4c3dd4..860fcc878e 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -911,31 +911,17 @@ static int mac_test_run(EVP_TEST *t) } #endif - if (!TEST_ptr(genctx = EVP_PKEY_CTX_new_id(expected->type, NULL))) { - t->err = "MAC_PKEY_CTX_ERROR"; - goto err; - } - - if (EVP_PKEY_keygen_init(genctx) <= 0) { - t->err = "MAC_KEYGEN_INIT_ERROR"; - goto err; - } - if (expected->type == EVP_PKEY_CMAC - && EVP_PKEY_CTX_ctrl_str(genctx, "cipher", expected->alg) <= 0) { - t->err = "MAC_ALGORITHM_SET_ERROR"; - goto err; - } - - if (EVP_PKEY_CTX_set_mac_key(genctx, expected->key, - expected->key_len) <= 0) { - t->err = "MAC_KEY_SET_ERROR"; + if (expected->type == EVP_PKEY_CMAC) + key = EVP_PKEY_new_CMAC_key(NULL, expected->key, expected->key_len, + EVP_get_cipherbyname(expected->alg)); + else + key = EVP_PKEY_new_private_key(expected->type, NULL, expected->key, + expected->key_len); + if (key == NULL) { + t->err = "MAC_KEY_CREATE_ERROR"; goto err; } - if (EVP_PKEY_keygen(genctx, &key) <= 0) { - t->err = "MAC_KEY_GENERATE_ERROR"; - goto err; - } if (expected->type == EVP_PKEY_HMAC) { if (!TEST_ptr(md = EVP_get_digestbyname(expected->alg))) { t->err = "MAC_ALGORITHM_SET_ERROR"; -- 2.40.0