Add EC_GROUP_order_bits, EC_GROUP_get0_order and EC_GROUP_get0_cofactor
[openssl.git] / crypto / ec / ec_key.c
index 970aeca63b43cf7d847c760a8e6f93dc199625c6..a5c60f680fad358a2c2a0fbee4ea57413d4d2d5c 100644 (file)
@@ -241,11 +241,10 @@ int ossl_ec_key_gen(EC_KEY *eckey)
 {
     int ok = 0;
     BN_CTX *ctx = NULL;
 {
     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;
 
     EC_POINT *pub_key = NULL;
 
-    if ((order = BN_new()) == NULL)
-        goto err;
     if ((ctx = BN_CTX_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;
 
     } 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
         goto err;
 
     do
@@ -280,7 +280,6 @@ int ossl_ec_key_gen(EC_KEY *eckey)
     ok = 1;
 
  err:
     ok = 1;
 
  err:
-    BN_free(order);
     if (eckey->pub_key == NULL)
         EC_POINT_free(pub_key);
     if (eckey->priv_key != priv_key)
     if (eckey->pub_key == NULL)
         EC_POINT_free(pub_key);
     if (eckey->priv_key != priv_key)