diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 0fe187aeb1..02609606ff 100644 --- a/src/lib/libcrypto/ec/ec_asn1.c +++ b/src/lib/libcrypto/ec/ec_asn1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_asn1.c,v 1.72 2024/10/14 18:17:11 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.73 2024/10/15 06:35:59 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -695,15 +695,11 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 695 | int ok = 0; | 695 | int ok = 0; |
| 696 | size_t len = 0; | 696 | size_t len = 0; |
| 697 | ECPARAMETERS *ret = NULL; | 697 | ECPARAMETERS *ret = NULL; |
| 698 | BIGNUM *tmp = NULL; | 698 | const BIGNUM *order, *cofactor; |
| 699 | unsigned char *buffer = NULL; | 699 | unsigned char *buffer = NULL; |
| 700 | const EC_POINT *point = NULL; | 700 | const EC_POINT *point = NULL; |
| 701 | point_conversion_form_t form; | 701 | point_conversion_form_t form; |
| 702 | 702 | ||
| 703 | if ((tmp = BN_new()) == NULL) { | ||
| 704 | ECerror(ERR_R_MALLOC_FAILURE); | ||
| 705 | goto err; | ||
| 706 | } | ||
| 707 | if ((ret = ECPARAMETERS_new()) == NULL) { | 703 | if ((ret = ECPARAMETERS_new()) == NULL) { |
| 708 | ECerror(ERR_R_MALLOC_FAILURE); | 704 | ECerror(ERR_R_MALLOC_FAILURE); |
| 709 | goto err; | 705 | goto err; |
| @@ -750,19 +746,27 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 750 | ECerror(ERR_R_ASN1_LIB); | 746 | ECerror(ERR_R_ASN1_LIB); |
| 751 | goto err; | 747 | goto err; |
| 752 | } | 748 | } |
| 753 | if (!EC_GROUP_get_order(group, tmp, NULL)) { | 749 | if ((order = EC_GROUP_get0_order(group)) == NULL) { |
| 750 | ECerror(ERR_R_EC_LIB); | ||
| 751 | goto err; | ||
| 752 | } | ||
| 753 | if (BN_is_zero(order)) { | ||
| 754 | ECerror(ERR_R_EC_LIB); | 754 | ECerror(ERR_R_EC_LIB); |
| 755 | goto err; | 755 | goto err; |
| 756 | } | 756 | } |
| 757 | ASN1_INTEGER_free(ret->order); | 757 | ASN1_INTEGER_free(ret->order); |
| 758 | if ((ret->order = BN_to_ASN1_INTEGER(tmp, NULL)) == NULL) { | 758 | if ((ret->order = BN_to_ASN1_INTEGER(order, NULL)) == NULL) { |
| 759 | ECerror(ERR_R_ASN1_LIB); | 759 | ECerror(ERR_R_ASN1_LIB); |
| 760 | goto err; | 760 | goto err; |
| 761 | } | 761 | } |
| 762 | ASN1_INTEGER_free(ret->cofactor); | 762 | ASN1_INTEGER_free(ret->cofactor); |
| 763 | ret->cofactor = NULL; | 763 | ret->cofactor = NULL; |
| 764 | if (EC_GROUP_get_cofactor(group, tmp, NULL)) { | 764 | if ((cofactor = EC_GROUP_get0_cofactor(group)) == NULL) { |
| 765 | if ((ret->cofactor = BN_to_ASN1_INTEGER(tmp, NULL)) == NULL) { | 765 | ECerror(ERR_R_EC_LIB); |
| 766 | goto err; | ||
| 767 | } | ||
| 768 | if (!BN_is_zero(cofactor)) { | ||
| 769 | if ((ret->cofactor = BN_to_ASN1_INTEGER(cofactor, NULL)) == NULL) { | ||
| 766 | ECerror(ERR_R_ASN1_LIB); | 770 | ECerror(ERR_R_ASN1_LIB); |
| 767 | goto err; | 771 | goto err; |
| 768 | } | 772 | } |
| @@ -774,7 +778,6 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 774 | ECPARAMETERS_free(ret); | 778 | ECPARAMETERS_free(ret); |
| 775 | ret = NULL; | 779 | ret = NULL; |
| 776 | } | 780 | } |
| 777 | BN_free(tmp); | ||
| 778 | free(buffer); | 781 | free(buffer); |
| 779 | return (ret); | 782 | return (ret); |
| 780 | } | 783 | } |
