Lines Matching refs:group

28 int ossl_ec_GF2m_simple_group_init(EC_GROUP *group)  in ossl_ec_GF2m_simple_group_init()  argument
30 group->field = BN_new(); in ossl_ec_GF2m_simple_group_init()
31 group->a = BN_new(); in ossl_ec_GF2m_simple_group_init()
32 group->b = BN_new(); in ossl_ec_GF2m_simple_group_init()
34 if (group->field == NULL || group->a == NULL || group->b == NULL) { in ossl_ec_GF2m_simple_group_init()
35 BN_free(group->field); in ossl_ec_GF2m_simple_group_init()
36 BN_free(group->a); in ossl_ec_GF2m_simple_group_init()
37 BN_free(group->b); in ossl_ec_GF2m_simple_group_init()
47 void ossl_ec_GF2m_simple_group_finish(EC_GROUP *group) in ossl_ec_GF2m_simple_group_finish() argument
49 BN_free(group->field); in ossl_ec_GF2m_simple_group_finish()
50 BN_free(group->a); in ossl_ec_GF2m_simple_group_finish()
51 BN_free(group->b); in ossl_ec_GF2m_simple_group_finish()
58 void ossl_ec_GF2m_simple_group_clear_finish(EC_GROUP *group) in ossl_ec_GF2m_simple_group_clear_finish() argument
60 BN_clear_free(group->field); in ossl_ec_GF2m_simple_group_clear_finish()
61 BN_clear_free(group->a); in ossl_ec_GF2m_simple_group_clear_finish()
62 BN_clear_free(group->b); in ossl_ec_GF2m_simple_group_clear_finish()
63 group->poly[0] = 0; in ossl_ec_GF2m_simple_group_clear_finish()
64 group->poly[1] = 0; in ossl_ec_GF2m_simple_group_clear_finish()
65 group->poly[2] = 0; in ossl_ec_GF2m_simple_group_clear_finish()
66 group->poly[3] = 0; in ossl_ec_GF2m_simple_group_clear_finish()
67 group->poly[4] = 0; in ossl_ec_GF2m_simple_group_clear_finish()
68 group->poly[5] = -1; in ossl_ec_GF2m_simple_group_clear_finish()
101 int ossl_ec_GF2m_simple_group_set_curve(EC_GROUP *group, in ossl_ec_GF2m_simple_group_set_curve() argument
108 if (!BN_copy(group->field, p)) in ossl_ec_GF2m_simple_group_set_curve()
110 i = BN_GF2m_poly2arr(group->field, group->poly, 6) - 1; in ossl_ec_GF2m_simple_group_set_curve()
117 if (!BN_GF2m_mod_arr(group->a, a, group->poly)) in ossl_ec_GF2m_simple_group_set_curve()
119 if (bn_wexpand(group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) in ossl_ec_GF2m_simple_group_set_curve()
122 bn_set_all_zero(group->a); in ossl_ec_GF2m_simple_group_set_curve()
125 if (!BN_GF2m_mod_arr(group->b, b, group->poly)) in ossl_ec_GF2m_simple_group_set_curve()
127 if (bn_wexpand(group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) in ossl_ec_GF2m_simple_group_set_curve()
130 bn_set_all_zero(group->b); in ossl_ec_GF2m_simple_group_set_curve()
141 int ossl_ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, in ossl_ec_GF2m_simple_group_get_curve() argument
147 if (!BN_copy(p, group->field)) in ossl_ec_GF2m_simple_group_get_curve()
152 if (!BN_copy(a, group->a)) in ossl_ec_GF2m_simple_group_get_curve()
157 if (!BN_copy(b, group->b)) in ossl_ec_GF2m_simple_group_get_curve()
171 int ossl_ec_GF2m_simple_group_get_degree(const EC_GROUP *group) in ossl_ec_GF2m_simple_group_get_degree() argument
173 return BN_num_bits(group->field) - 1; in ossl_ec_GF2m_simple_group_get_degree()
180 int ossl_ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, in ossl_ec_GF2m_simple_group_check_discriminant() argument
201 if (!BN_GF2m_mod_arr(b, group->b, group->poly)) in ossl_ec_GF2m_simple_group_check_discriminant()
276 int ossl_ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, in ossl_ec_GF2m_simple_point_set_to_infinity() argument
288 int ossl_ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, in ossl_ec_GF2m_simple_point_set_affine_coordinates() argument
320 int ossl_ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, in ossl_ec_GF2m_simple_point_get_affine_coordinates() argument
327 if (EC_POINT_is_at_infinity(group, point)) { in ossl_ec_GF2m_simple_point_get_affine_coordinates()
356 int ossl_ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, in ossl_ec_GF2m_simple_add() argument
365 if (EC_POINT_is_at_infinity(group, a)) { in ossl_ec_GF2m_simple_add()
371 if (EC_POINT_is_at_infinity(group, b)) { in ossl_ec_GF2m_simple_add()
403 if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx)) in ossl_ec_GF2m_simple_add()
412 if (!EC_POINT_get_affine_coordinates(group, b, x1, y1, ctx)) in ossl_ec_GF2m_simple_add()
421 if (!group->meth->field_div(group, s, s, t, ctx)) in ossl_ec_GF2m_simple_add()
423 if (!group->meth->field_sqr(group, x2, s, ctx)) in ossl_ec_GF2m_simple_add()
425 if (!BN_GF2m_add(x2, x2, group->a)) in ossl_ec_GF2m_simple_add()
433 if (!EC_POINT_set_to_infinity(group, r)) in ossl_ec_GF2m_simple_add()
438 if (!group->meth->field_div(group, s, y1, x1, ctx)) in ossl_ec_GF2m_simple_add()
443 if (!group->meth->field_sqr(group, x2, s, ctx)) in ossl_ec_GF2m_simple_add()
447 if (!BN_GF2m_add(x2, x2, group->a)) in ossl_ec_GF2m_simple_add()
453 if (!group->meth->field_mul(group, y2, y2, s, ctx)) in ossl_ec_GF2m_simple_add()
460 if (!EC_POINT_set_affine_coordinates(group, r, x2, y2, ctx)) in ossl_ec_GF2m_simple_add()
477 int ossl_ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, in ossl_ec_GF2m_simple_dbl() argument
480 return ossl_ec_GF2m_simple_add(group, r, a, a, ctx); in ossl_ec_GF2m_simple_dbl()
483 int ossl_ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, in ossl_ec_GF2m_simple_invert() argument
486 if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(point->Y)) in ossl_ec_GF2m_simple_invert()
490 if (group->meth->make_affine == NULL in ossl_ec_GF2m_simple_invert()
491 || !group->meth->make_affine(group, point, ctx)) in ossl_ec_GF2m_simple_invert()
497 int ossl_ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, in ossl_ec_GF2m_simple_is_at_infinity() argument
508 int ossl_ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, in ossl_ec_GF2m_simple_is_on_curve() argument
520 if (EC_POINT_is_at_infinity(group, point)) in ossl_ec_GF2m_simple_is_on_curve()
523 field_mul = group->meth->field_mul; in ossl_ec_GF2m_simple_is_on_curve()
524 field_sqr = group->meth->field_sqr; in ossl_ec_GF2m_simple_is_on_curve()
550 if (!BN_GF2m_add(lh, point->X, group->a)) in ossl_ec_GF2m_simple_is_on_curve()
552 if (!field_mul(group, lh, lh, point->X, ctx)) in ossl_ec_GF2m_simple_is_on_curve()
556 if (!field_mul(group, lh, lh, point->X, ctx)) in ossl_ec_GF2m_simple_is_on_curve()
558 if (!BN_GF2m_add(lh, lh, group->b)) in ossl_ec_GF2m_simple_is_on_curve()
560 if (!field_sqr(group, y2, point->Y, ctx)) in ossl_ec_GF2m_simple_is_on_curve()
581 int ossl_ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, in ossl_ec_GF2m_simple_cmp() argument
590 if (EC_POINT_is_at_infinity(group, a)) { in ossl_ec_GF2m_simple_cmp()
591 return EC_POINT_is_at_infinity(group, b) ? 0 : 1; in ossl_ec_GF2m_simple_cmp()
594 if (EC_POINT_is_at_infinity(group, b)) in ossl_ec_GF2m_simple_cmp()
617 if (!EC_POINT_get_affine_coordinates(group, a, aX, aY, ctx)) in ossl_ec_GF2m_simple_cmp()
619 if (!EC_POINT_get_affine_coordinates(group, b, bX, bY, ctx)) in ossl_ec_GF2m_simple_cmp()
632 int ossl_ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, in ossl_ec_GF2m_simple_make_affine() argument
641 if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) in ossl_ec_GF2m_simple_make_affine()
658 if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) in ossl_ec_GF2m_simple_make_affine()
681 int ossl_ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, in ossl_ec_GF2m_simple_points_make_affine() argument
687 if (!group->meth->make_affine(group, points[i], ctx)) in ossl_ec_GF2m_simple_points_make_affine()
695 int ossl_ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, in ossl_ec_GF2m_simple_field_mul() argument
698 return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx); in ossl_ec_GF2m_simple_field_mul()
702 int ossl_ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, in ossl_ec_GF2m_simple_field_sqr() argument
705 return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx); in ossl_ec_GF2m_simple_field_sqr()
709 int ossl_ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, in ossl_ec_GF2m_simple_field_div() argument
712 return BN_GF2m_mod_div(r, a, b, group->field, ctx); in ossl_ec_GF2m_simple_field_div()
722 int ec_GF2m_simple_ladder_pre(const EC_GROUP *group, in ec_GF2m_simple_ladder_pre() argument
732 if (!BN_priv_rand_ex(s->Z, BN_num_bits(group->field) - 1, in ec_GF2m_simple_ladder_pre()
740 if ((group->meth->field_encode != NULL in ec_GF2m_simple_ladder_pre()
741 && !group->meth->field_encode(group, s->Z, s->Z, ctx)) in ec_GF2m_simple_ladder_pre()
742 || !group->meth->field_mul(group, s->X, p->X, s->Z, ctx)) in ec_GF2m_simple_ladder_pre()
747 if (!BN_priv_rand_ex(r->Y, BN_num_bits(group->field) - 1, in ec_GF2m_simple_ladder_pre()
754 if ((group->meth->field_encode != NULL in ec_GF2m_simple_ladder_pre()
755 && !group->meth->field_encode(group, r->Y, r->Y, ctx)) in ec_GF2m_simple_ladder_pre()
756 || !group->meth->field_sqr(group, r->Z, p->X, ctx) in ec_GF2m_simple_ladder_pre()
757 || !group->meth->field_sqr(group, r->X, r->Z, ctx) in ec_GF2m_simple_ladder_pre()
758 || !BN_GF2m_add(r->X, r->X, group->b) in ec_GF2m_simple_ladder_pre()
759 || !group->meth->field_mul(group, r->Z, r->Z, r->Y, ctx) in ec_GF2m_simple_ladder_pre()
760 || !group->meth->field_mul(group, r->X, r->X, r->Y, ctx)) in ec_GF2m_simple_ladder_pre()
775 int ec_GF2m_simple_ladder_step(const EC_GROUP *group, in ec_GF2m_simple_ladder_step() argument
779 if (!group->meth->field_mul(group, r->Y, r->Z, s->X, ctx) in ec_GF2m_simple_ladder_step()
780 || !group->meth->field_mul(group, s->X, r->X, s->Z, ctx) in ec_GF2m_simple_ladder_step()
781 || !group->meth->field_sqr(group, s->Y, r->Z, ctx) in ec_GF2m_simple_ladder_step()
782 || !group->meth->field_sqr(group, r->Z, r->X, ctx) in ec_GF2m_simple_ladder_step()
784 || !group->meth->field_sqr(group, s->Z, s->Z, ctx) in ec_GF2m_simple_ladder_step()
785 || !group->meth->field_mul(group, s->X, r->Y, s->X, ctx) in ec_GF2m_simple_ladder_step()
786 || !group->meth->field_mul(group, r->Y, s->Z, p->X, ctx) in ec_GF2m_simple_ladder_step()
788 || !group->meth->field_sqr(group, r->Y, r->Z, ctx) in ec_GF2m_simple_ladder_step()
789 || !group->meth->field_mul(group, r->Z, r->Z, s->Y, ctx) in ec_GF2m_simple_ladder_step()
790 || !group->meth->field_sqr(group, s->Y, s->Y, ctx) in ec_GF2m_simple_ladder_step()
791 || !group->meth->field_mul(group, s->Y, s->Y, group->b, ctx) in ec_GF2m_simple_ladder_step()
805 int ec_GF2m_simple_ladder_post(const EC_GROUP *group, in ec_GF2m_simple_ladder_post() argument
813 return EC_POINT_set_to_infinity(group, r); in ec_GF2m_simple_ladder_post()
817 || !EC_POINT_invert(group, r, ctx)) { in ec_GF2m_simple_ladder_post()
833 if (!group->meth->field_mul(group, t0, r->Z, s->Z, ctx) in ec_GF2m_simple_ladder_post()
834 || !group->meth->field_mul(group, t1, p->X, r->Z, ctx) in ec_GF2m_simple_ladder_post()
836 || !group->meth->field_mul(group, t2, p->X, s->Z, ctx) in ec_GF2m_simple_ladder_post()
837 || !group->meth->field_mul(group, r->Z, r->X, t2, ctx) in ec_GF2m_simple_ladder_post()
839 || !group->meth->field_mul(group, t1, t1, t2, ctx) in ec_GF2m_simple_ladder_post()
840 || !group->meth->field_sqr(group, t2, p->X, ctx) in ec_GF2m_simple_ladder_post()
842 || !group->meth->field_mul(group, t2, t2, t0, ctx) in ec_GF2m_simple_ladder_post()
844 || !group->meth->field_mul(group, t2, p->X, t0, ctx) in ec_GF2m_simple_ladder_post()
845 || !group->meth->field_inv(group, t2, t2, ctx) in ec_GF2m_simple_ladder_post()
846 || !group->meth->field_mul(group, t1, t1, t2, ctx) in ec_GF2m_simple_ladder_post()
847 || !group->meth->field_mul(group, r->X, r->Z, t2, ctx) in ec_GF2m_simple_ladder_post()
849 || !group->meth->field_mul(group, t2, t2, t1, ctx) in ec_GF2m_simple_ladder_post()
868 int ec_GF2m_simple_points_mul(const EC_GROUP *group, EC_POINT *r, in ec_GF2m_simple_points_mul() argument
891 if (num > 1 || BN_is_zero(group->order) || BN_is_zero(group->cofactor)) in ec_GF2m_simple_points_mul()
892 return ossl_ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx); in ec_GF2m_simple_points_mul()
896 return ossl_ec_scalar_mul_ladder(group, r, scalar, NULL, ctx); in ec_GF2m_simple_points_mul()
900 return ossl_ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx); in ec_GF2m_simple_points_mul()
907 if ((t = EC_POINT_new(group)) == NULL) { in ec_GF2m_simple_points_mul()
912 if (!ossl_ec_scalar_mul_ladder(group, t, scalar, NULL, ctx) in ec_GF2m_simple_points_mul()
913 || !ossl_ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx) in ec_GF2m_simple_points_mul()
914 || !EC_POINT_add(group, r, t, r, ctx)) in ec_GF2m_simple_points_mul()
929 static int ec_GF2m_simple_field_inv(const EC_GROUP *group, BIGNUM *r, in ec_GF2m_simple_field_inv() argument
934 if (!(ret = BN_GF2m_mod_inv(r, a, group->field, ctx))) in ec_GF2m_simple_field_inv()