diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_asn1.c')
-rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index ae55539859..175eec5342 100644 --- a/src/lib/libcrypto/ec/ec_asn1.c +++ b/src/lib/libcrypto/ec/ec_asn1.c | |||
@@ -83,7 +83,7 @@ int EC_GROUP_get_basis_type(const EC_GROUP *group) | |||
83 | /* everything else is currently not supported */ | 83 | /* everything else is currently not supported */ |
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | 86 | #ifndef OPENSSL_NO_EC2M | |
87 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k) | 87 | int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k) |
88 | { | 88 | { |
89 | if (group == NULL) | 89 | if (group == NULL) |
@@ -101,7 +101,6 @@ int EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k) | |||
101 | 101 | ||
102 | return 1; | 102 | return 1; |
103 | } | 103 | } |
104 | |||
105 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1, | 104 | int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1, |
106 | unsigned int *k2, unsigned int *k3) | 105 | unsigned int *k2, unsigned int *k3) |
107 | { | 106 | { |
@@ -124,7 +123,7 @@ int EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1, | |||
124 | 123 | ||
125 | return 1; | 124 | return 1; |
126 | } | 125 | } |
127 | 126 | #endif | |
128 | 127 | ||
129 | 128 | ||
130 | /* some structures needed for the asn1 encoding */ | 129 | /* some structures needed for the asn1 encoding */ |
@@ -340,6 +339,12 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) | |||
340 | } | 339 | } |
341 | } | 340 | } |
342 | else /* nid == NID_X9_62_characteristic_two_field */ | 341 | else /* nid == NID_X9_62_characteristic_two_field */ |
342 | #ifdef OPENSSL_NO_EC2M | ||
343 | { | ||
344 | ECerr(EC_F_EC_ASN1_GROUP2FIELDID, EC_R_GF2M_NOT_SUPPORTED); | ||
345 | goto err; | ||
346 | } | ||
347 | #else | ||
343 | { | 348 | { |
344 | int field_type; | 349 | int field_type; |
345 | X9_62_CHARACTERISTIC_TWO *char_two; | 350 | X9_62_CHARACTERISTIC_TWO *char_two; |
@@ -419,6 +424,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) | |||
419 | } | 424 | } |
420 | } | 425 | } |
421 | } | 426 | } |
427 | #endif | ||
422 | 428 | ||
423 | ok = 1; | 429 | ok = 1; |
424 | 430 | ||
@@ -456,6 +462,7 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) | |||
456 | goto err; | 462 | goto err; |
457 | } | 463 | } |
458 | } | 464 | } |
465 | #ifndef OPENSSL_NO_EC2M | ||
459 | else /* nid == NID_X9_62_characteristic_two_field */ | 466 | else /* nid == NID_X9_62_characteristic_two_field */ |
460 | { | 467 | { |
461 | if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL)) | 468 | if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL)) |
@@ -464,7 +471,7 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) | |||
464 | goto err; | 471 | goto err; |
465 | } | 472 | } |
466 | } | 473 | } |
467 | 474 | #endif | |
468 | len_1 = (size_t)BN_num_bytes(tmp_1); | 475 | len_1 = (size_t)BN_num_bytes(tmp_1); |
469 | len_2 = (size_t)BN_num_bytes(tmp_2); | 476 | len_2 = (size_t)BN_num_bytes(tmp_2); |
470 | 477 | ||
@@ -775,8 +782,13 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params) | |||
775 | 782 | ||
776 | /* get the field parameters */ | 783 | /* get the field parameters */ |
777 | tmp = OBJ_obj2nid(params->fieldID->fieldType); | 784 | tmp = OBJ_obj2nid(params->fieldID->fieldType); |
778 | |||
779 | if (tmp == NID_X9_62_characteristic_two_field) | 785 | if (tmp == NID_X9_62_characteristic_two_field) |
786 | #ifdef OPENSSL_NO_EC2M | ||
787 | { | ||
788 | ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_GF2M_NOT_SUPPORTED); | ||
789 | goto err; | ||
790 | } | ||
791 | #else | ||
780 | { | 792 | { |
781 | X9_62_CHARACTERISTIC_TWO *char_two; | 793 | X9_62_CHARACTERISTIC_TWO *char_two; |
782 | 794 | ||
@@ -862,6 +874,7 @@ static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *params) | |||
862 | /* create the EC_GROUP structure */ | 874 | /* create the EC_GROUP structure */ |
863 | ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL); | 875 | ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL); |
864 | } | 876 | } |
877 | #endif | ||
865 | else if (tmp == NID_X9_62_prime_field) | 878 | else if (tmp == NID_X9_62_prime_field) |
866 | { | 879 | { |
867 | /* we have a curve over a prime field */ | 880 | /* we have a curve over a prime field */ |
@@ -1065,6 +1078,7 @@ EC_GROUP *d2i_ECPKParameters(EC_GROUP **a, const unsigned char **in, long len) | |||
1065 | if ((group = ec_asn1_pkparameters2group(params)) == NULL) | 1078 | if ((group = ec_asn1_pkparameters2group(params)) == NULL) |
1066 | { | 1079 | { |
1067 | ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE); | 1080 | ECerr(EC_F_D2I_ECPKPARAMETERS, EC_R_PKPARAMETERS2GROUP_FAILURE); |
1081 | ECPKPARAMETERS_free(params); | ||
1068 | return NULL; | 1082 | return NULL; |
1069 | } | 1083 | } |
1070 | 1084 | ||