diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2015-12-13 17:28:40 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2015-12-14 23:06:14 +0000 |
commit | 2986ecdc08016de978f1134315623778420b51e5 (patch) | |
tree | d553d2766381f7bd4b04b38fb7f472379d6e903c /crypto/dh | |
parent | d911097d7c93e4cfeab624b34d73fe51da158b69 (diff) | |
download | openssl-2986ecdc08016de978f1134315623778420b51e5.tar.gz |
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 <viktor@openssl.org>
Diffstat (limited to 'crypto/dh')
-rw-r--r-- | crypto/dh/dh_ameth.c | 5 |
1 files changed, 5 insertions, 0 deletions
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); } |