diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_ameth.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c index 45f51e9dd8..8676ace9d8 100644 --- a/src/lib/libcrypto/ec/ec_ameth.c +++ b/src/lib/libcrypto/ec/ec_ameth.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_ameth.c,v 1.39 2023/07/01 08:15:31 tb Exp $ */ | 1 | /* $OpenBSD: ec_ameth.c,v 1.40 2023/07/03 09:25:44 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -367,23 +367,12 @@ int_ec_size(const EVP_PKEY *pkey) | |||
| 367 | static int | 367 | static int |
| 368 | ec_bits(const EVP_PKEY *pkey) | 368 | ec_bits(const EVP_PKEY *pkey) |
| 369 | { | 369 | { |
| 370 | BIGNUM *order = BN_new(); | ||
| 371 | const EC_GROUP *group; | 370 | const EC_GROUP *group; |
| 372 | int ret; | ||
| 373 | 371 | ||
| 374 | if (!order) { | 372 | if ((group = EC_KEY_get0_group(pkey->pkey.ec)) == NULL) |
| 375 | ERR_clear_error(); | ||
| 376 | return 0; | 373 | return 0; |
| 377 | } | 374 | |
| 378 | group = EC_KEY_get0_group(pkey->pkey.ec); | 375 | return EC_GROUP_order_bits(group); |
| 379 | if (!EC_GROUP_get_order(group, order, NULL)) { | ||
| 380 | BN_free(order); | ||
| 381 | ERR_clear_error(); | ||
| 382 | return 0; | ||
| 383 | } | ||
| 384 | ret = BN_num_bits(order); | ||
| 385 | BN_free(order); | ||
| 386 | return ret; | ||
| 387 | } | 376 | } |
| 388 | 377 | ||
| 389 | static int | 378 | static int |
| @@ -442,7 +431,7 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) | |||
| 442 | const char *ecstr; | 431 | const char *ecstr; |
| 443 | size_t buf_len = 0, i; | 432 | size_t buf_len = 0, i; |
| 444 | int ret = 0, reason = ERR_R_BIO_LIB; | 433 | int ret = 0, reason = ERR_R_BIO_LIB; |
| 445 | BIGNUM *pub_key = NULL, *order = NULL; | 434 | BIGNUM *pub_key = NULL; |
| 446 | BN_CTX *ctx = NULL; | 435 | BN_CTX *ctx = NULL; |
| 447 | const EC_GROUP *group; | 436 | const EC_GROUP *group; |
| 448 | const EC_POINT *public_key; | 437 | const EC_POINT *public_key; |
| @@ -492,12 +481,8 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) | |||
| 492 | 481 | ||
| 493 | if (!BIO_indent(bp, off, 128)) | 482 | if (!BIO_indent(bp, off, 128)) |
| 494 | goto err; | 483 | goto err; |
| 495 | if ((order = BN_new()) == NULL) | ||
| 496 | goto err; | ||
| 497 | if (!EC_GROUP_get_order(group, order, NULL)) | ||
| 498 | goto err; | ||
| 499 | if (BIO_printf(bp, "%s: (%d bit)\n", ecstr, | 484 | if (BIO_printf(bp, "%s: (%d bit)\n", ecstr, |
| 500 | BN_num_bits(order)) <= 0) | 485 | EC_GROUP_order_bits(group)) <= 0) |
| 501 | goto err; | 486 | goto err; |
| 502 | 487 | ||
| 503 | if (!ASN1_bn_print(bp, "priv:", priv_key, buffer, off)) | 488 | if (!ASN1_bn_print(bp, "priv:", priv_key, buffer, off)) |
| @@ -511,7 +496,6 @@ do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) | |||
| 511 | if (!ret) | 496 | if (!ret) |
| 512 | ECerror(reason); | 497 | ECerror(reason); |
| 513 | BN_free(pub_key); | 498 | BN_free(pub_key); |
| 514 | BN_free(order); | ||
| 515 | BN_CTX_free(ctx); | 499 | BN_CTX_free(ctx); |
| 516 | free(buffer); | 500 | free(buffer); |
| 517 | return (ret); | 501 | return (ret); |
