Remove EC_GROUP_get_cofactor (dead code).
All the curves supported by the openssl/ec.h API in *ring* have cofactor 1. It isn't clear how well the code even works when the cofactor isn't 1.
This commit is contained in:
parent
3909ad4864
commit
7714e639c9
@ -110,7 +110,6 @@ static const struct curve_data P224 = {
|
||||
ec_group_new_curve_GFp,
|
||||
"NIST P-224",
|
||||
28,
|
||||
1,
|
||||
{/* p */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@ -142,7 +141,6 @@ static const struct curve_data P256 = {
|
||||
EC_GROUP_new_curve_p256,
|
||||
"NIST P-256",
|
||||
32,
|
||||
1,
|
||||
{/* p */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@ -173,7 +171,6 @@ static const struct curve_data P384 = {
|
||||
ec_group_new_curve_GFp,
|
||||
"NIST P-384",
|
||||
48,
|
||||
1,
|
||||
{/* p */
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@ -210,7 +207,6 @@ static const struct curve_data P521 = {
|
||||
ec_group_new_curve_GFp,
|
||||
"NIST P-521",
|
||||
66,
|
||||
1,
|
||||
{/* p */
|
||||
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
@ -276,7 +272,6 @@ EC_GROUP *ec_group_new(const EC_METHOD *meth) {
|
||||
|
||||
ret->meth = meth;
|
||||
BN_init(&ret->order);
|
||||
BN_init(&ret->cofactor);
|
||||
|
||||
if (!meth->group_init(ret)) {
|
||||
OPENSSL_free(ret);
|
||||
@ -352,8 +347,7 @@ static EC_GROUP *ec_group_new_from_data(const struct curve_data *data) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (!BN_bin2bn(params + 5 * param_len, param_len, &group->order) ||
|
||||
!BN_set_word(&group->cofactor, (BN_ULONG)data->cofactor)) {
|
||||
if (!BN_bin2bn(params + 5 * param_len, param_len, &group->order)) {
|
||||
OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
@ -408,7 +402,6 @@ void EC_GROUP_free(EC_GROUP *group) {
|
||||
|
||||
EC_POINT_free(group->generator);
|
||||
BN_free(&group->order);
|
||||
BN_free(&group->cofactor);
|
||||
|
||||
OPENSSL_free(group);
|
||||
}
|
||||
@ -447,8 +440,7 @@ int ec_group_copy(EC_GROUP *dest, const EC_GROUP *src) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!BN_copy(&dest->order, &src->order) ||
|
||||
!BN_copy(&dest->cofactor, &src->cofactor)) {
|
||||
if (!BN_copy(&dest->order, &src->order)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -502,15 +494,6 @@ int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) {
|
||||
return !BN_is_zero(order);
|
||||
}
|
||||
|
||||
int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,
|
||||
BN_CTX *ctx) {
|
||||
if (!BN_copy(cofactor, &group->cofactor)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return !BN_is_zero(&group->cofactor);
|
||||
}
|
||||
|
||||
int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *out_p, BIGNUM *out_a,
|
||||
BIGNUM *out_b, BN_CTX *ctx) {
|
||||
if (group->meth->group_get_curve == 0) {
|
||||
|
@ -191,7 +191,7 @@ struct ec_group_st {
|
||||
const EC_METHOD *meth;
|
||||
|
||||
EC_POINT *generator; /* optional */
|
||||
BIGNUM order, cofactor;
|
||||
BIGNUM order;
|
||||
|
||||
int curve_name; /* optional NID for named curve */
|
||||
|
||||
@ -338,9 +338,6 @@ struct curve_data {
|
||||
const char *comment;
|
||||
/* param_len is the number of bytes needed to store a field element. */
|
||||
uint8_t param_len;
|
||||
/* cofactor is the cofactor of the group (i.e. the number of elements in the
|
||||
* group divided by the size of the main subgroup. */
|
||||
uint8_t cofactor; /* promoted to BN_ULONG */
|
||||
/* data points to an array of 6*|param_len| bytes which hold the field
|
||||
* elements of the following (in big-endian order): prime, a, b, generator x,
|
||||
* generator y, order. */
|
||||
|
@ -140,11 +140,6 @@ OPENSSL_EXPORT const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);
|
||||
OPENSSL_EXPORT int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order,
|
||||
BN_CTX *ctx);
|
||||
|
||||
/* EC_GROUP_get_cofactor sets |*cofactor| to the cofactor of |group| using
|
||||
* |ctx|, if it's not NULL. It returns one on success and zero otherwise. */
|
||||
OPENSSL_EXPORT int EC_GROUP_get_cofactor(const EC_GROUP *group,
|
||||
BIGNUM *cofactor, BN_CTX *ctx);
|
||||
|
||||
/* EC_GROUP_get_curve_GFp gets various parameters about a group. It sets
|
||||
* |*out_p| to the order of the coordinate field and |*out_a| and |*out_b| to
|
||||
* the parameters of the curve when expressed as y² = x³ + ax + b. Any of the
|
||||
|
Loading…
x
Reference in New Issue
Block a user