diff options
-rw-r--r-- | crypto/ec/ec_key.c | 10 | ||||
-rw-r--r-- | crypto/ec/ec_kmeth.c | 2 | ||||
-rw-r--r-- | crypto/ec/ec_lcl.h | 3 |
3 files changed, 14 insertions, 1 deletions
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 1b941b4844..53844ab9be 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -84,6 +84,10 @@ EC_KEY *EC_KEY_new_by_curve_name(int nid) EC_KEY_free(ret); return NULL; } + if (ret->meth->set_group && ret->meth->set_group(ret, ret->group) == 0) { + EC_KEY_free(ret); + return NULL; + } return ret; } @@ -449,6 +453,8 @@ const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key) int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group) { + if (key->meth->set_group && key->meth->set_group(key, group) == 0) + return 0; EC_GROUP_free(key->group); key->group = EC_GROUP_dup(group); return (key->group == NULL) ? 0 : 1; @@ -461,6 +467,8 @@ const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key) int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key) { + if (key->meth->set_private && key->meth->set_private(key, priv_key) == 0) + return 0; BN_clear_free(key->priv_key); key->priv_key = BN_dup(priv_key); return (key->priv_key == NULL) ? 0 : 1; @@ -473,6 +481,8 @@ const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key) int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key) { + if (key->meth->set_public && key->meth->set_public(key, pub_key) == 0) + return 0; EC_POINT_free(key->pub_key); key->pub_key = EC_POINT_dup(pub_key, key->group); return (key->pub_key == NULL) ? 0 : 1; diff --git a/crypto/ec/ec_kmeth.c b/crypto/ec/ec_kmeth.c index 4581880b84..767e51f73e 100644 --- a/crypto/ec/ec_kmeth.c +++ b/crypto/ec/ec_kmeth.c @@ -63,7 +63,7 @@ static const EC_KEY_METHOD openssl_ec_key_method = { "OpenSSL EC_KEY method", 0, - 0,0,0, + 0,0,0,0,0,0, ossl_ec_key_gen, ossl_ecdh_compute_key }; diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h index 2db8779c57..57fd6ce284 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_lcl.h @@ -563,6 +563,9 @@ struct ec_key_method_st { int (*init)(EC_KEY *key); void (*finish)(EC_KEY *key); int (*copy)(EC_KEY *dest, const EC_KEY *src); + int (*set_group)(EC_KEY *key, const EC_GROUP *grp); + int (*set_private)(EC_KEY *key, const BIGNUM *priv_key); + int (*set_public)(EC_KEY *key, const EC_POINT *pub_key); int (*keygen)(EC_KEY *key); int (*compute_key)(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, |