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/ec/ec_ameth.c | |
parent | d911097d7c93e4cfeab624b34d73fe51da158b69 (diff) |
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/ec/ec_ameth.c')
-rw-r--r-- | crypto/ec/ec_ameth.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 19932d541c..fb07262466 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -402,6 +402,11 @@ static int ec_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) EC_GROUP *group = EC_GROUP_dup(EC_KEY_get0_group(from->pkey.ec)); if (group == NULL) return 0; + if (to->pkey.ec == NULL) { + to->pkey.ec = EC_KEY_new(); + if (to->pkey.ec == NULL) + return 0; + } if (EC_KEY_set_group(to->pkey.ec, group) == 0) return 0; EC_GROUP_free(group); |