summaryrefslogtreecommitdiffstats
path: root/test/evp_libctx_test.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-03-19 18:45:43 +0100
committerPauli <pauli@openssl.org>2021-03-28 16:38:57 +1000
commit2145ba5e8383184d7f212500ec2f759bdf08503a (patch)
treea862106cc508e75f170b3105e3b5919fb38219d3 /test/evp_libctx_test.c
parentc464583483df70ad8df9907168bf015d672742bd (diff)
Implement EVP_PKEY_dup() function
Fixes #14501 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14624)
Diffstat (limited to 'test/evp_libctx_test.c')
-rw-r--r--test/evp_libctx_test.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/evp_libctx_test.c b/test/evp_libctx_test.c
index f5d652ebc0..c5cc6bb0d7 100644
--- a/test/evp_libctx_test.c
+++ b/test/evp_libctx_test.c
@@ -83,7 +83,7 @@ static int test_dsa_param_keygen(int tstid)
int expected;
EVP_PKEY_CTX *gen_ctx = NULL;
EVP_PKEY *pkey_parm = NULL;
- EVP_PKEY *pkey = NULL;
+ EVP_PKEY *pkey = NULL, *dup_pk = NULL;
DSA *dsa = NULL;
int pind, qind, gind;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
@@ -127,9 +127,17 @@ static int test_dsa_param_keygen(int tstid)
|| !TEST_int_gt(EVP_PKEY_keygen_init(gen_ctx), 0)
|| !TEST_int_eq(EVP_PKEY_keygen(gen_ctx, &pkey), expected))
goto err;
+
+ if (expected) {
+ if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pkey))
+ || !TEST_int_eq(EVP_PKEY_eq(pkey, dup_pk), 1))
+ goto err;
+ }
+
ret = 1;
err:
EVP_PKEY_free(pkey);
+ EVP_PKEY_free(dup_pk);
EVP_PKEY_CTX_free(gen_ctx);
EVP_PKEY_free(pkey_parm);
DSA_free(dsa);
@@ -147,7 +155,7 @@ static int do_dh_param_keygen(int tstid, const BIGNUM **bn)
int expected;
EVP_PKEY_CTX *gen_ctx = NULL;
EVP_PKEY *pkey_parm = NULL;
- EVP_PKEY *pkey = NULL;
+ EVP_PKEY *pkey = NULL, *dup_pk = NULL;
DH *dh = NULL;
int pind, qind, gind;
BIGNUM *p = NULL, *q = NULL, *g = NULL;
@@ -182,9 +190,17 @@ static int do_dh_param_keygen(int tstid, const BIGNUM **bn)
|| !TEST_int_gt(EVP_PKEY_keygen_init(gen_ctx), 0)
|| !TEST_int_eq(EVP_PKEY_keygen(gen_ctx, &pkey), expected))
goto err;
+
+ if (expected) {
+ if (!TEST_ptr(dup_pk = EVP_PKEY_dup(pkey))
+ || !TEST_int_eq(EVP_PKEY_eq(pkey, dup_pk), 1))
+ goto err;
+ }
+
ret = 1;
err:
EVP_PKEY_free(pkey);
+ EVP_PKEY_free(dup_pk);
EVP_PKEY_CTX_free(gen_ctx);
EVP_PKEY_free(pkey_parm);
DH_free(dh);