Lines Matching refs:group

137 int ec_GF2m_simple_group_init(EC_GROUP *group)
139 BN_init(&group->field);
140 BN_init(&group->a);
141 BN_init(&group->b);
149 void ec_GF2m_simple_group_finish(EC_GROUP *group)
151 BN_free(&group->field);
152 BN_free(&group->a);
153 BN_free(&group->b);
160 void ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
162 BN_clear_free(&group->field);
163 BN_clear_free(&group->a);
164 BN_clear_free(&group->b);
165 group->poly[0] = 0;
166 group->poly[1] = 0;
167 group->poly[2] = 0;
168 group->poly[3] = 0;
169 group->poly[4] = 0;
170 group->poly[5] = -1;
198 int ec_GF2m_simple_group_set_curve(EC_GROUP *group,
203 /* group->field */
204 if (!BN_copy(&group->field, p)) goto err;
205 i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1;
212 /* group->a */
213 if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err;
214 if(bn_wexpand(&group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err;
215 for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0;
217 /* group->b */
218 if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err;
219 if(bn_wexpand(&group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err;
220 for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0;
231 int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
237 if (!BN_copy(p, &group->field)) return 0;
242 if (!BN_copy(a, &group->a)) goto err;
247 if (!BN_copy(b, &group->b)) goto err;
258 int ec_GF2m_simple_group_get_degree(const EC_GROUP *group)
260 return BN_num_bits(&group->field)-1;
267 int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
286 if (!BN_GF2m_mod_arr(b, &group->b, group->poly)) goto err;
348 int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
359 int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
386 int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
391 if (EC_POINT_is_at_infinity(group, point))
421 int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
427 if (EC_POINT_is_at_infinity(group, a))
433 if (EC_POINT_is_at_infinity(group, b))
464 if (!EC_POINT_get_affine_coordinates_GF2m(group, a, x0, y0, ctx)) goto err;
473 if (!EC_POINT_get_affine_coordinates_GF2m(group, b, x1, y1, ctx)) goto err;
481 if (!group->meth->field_div(group, s, s, t, ctx)) goto err;
482 if (!group->meth->field_sqr(group, x2, s, ctx)) goto err;
483 if (!BN_GF2m_add(x2, x2, &group->a)) goto err;
491 if (!EC_POINT_set_to_infinity(group, r)) goto err;
495 if (!group->meth->field_div(group, s, y1, x1, ctx)) goto err;
498 if (!group->meth->field_sqr(group, x2, s, ctx)) goto err;
500 if (!BN_GF2m_add(x2, x2, &group->a)) goto err;
504 if (!group->meth->field_mul(group, y2, y2, s, ctx)) goto err;
508 if (!EC_POINT_set_affine_coordinates_GF2m(group, r, x2, y2, ctx)) goto err;
523 int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
525 return ec_GF2m_simple_add(group, r, a, a, ctx);
529 int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
531 if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y))
535 if (!EC_POINT_make_affine(group, point, ctx)) return 0;
541 int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
551 int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
559 if (EC_POINT_is_at_infinity(group, point))
562 field_mul = group->meth->field_mul;
563 field_sqr = group->meth->field_sqr;
585 if (!BN_GF2m_add(lh, &point->X, &group->a)) goto err;
586 if (!field_mul(group, lh, lh, &point->X, ctx)) goto err;
588 if (!field_mul(group, lh, lh, &point->X, ctx)) goto err;
589 if (!BN_GF2m_add(lh, lh, &group->b)) goto err;
590 if (!field_sqr(group, y2, &point->Y, ctx)) goto err;
606 int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
612 if (EC_POINT_is_at_infinity(group, a))
614 return EC_POINT_is_at_infinity(group, b) ? 0 : 1;
617 if (EC_POINT_is_at_infinity(group, b))
639 if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx)) goto err;
640 if (!EC_POINT_get_affine_coordinates_GF2m(group, b, bX, bY, ctx)) goto err;
651 int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
657 if (point->Z_is_one || EC_POINT_is_at_infinity(group, point))
672 if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) goto err;
687 int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
693 if (!group->meth->make_affine(group, points[i], ctx)) return 0;
701 int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
703 return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx);
708 int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
710 return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx);
715 int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
717 return BN_GF2m_mod_div(r, a, b, &group->field, ctx);