diff options
Diffstat (limited to 'src/lib/libcrypto/ec')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 147061b5c3..0d5d761261 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.61 2024/10/11 06:21:30 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.62 2024/10/11 18:18:10 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -789,39 +789,37 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 789 | ECPKPARAMETERS * | 789 | ECPKPARAMETERS * |
| 790 | ec_asn1_group2pkparameters(const EC_GROUP *group) | 790 | ec_asn1_group2pkparameters(const EC_GROUP *group) |
| 791 | { | 791 | { |
| 792 | int ok = 1, tmp; | 792 | ECPKPARAMETERS *pkparameters; |
| 793 | ECPKPARAMETERS *ret; | 793 | ECPARAMETERS *parameters; |
| 794 | ASN1_OBJECT *aobj; | ||
| 795 | int nid; | ||
| 794 | 796 | ||
| 795 | if ((ret = ECPKPARAMETERS_new()) == NULL) { | 797 | if ((pkparameters = ECPKPARAMETERS_new()) == NULL) { |
| 796 | ECerror(ERR_R_MALLOC_FAILURE); | 798 | ECerror(ERR_R_MALLOC_FAILURE); |
| 797 | return NULL; | 799 | goto err; |
| 798 | } | 800 | } |
| 799 | 801 | ||
| 800 | if (EC_GROUP_get_asn1_flag(group)) { | 802 | if (EC_GROUP_get_asn1_flag(group) != 0) { |
| 801 | /* | 803 | if ((nid = EC_GROUP_get_curve_name(group)) == NID_undef) |
| 802 | * use the asn1 OID to describe the elliptic curve | 804 | goto err; |
| 803 | * parameters | 805 | if ((aobj = OBJ_nid2obj(nid)) == NULL) |
| 804 | */ | 806 | goto err; |
| 805 | tmp = EC_GROUP_get_curve_name(group); | 807 | pkparameters->type = 0; |
| 806 | if (tmp) { | 808 | pkparameters->value.named_curve = aobj; |
| 807 | ret->type = 0; | ||
| 808 | if ((ret->value.named_curve = OBJ_nid2obj(tmp)) == NULL) | ||
| 809 | ok = 0; | ||
| 810 | } else | ||
| 811 | /* we don't know the group => ERROR */ | ||
| 812 | ok = 0; | ||
| 813 | } else { | 809 | } else { |
| 814 | /* use the ECPARAMETERS structure */ | 810 | if ((parameters = ec_asn1_group2parameters(group)) == NULL) |
| 815 | ret->type = 1; | 811 | goto err; |
| 816 | if ((ret->value.parameters = ec_asn1_group2parameters(group)) == NULL) | 812 | pkparameters->type = 1; |
| 817 | ok = 0; | 813 | pkparameters->value.parameters = parameters; |
| 814 | parameters = NULL; | ||
| 818 | } | 815 | } |
| 819 | 816 | ||
| 820 | if (!ok) { | 817 | return pkparameters; |
| 821 | ECPKPARAMETERS_free(ret); | 818 | |
| 822 | return NULL; | 819 | err: |
| 823 | } | 820 | ECPKPARAMETERS_free(pkparameters); |
| 824 | return ret; | 821 | |
| 822 | return NULL; | ||
| 825 | } | 823 | } |
| 826 | 824 | ||
| 827 | static EC_GROUP * | 825 | static EC_GROUP * |
