summaryrefslogtreecommitdiffstats
path: root/test/evp_test.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2018-03-05 16:22:41 +0000
committerMatt Caswell <matt@openssl.org>2018-03-15 12:47:27 +0000
commit9442c8d7636a2bb257e76d4137a5d7305dedf28f (patch)
tree445219afa7978f4bc5a78ed58f97c2c38d7e3b9e /test/evp_test.c
parentb3831fbb0bf63f77ce45e359b5031cd3f6c56fa2 (diff)
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.c30
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";