From 2986ecdc08016de978f1134315623778420b51e5 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 13 Dec 2015 17:28:40 +0000 Subject: Extend EVP_PKEY_copy_parameters() Make EVP_PKEY_copy_parameters() work if the destination has no type (e.g. if obtained from EVP_PKEY_new()) or the underlying key is NULL. This is useful where we want to copy the parameters from an existing key to a new key. Reviewed-by: Viktor Dukhovni --- crypto/dh/dh_ameth.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crypto/dh') diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c index 43cba87a1e..7a3d9235cf 100644 --- a/crypto/dh/dh_ameth.c +++ b/crypto/dh/dh_ameth.c @@ -507,6 +507,11 @@ DH *DHparams_dup(DH *dh) static int dh_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) { + if (to->pkey.dh == NULL) { + to->pkey.dh = DH_new(); + if (to->pkey.dh == NULL) + return 0; + } return int_dh_param_copy(to->pkey.dh, from->pkey.dh, from->ameth == &dhx_asn1_meth); } -- cgit v1.2.3