-/* $OpenBSD: ec_ameth.c,v 1.39 2023/07/01 08:15:31 tb Exp $ */
+/* $OpenBSD: ec_ameth.c,v 1.40 2023/07/03 09:25:44 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
static int
ec_bits(const EVP_PKEY *pkey)
{
- BIGNUM *order = BN_new();
const EC_GROUP *group;
- int ret;
- if (!order) {
- ERR_clear_error();
+ if ((group = EC_KEY_get0_group(pkey->pkey.ec)) == NULL)
return 0;
- }
- group = EC_KEY_get0_group(pkey->pkey.ec);
- if (!EC_GROUP_get_order(group, order, NULL)) {
- BN_free(order);
- ERR_clear_error();
- return 0;
- }
- ret = BN_num_bits(order);
- BN_free(order);
- return ret;
+
+ return EC_GROUP_order_bits(group);
}
static int
const char *ecstr;
size_t buf_len = 0, i;
int ret = 0, reason = ERR_R_BIO_LIB;
- BIGNUM *pub_key = NULL, *order = NULL;
+ BIGNUM *pub_key = NULL;
BN_CTX *ctx = NULL;
const EC_GROUP *group;
const EC_POINT *public_key;
if (!BIO_indent(bp, off, 128))
goto err;
- if ((order = BN_new()) == NULL)
- goto err;
- if (!EC_GROUP_get_order(group, order, NULL))
- goto err;
if (BIO_printf(bp, "%s: (%d bit)\n", ecstr,
- BN_num_bits(order)) <= 0)
+ EC_GROUP_order_bits(group)) <= 0)
goto err;
if (!ASN1_bn_print(bp, "priv:", priv_key, buffer, off))
if (!ret)
ECerror(reason);
BN_free(pub_key);
- BN_free(order);
BN_CTX_free(ctx);
free(buffer);
return (ret);