From be2e334fce734e726a4085701bc3cbbaabf9d893 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 31 Jan 2016 16:34:07 +0000 Subject: 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 --- crypto/ec/ec_key.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'crypto/ec/ec_key.c') 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) -- cgit v1.2.3