ECerr(EC_F_EC_KEY_COPY, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
+ if (src->meth != dest->meth) {
+ if (dest->meth->finish)
+ dest->meth->finish(dest);
+#ifndef OPENSSL_NO_ENGINE
+ if (dest->engine && ENGINE_finish(dest->engine) == 0)
+ return 0;
+ dest->engine = NULL;
+#endif
+ }
/* copy the parameters */
if (src->group) {
const EC_METHOD *meth = EC_GROUP_method_of(src->group);
dest->version = src->version;
dest->flags = src->flags;
+ if (src->meth != dest->meth) {
+#ifndef OPENSSL_NO_ENGINE
+ if (src->engine && ENGINE_init(src->engine) == 0)
+ return 0;
+ dest->engine = src->engine;
+#endif
+ dest->meth = src->meth;
+ }
+
+ if (src->meth->copy && src->meth->copy(dest, src) == 0)
+ return 0;
+
return dest;
}
EC_KEY *EC_KEY_dup(const EC_KEY *ec_key)
{
- EC_KEY *ret = EC_KEY_new();
+ EC_KEY *ret = EC_KEY_new_method(ec_key->engine);
if (ret == NULL)
return NULL;
if (EC_KEY_copy(ret, ec_key) == NULL) {
int32_t flags;
int (*init)(EC_KEY *key);
void (*finish)(EC_KEY *key);
+ int (*copy)(EC_KEY *dest, const EC_KEY *src);
int (*keygen)(EC_KEY *key);
int (*compute_key)(void *out, size_t outlen, const EC_POINT *pub_key,
EC_KEY *ecdh,