Remove |group_check_discriminant| from |EC_METHOD| (dead code).

This commit is contained in:
Brian Smith 2015-10-07 11:17:48 -10:00
parent 7714e639c9
commit 89b8805088
4 changed files with 1 additions and 77 deletions

View File

@ -83,7 +83,6 @@ const EC_METHOD *EC_GFp_mont_method(void) {
ec_GFp_mont_group_set_curve,
ec_GFp_simple_group_get_curve,
ec_GFp_simple_group_get_degree,
ec_GFp_simple_group_check_discriminant,
ec_GFp_simple_point_init,
ec_GFp_simple_point_finish,
ec_GFp_simple_point_clear_finish,

View File

@ -101,9 +101,6 @@ typedef struct ec_method_st {
/* used by EC_GROUP_get_degree: */
int (*group_get_degree)(const EC_GROUP *);
/* used by EC_GROUP_check: */
int (*group_check_discriminant)(const EC_GROUP *, BN_CTX *);
/* used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy: */
int (*point_init)(EC_POINT *);
void (*point_finish)(EC_POINT *);
@ -242,7 +239,6 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,
int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,
BIGNUM *b, BN_CTX *);
int ec_GFp_simple_group_get_degree(const EC_GROUP *);
int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);
int ec_GFp_simple_point_init(EC_POINT *);
void ec_GFp_simple_point_finish(EC_POINT *);
void ec_GFp_simple_point_clear_finish(EC_POINT *);

View File

@ -1908,7 +1908,7 @@ const EC_METHOD *EC_GFp_nistp256_method(void) {
ec_GFp_simple_group_clear_finish,
ec_GFp_simple_group_copy, ec_GFp_nistp256_group_set_curve,
ec_GFp_simple_group_get_curve, ec_GFp_simple_group_get_degree,
ec_GFp_simple_group_check_discriminant, ec_GFp_simple_point_init,
ec_GFp_simple_point_init,
ec_GFp_simple_point_finish, ec_GFp_simple_point_clear_finish,
ec_GFp_simple_point_copy, ec_GFp_simple_point_set_to_infinity,
ec_GFp_simple_set_Jprojective_coordinates_GFp,

View File

@ -85,7 +85,6 @@ const EC_METHOD *EC_GFp_simple_method(void) {
ec_GFp_simple_group_set_curve,
ec_GFp_simple_group_get_curve,
ec_GFp_simple_group_get_degree,
ec_GFp_simple_group_check_discriminant,
ec_GFp_simple_point_init,
ec_GFp_simple_point_finish,
ec_GFp_simple_point_clear_finish,
@ -273,76 +272,6 @@ int ec_GFp_simple_group_get_degree(const EC_GROUP *group) {
return BN_num_bits(&group->field);
}
int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) {
int ret = 0;
BIGNUM *a, *b, *order, *tmp_1, *tmp_2;
const BIGNUM *p = &group->field;
BN_CTX *new_ctx = NULL;
if (ctx == NULL) {
ctx = new_ctx = BN_CTX_new();
if (ctx == NULL) {
OPENSSL_PUT_ERROR(EC, ERR_R_MALLOC_FAILURE);
goto err;
}
}
BN_CTX_start(ctx);
a = BN_CTX_get(ctx);
b = BN_CTX_get(ctx);
tmp_1 = BN_CTX_get(ctx);
tmp_2 = BN_CTX_get(ctx);
order = BN_CTX_get(ctx);
if (order == NULL) {
goto err;
}
if (group->meth->field_decode) {
if (!group->meth->field_decode(group, a, &group->a, ctx) ||
!group->meth->field_decode(group, b, &group->b, ctx)) {
goto err;
}
} else {
if (!BN_copy(a, &group->a) || !BN_copy(b, &group->b)) {
goto err;
}
}
/* check the discriminant:
* y^2 = x^3 + a*x + b is an elliptic curve <=> 4*a^3 + 27*b^2 != 0 (mod p)
* 0 =< a, b < p */
if (BN_is_zero(a)) {
if (BN_is_zero(b)) {
goto err;
}
} else if (!BN_is_zero(b)) {
if (!BN_mod_sqr(tmp_1, a, p, ctx) ||
!BN_mod_mul(tmp_2, tmp_1, a, p, ctx) ||
!BN_lshift(tmp_1, tmp_2, 2)) {
goto err;
}
/* tmp_1 = 4*a^3 */
if (!BN_mod_sqr(tmp_2, b, p, ctx) ||
!BN_mul_word(tmp_2, 27)) {
goto err;
}
/* tmp_2 = 27*b^2 */
if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx) ||
BN_is_zero(a)) {
goto err;
}
}
ret = 1;
err:
if (ctx != NULL) {
BN_CTX_end(ctx);
}
BN_CTX_free(new_ctx);
return ret;
}
int ec_GFp_simple_point_init(EC_POINT *point) {
BN_init(&point->X);
BN_init(&point->Y);