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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user