aboutsummaryrefslogtreecommitdiff
path: root/crypto/dsa
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-12-13 17:28:40 +0000
committerDr. Stephen Henson <steve@openssl.org>2015-12-14 23:06:14 +0000
commit2986ecdc08016de978f1134315623778420b51e5 (patch)
treed553d2766381f7bd4b04b38fb7f472379d6e903c /crypto/dsa
parentd911097d7c93e4cfeab624b34d73fe51da158b69 (diff)
downloadopenssl-2986ecdc08016de978f1134315623778420b51e5.zip
openssl-2986ecdc08016de978f1134315623778420b51e5.tar.gz
openssl-2986ecdc08016de978f1134315623778420b51e5.tar.bz2
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/dsa')
-rw-r--r--crypto/dsa/dsa_ameth.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c
index d1d32c6..92976bc3 100644
--- a/crypto/dsa/dsa_ameth.c
+++ b/crypto/dsa/dsa_ameth.c
@@ -364,6 +364,12 @@ static int dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
{
BIGNUM *a;
+ if (to->pkey.dsa == NULL) {
+ to->pkey.dsa = DSA_new();
+ if (to->pkey.dsa == NULL)
+ return 0;
+ }
+
if ((a = BN_dup(from->pkey.dsa->p)) == NULL)
return 0;
BN_free(to->pkey.dsa->p);