summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_key.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-06-15 14:21:00 +0100
committerMatt Caswell <matt@openssl.org>2020-06-19 10:34:58 +0100
commit2da8d4eb2812e18cec5c8324a54a4c56b52563ed (patch)
tree83398242047d499554026412f2bd68a51fe7217b /crypto/ec/ec_key.c
parent48e971dd9f88933a7f77f5051a8b79b9e17892a9 (diff)
Add more complete support for libctx/propq in the EC code
Renames some "new_ex" functions to "new_with_libctx" and ensures that we pass around the libctx AND the propq everywhere. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12159)
Diffstat (limited to 'crypto/ec/ec_key.c')
-rw-r--r--crypto/ec/ec_key.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index 47feede54b..359e034ed9 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -29,21 +29,22 @@ static int ecdsa_keygen_pairwise_test(EC_KEY *eckey, OSSL_CALLBACK *cb,
#ifndef FIPS_MODULE
EC_KEY *EC_KEY_new(void)
{
- return ec_key_new_method_int(NULL, NULL);
+ return ec_key_new_method_int(NULL, NULL, NULL);
}
#endif
-EC_KEY *EC_KEY_new_ex(OPENSSL_CTX *ctx)
+EC_KEY *EC_KEY_new_with_libctx(OPENSSL_CTX *ctx, const char *propq)
{
- return ec_key_new_method_int(ctx, NULL);
+ return ec_key_new_method_int(ctx, propq, NULL);
}
-EC_KEY *EC_KEY_new_by_curve_name_ex(OPENSSL_CTX *ctx, int nid)
+EC_KEY *EC_KEY_new_by_curve_name_with_libctx(OPENSSL_CTX *ctx,
+ const char *propq, int nid)
{
- EC_KEY *ret = EC_KEY_new_ex(ctx);
+ EC_KEY *ret = EC_KEY_new_with_libctx(ctx, propq);
if (ret == NULL)
return NULL;
- ret->group = EC_GROUP_new_by_curve_name_ex(ctx, nid);
+ ret->group = EC_GROUP_new_by_curve_name_with_libctx(ctx, propq, nid);
if (ret->group == NULL) {
EC_KEY_free(ret);
return NULL;
@@ -59,7 +60,7 @@ EC_KEY *EC_KEY_new_by_curve_name_ex(OPENSSL_CTX *ctx, int nid)
#ifndef FIPS_MODULE
EC_KEY *EC_KEY_new_by_curve_name(int nid)
{
- return EC_KEY_new_by_curve_name_ex(NULL, nid);
+ return EC_KEY_new_by_curve_name_with_libctx(NULL, NULL, nid);
}
#endif
@@ -93,6 +94,7 @@ void EC_KEY_free(EC_KEY *r)
EC_GROUP_free(r->group);
EC_POINT_free(r->pub_key);
BN_clear_free(r->priv_key);
+ OPENSSL_free(r->propq);
OPENSSL_clear_free((void *)r, sizeof(EC_KEY));
}
@@ -119,7 +121,8 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
if (src->group != NULL) {
/* clear the old group */
EC_GROUP_free(dest->group);
- dest->group = ec_group_new_ex(src->libctx, src->group->meth);
+ dest->group = ec_group_new_with_libctx(src->libctx, src->propq,
+ src->group->meth);
if (dest->group == NULL)
return NULL;
if (!EC_GROUP_copy(dest->group, src->group))
@@ -180,7 +183,8 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
EC_KEY *EC_KEY_dup(const EC_KEY *ec_key)
{
- EC_KEY *ret = ec_key_new_method_int(ec_key->libctx, ec_key->engine);
+ EC_KEY *ret = ec_key_new_method_int(ec_key->libctx, ec_key->propq,
+ ec_key->engine);
if (ret == NULL)
return NULL;
@@ -631,6 +635,11 @@ OPENSSL_CTX *ec_key_get_libctx(const EC_KEY *key)
return key->libctx;
}
+const char *ec_key_get0_propq(const EC_KEY *key)
+{
+ return key->propq;
+}
+
const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
{
return key->group;