diff options
-rw-r--r-- | crypto/ec/ec.h | 13 | ||||
-rw-r--r-- | crypto/ec/ec_asn1.c | 42 | ||||
-rw-r--r-- | crypto/ec/ec_lcl.h | 5 | ||||
-rw-r--r-- | crypto/ec/ec_lib.c | 39 |
4 files changed, 54 insertions, 45 deletions
diff --git a/crypto/ec/ec.h b/crypto/ec/ec.h index 51cc3f8c08..e401eb739c 100644 --- a/crypto/ec/ec.h +++ b/crypto/ec/ec.h @@ -191,12 +191,6 @@ const char *EC_GROUP_get0_comment(int nid); * with the given index i from the internal curve list */ int ec_group_index2nid(int i); -/* EC_GROUP_get_basis_type() returns the NID of the basis type - * used to represent the field elements (in case of a pentanomial or trinomial - * basis the coefficient are returned in the k? arguments) */ -int EC_GROUP_get_basis_type(const EC_GROUP *, unsigned int *k1, - unsigned int *k2, unsigned int *k3); - /* EC_POINT functions */ @@ -261,6 +255,13 @@ int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); /* ASN1 stuff */ + +/* EC_GROUP_get_basis_type() returns the NID of the basis type + * used to represent the field elements (in case of a pentanomial or trinomial + * basis the coefficient are returned in the k? arguments) */ +int EC_GROUP_get_basis_type(const EC_GROUP *, unsigned int *k1, + unsigned int *k2, unsigned int *k3); + #define OPENSSL_EC_NAMED_CURVE 0x001 typedef struct ecpk_parameters_st ECPKPARAMETERS; diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index 26f3916d01..8b0167bd60 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -62,6 +62,48 @@ #include <openssl/asn1t.h> #include <openssl/objects.h> + +int EC_GROUP_get_basis_type(const EC_GROUP *group, unsigned int *k1, + unsigned int *k2, unsigned int *k3) + { + int i = 0; + + if (group == NULL) + return 0; + + if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != + NID_X9_62_characteristic_two_field) + /* everything else is currently not supported */ + return 0; + + while (group->poly[i] != 0) + i++; + + if (i == 4) + { + if (k1) + *k1 = group->poly[3]; + if (k2) + *k2 = group->poly[2]; + if (k3) + *k3 = group->poly[1]; + + return NID_X9_62_ppBasis; + } + else if (i == 2) + { + if (k1) + *k1 = group->poly[1]; + + return NID_X9_62_tpBasis; + } + else + /* everything else is currently not supported */ + return 0; + } + + + /* some structures needed for the asn1 encoding */ typedef struct x9_62_fieldid_st { ASN1_OBJECT *fieldType; diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h index 247c985a23..ae67ccfdc2 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_lcl.h @@ -89,6 +89,11 @@ #include <openssl/ec.h> +/* internal function: ec_group_index2nid() returns the NID of curve + * with the given index i from the internal curve list */ +int ec_group_index2nid(int i); + + /* Structure details are not part of the exported interface, * so all this may change in future versions. */ diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 9bccb073c6..9669f42aab 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -537,45 +537,6 @@ void EC_GROUP_clear_free_extra_data(EC_GROUP *group) } -int EC_GROUP_get_basis_type(const EC_GROUP *group, unsigned int *k1, - unsigned int *k2, unsigned int *k3) - { - int i = 0; - - if (group == NULL) - return 0; - - if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) != - NID_X9_62_characteristic_two_field) - /* everything else is currently not supported */ - return 0; - - while (group->poly[i] != 0) - i++; - - if (i == 4) - { - if (k1) - *k1 = group->poly[3]; - if (k2) - *k2 = group->poly[2]; - if (k3) - *k3 = group->poly[1]; - - return NID_X9_62_ppBasis; - } - else if (i == 2) - { - if (k1) - *k1 = group->poly[1]; - - return NID_X9_62_tpBasis; - } - else - /* everything else is currently not supported */ - return 0; - } - /* functions for EC_POINT objects */ EC_POINT *EC_POINT_new(const EC_GROUP *group) |