summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_key.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2016-01-31 16:34:07 +0000
committerDr. Stephen Henson <steve@openssl.org>2016-01-31 22:18:30 +0000
commitbe2e334fce734e726a4085701bc3cbbaabf9d893 (patch)
tree1abe68a660b992e194fdb26dd42aed6860d3e87a /crypto/ec/ec_key.c
parent81e03785f718f98861a2a84b7b5d798b00df1670 (diff)
Add EC_GROUP_order_bits, EC_GROUP_get0_order and EC_GROUP_get0_cofactor
New functions to return internal pointer for order and cofactor. This avoids the need to allocate a new BIGNUM which to copy the value to. Simplify code to use new functions. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/ec/ec_key.c')
-rw-r--r--crypto/ec/ec_key.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index 970aeca63b..a5c60f680f 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -241,11 +241,10 @@ int ossl_ec_key_gen(EC_KEY *eckey)
{
int ok = 0;
BN_CTX *ctx = NULL;
- BIGNUM *priv_key = NULL, *order = NULL;
+ BIGNUM *priv_key = NULL;
+ const BIGNUM *order = NULL;
EC_POINT *pub_key = NULL;
- if ((order = BN_new()) == NULL)
- goto err;
if ((ctx = BN_CTX_new()) == NULL)
goto err;
@@ -256,7 +255,8 @@ int ossl_ec_key_gen(EC_KEY *eckey)
} else
priv_key = eckey->priv_key;
- if (!EC_GROUP_get_order(eckey->group, order, ctx))
+ order = EC_GROUP_get0_order(eckey->group);
+ if (order == NULL)
goto err;
do
@@ -280,7 +280,6 @@ int ossl_ec_key_gen(EC_KEY *eckey)
ok = 1;
err:
- BN_free(order);
if (eckey->pub_key == NULL)
EC_POINT_free(pub_key);
if (eckey->priv_key != priv_key)