diff options
author | Matt Caswell <matt@openssl.org> | 2018-03-05 17:22:41 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-03-15 13:47:27 +0100 |
commit | 9442c8d7636a2bb257e76d4137a5d7305dedf28f (patch) | |
tree | 445219afa7978f4bc5a78ed58f97c2c38d7e3b9e /test/evp_test.c | |
parent | Add the function EVP_PKEY_new_CMAC_key() (diff) | |
download | openssl-9442c8d7636a2bb257e76d4137a5d7305dedf28f.tar.xz openssl-9442c8d7636a2bb257e76d4137a5d7305dedf28f.zip |
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 <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5520)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 30 |
1 files 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"; |