Extend EVP_PKEY_copy_parameters()
[openssl.git] / crypto / dh / dh_ameth.c
index 43cba87a1ecb19710da9e7aa33d29840835bf891..7a3d9235cff187410788fabf444a396119b6fc77 100644 (file)
@@ -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);
 }