提交 8aefe253 编写于 作者: B Bodo Möller

move EC_GROUP_get_basis_type() from ec_lib.c to ec_asn1.c

上级 7e31164a
...@@ -191,12 +191,6 @@ const char *EC_GROUP_get0_comment(int nid); ...@@ -191,12 +191,6 @@ const char *EC_GROUP_get0_comment(int nid);
* with the given index i from the internal curve list */ * with the given index i from the internal curve list */
int ec_group_index2nid(int i); 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 */ /* EC_POINT functions */
...@@ -261,6 +255,13 @@ int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *); ...@@ -261,6 +255,13 @@ int EC_GROUP_precompute_mult(EC_GROUP *, BN_CTX *);
/* ASN1 stuff */ /* 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 #define OPENSSL_EC_NAMED_CURVE 0x001
typedef struct ecpk_parameters_st ECPKPARAMETERS; typedef struct ecpk_parameters_st ECPKPARAMETERS;
......
...@@ -62,6 +62,48 @@ ...@@ -62,6 +62,48 @@
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/objects.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 */ /* some structures needed for the asn1 encoding */
typedef struct x9_62_fieldid_st { typedef struct x9_62_fieldid_st {
ASN1_OBJECT *fieldType; ASN1_OBJECT *fieldType;
......
...@@ -89,6 +89,11 @@ ...@@ -89,6 +89,11 @@
#include <openssl/ec.h> #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, /* Structure details are not part of the exported interface,
* so all this may change in future versions. */ * so all this may change in future versions. */
......
...@@ -537,45 +537,6 @@ void EC_GROUP_clear_free_extra_data(EC_GROUP *group) ...@@ -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 */ /* functions for EC_POINT objects */
EC_POINT *EC_POINT_new(const EC_GROUP *group) EC_POINT *EC_POINT_new(const EC_GROUP *group)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册