提交 ea0392b9 编写于 作者: D Dr. Stephen Henson

EC_KEY_METHOD copy support

Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 0d6ff6d3
......@@ -132,6 +132,15 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
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);
......@@ -182,12 +191,24 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
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) {
......
......@@ -63,7 +63,7 @@
static const EC_KEY_METHOD openssl_ec_key_method = {
"OpenSSL EC_KEY method",
0,
0,0,
0,0,0,
ossl_ec_key_gen,
ossl_ecdh_compute_key
};
......
......@@ -562,6 +562,7 @@ struct ec_key_method_st {
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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册