|
|
@@ -170,35 +170,27 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) { |
|
|
|
OPENSSL_PUT_ERROR(EC, EC_KEY_copy, ERR_R_PASSED_NULL_PARAMETER); |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
/* copy the parameters */ |
|
|
|
/* Copy the parameters. */ |
|
|
|
if (src->group) { |
|
|
|
/* TODO(fork): duplicating the group seems wasteful. */ |
|
|
|
const EC_METHOD *meth = src->group->meth; |
|
|
|
/* clear the old group */ |
|
|
|
if (dest->group) { |
|
|
|
EC_GROUP_free(dest->group); |
|
|
|
} |
|
|
|
dest->group = ec_group_new(meth); |
|
|
|
dest->group = EC_GROUP_dup(src->group); |
|
|
|
if (dest->group == NULL) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
if (!EC_GROUP_copy(dest->group, src->group)) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* copy the public key */ |
|
|
|
/* Copy the public key. */ |
|
|
|
if (src->pub_key && src->group) { |
|
|
|
if (dest->pub_key) { |
|
|
|
EC_POINT_free(dest->pub_key); |
|
|
|
} |
|
|
|
dest->pub_key = EC_POINT_new(src->group); |
|
|
|
dest->pub_key = EC_POINT_dup(src->pub_key, src->group); |
|
|
|
if (dest->pub_key == NULL) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
if (!EC_POINT_copy(dest->pub_key, src->pub_key)) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* copy the private key */ |
|
|
|