diff options
-rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 98eec5134a..faca6059e4 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.109 2024/12/06 05:13:35 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.110 2025/01/25 10:27:58 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -651,36 +651,16 @@ ec_point_to_asn1_octet_string(const EC_GROUP *group, const EC_POINT *point, | |||
651 | static int | 651 | static int |
652 | ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) | 652 | ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) |
653 | { | 653 | { |
654 | BIGNUM *p = NULL; | ||
655 | int nid; | ||
656 | int ret = 0; | 654 | int ret = 0; |
657 | 655 | ||
658 | if (group == NULL || field == NULL) | 656 | if (group == NULL || field == NULL) |
659 | goto err; | 657 | goto err; |
660 | 658 | ||
661 | nid = ec_group_get_field_type(group); | 659 | if ((field->fieldType = OBJ_nid2obj(NID_X9_62_prime_field)) == NULL) { |
662 | if (nid == NID_X9_62_characteristic_two_field) { | ||
663 | ECerror(EC_R_GF2M_NOT_SUPPORTED); | ||
664 | goto err; | ||
665 | } | ||
666 | if (nid != NID_X9_62_prime_field) { | ||
667 | ECerror(EC_R_INVALID_FIELD); | ||
668 | goto err; | ||
669 | } | ||
670 | |||
671 | if ((field->fieldType = OBJ_nid2obj(nid)) == NULL) { | ||
672 | ECerror(ERR_R_OBJ_LIB); | 660 | ECerror(ERR_R_OBJ_LIB); |
673 | goto err; | 661 | goto err; |
674 | } | 662 | } |
675 | if ((p = BN_new()) == NULL) { | 663 | if ((field->p.prime = BN_to_ASN1_INTEGER(group->p, NULL)) == NULL) { |
676 | ECerror(ERR_R_MALLOC_FAILURE); | ||
677 | goto err; | ||
678 | } | ||
679 | if (!EC_GROUP_get_curve(group, p, NULL, NULL, NULL)) { | ||
680 | ECerror(ERR_R_EC_LIB); | ||
681 | goto err; | ||
682 | } | ||
683 | if ((field->p.prime = BN_to_ASN1_INTEGER(p, NULL)) == NULL) { | ||
684 | ECerror(ERR_R_ASN1_LIB); | 664 | ECerror(ERR_R_ASN1_LIB); |
685 | goto err; | 665 | goto err; |
686 | } | 666 | } |
@@ -688,8 +668,6 @@ ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) | |||
688 | ret = 1; | 668 | ret = 1; |
689 | 669 | ||
690 | err: | 670 | err: |
691 | BN_free(p); | ||
692 | |||
693 | return ret; | 671 | return ret; |
694 | } | 672 | } |
695 | 673 | ||