diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 5da4d116c3..0a488cac66 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.98 2024/10/30 06:41:33 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.99 2024/10/30 06:44:34 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -773,7 +773,6 @@ ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) | |||
| 773 | static ECPARAMETERS * | 773 | static ECPARAMETERS * |
| 774 | ec_asn1_group2parameters(const EC_GROUP *group) | 774 | ec_asn1_group2parameters(const EC_GROUP *group) |
| 775 | { | 775 | { |
| 776 | int ok = 0; | ||
| 777 | ECPARAMETERS *parameters = NULL; | 776 | ECPARAMETERS *parameters = NULL; |
| 778 | const EC_POINT *generator = NULL; | 777 | const EC_POINT *generator = NULL; |
| 779 | const BIGNUM *order, *cofactor; | 778 | const BIGNUM *order, *cofactor; |
| @@ -784,20 +783,18 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 784 | goto err; | 783 | goto err; |
| 785 | } | 784 | } |
| 786 | 785 | ||
| 787 | /* set the version (always one) */ | 786 | parameters->version = 0x1; |
| 788 | parameters->version = (long) 0x1; | ||
| 789 | 787 | ||
| 790 | /* set the fieldID */ | ||
| 791 | if (!ec_asn1_group2fieldid(group, parameters->fieldID)) { | 788 | if (!ec_asn1_group2fieldid(group, parameters->fieldID)) { |
| 792 | ECerror(ERR_R_EC_LIB); | 789 | ECerror(ERR_R_EC_LIB); |
| 793 | goto err; | 790 | goto err; |
| 794 | } | 791 | } |
| 795 | /* set the curve */ | 792 | |
| 796 | if (!ec_asn1_group2curve(group, parameters->curve)) { | 793 | if (!ec_asn1_group2curve(group, parameters->curve)) { |
| 797 | ECerror(ERR_R_EC_LIB); | 794 | ECerror(ERR_R_EC_LIB); |
| 798 | goto err; | 795 | goto err; |
| 799 | } | 796 | } |
| 800 | /* set the base point */ | 797 | |
| 801 | if ((generator = EC_GROUP_get0_generator(group)) == NULL) { | 798 | if ((generator = EC_GROUP_get0_generator(group)) == NULL) { |
| 802 | ECerror(EC_R_UNDEFINED_GENERATOR); | 799 | ECerror(EC_R_UNDEFINED_GENERATOR); |
| 803 | goto err; | 800 | goto err; |
| @@ -820,6 +817,7 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 820 | ECerror(ERR_R_ASN1_LIB); | 817 | ECerror(ERR_R_ASN1_LIB); |
| 821 | goto err; | 818 | goto err; |
| 822 | } | 819 | } |
| 820 | |||
| 823 | ASN1_INTEGER_free(parameters->cofactor); | 821 | ASN1_INTEGER_free(parameters->cofactor); |
| 824 | parameters->cofactor = NULL; | 822 | parameters->cofactor = NULL; |
| 825 | if ((cofactor = EC_GROUP_get0_cofactor(group)) == NULL) { | 823 | if ((cofactor = EC_GROUP_get0_cofactor(group)) == NULL) { |
| @@ -827,19 +825,19 @@ ec_asn1_group2parameters(const EC_GROUP *group) | |||
| 827 | goto err; | 825 | goto err; |
| 828 | } | 826 | } |
| 829 | if (!BN_is_zero(cofactor)) { | 827 | if (!BN_is_zero(cofactor)) { |
| 830 | if ((parameters->cofactor = BN_to_ASN1_INTEGER(cofactor, NULL)) == NULL) { | 828 | if ((parameters->cofactor = BN_to_ASN1_INTEGER(cofactor, |
| 829 | NULL)) == NULL) { | ||
| 831 | ECerror(ERR_R_ASN1_LIB); | 830 | ECerror(ERR_R_ASN1_LIB); |
| 832 | goto err; | 831 | goto err; |
| 833 | } | 832 | } |
| 834 | } | 833 | } |
| 835 | ok = 1; | 834 | |
| 835 | return parameters; | ||
| 836 | 836 | ||
| 837 | err: | 837 | err: |
| 838 | if (!ok) { | 838 | ECPARAMETERS_free(parameters); |
| 839 | ECPARAMETERS_free(parameters); | 839 | |
| 840 | parameters = NULL; | 840 | return NULL; |
| 841 | } | ||
| 842 | return (parameters); | ||
| 843 | } | 841 | } |
| 844 | 842 | ||
| 845 | static ECPKPARAMETERS * | 843 | static ECPKPARAMETERS * |
