diff options
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index d471d2dff4..61216df26f 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.59 2024/10/11 06:18:40 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.60 2024/10/11 06:19:52 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -791,21 +791,14 @@ ec_asn1_group2parameters(const EC_GROUP *group, ECPARAMETERS *param) | |||
| 791 | } | 791 | } |
| 792 | 792 | ||
| 793 | ECPKPARAMETERS * | 793 | ECPKPARAMETERS * |
| 794 | ec_asn1_group2pkparameters(const EC_GROUP *group, ECPKPARAMETERS *params) | 794 | ec_asn1_group2pkparameters(const EC_GROUP *group) |
| 795 | { | 795 | { |
| 796 | int ok = 1, tmp; | 796 | int ok = 1, tmp; |
| 797 | ECPKPARAMETERS *ret = params; | 797 | ECPKPARAMETERS *ret; |
| 798 | 798 | ||
| 799 | if (ret == NULL) { | 799 | if ((ret = ECPKPARAMETERS_new()) == NULL) { |
| 800 | if ((ret = ECPKPARAMETERS_new()) == NULL) { | 800 | ECerror(ERR_R_MALLOC_FAILURE); |
| 801 | ECerror(ERR_R_MALLOC_FAILURE); | 801 | return NULL; |
| 802 | return NULL; | ||
| 803 | } | ||
| 804 | } else { | ||
| 805 | if (ret->type == 0 && ret->value.named_curve) | ||
| 806 | ASN1_OBJECT_free(ret->value.named_curve); | ||
| 807 | else if (ret->type == 1 && ret->value.parameters) | ||
| 808 | ECPARAMETERS_free(ret->value.parameters); | ||
| 809 | } | 802 | } |
| 810 | 803 | ||
| 811 | if (EC_GROUP_get_asn1_flag(group)) { | 804 | if (EC_GROUP_get_asn1_flag(group)) { |
| @@ -1039,7 +1032,7 @@ i2d_ECPKParameters(const EC_GROUP *group, unsigned char **out_der) | |||
| 1039 | ECPKPARAMETERS *parameters; | 1032 | ECPKPARAMETERS *parameters; |
| 1040 | int ret = 0; | 1033 | int ret = 0; |
| 1041 | 1034 | ||
| 1042 | if ((parameters = ec_asn1_group2pkparameters(group, NULL)) == NULL) { | 1035 | if ((parameters = ec_asn1_group2pkparameters(group)) == NULL) { |
| 1043 | ECerror(EC_R_GROUP2PKPARAMETERS_FAILURE); | 1036 | ECerror(EC_R_GROUP2PKPARAMETERS_FAILURE); |
| 1044 | goto err; | 1037 | goto err; |
| 1045 | } | 1038 | } |
| @@ -1184,7 +1177,7 @@ i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) | |||
| 1184 | if (!(a->enc_flag & EC_PKEY_NO_PARAMETERS)) { | 1177 | if (!(a->enc_flag & EC_PKEY_NO_PARAMETERS)) { |
| 1185 | ECPKPARAMETERS *parameters; | 1178 | ECPKPARAMETERS *parameters; |
| 1186 | 1179 | ||
| 1187 | if ((parameters = ec_asn1_group2pkparameters(a->group, NULL)) == NULL) { | 1180 | if ((parameters = ec_asn1_group2pkparameters(a->group)) == NULL) { |
| 1188 | ECerror(ERR_R_EC_LIB); | 1181 | ECerror(ERR_R_EC_LIB); |
| 1189 | goto err; | 1182 | goto err; |
| 1190 | } | 1183 | } |
