Lines Matching defs:group
81 EC_GROUP *group = NULL;
87 if ((group = calloc(1, sizeof(*group))) == NULL) {
92 group->meth = meth;
94 group->asn1_flag = OPENSSL_EC_NAMED_CURVE;
95 group->asn1_form = POINT_CONVERSION_UNCOMPRESSED;
97 if ((group->p = BN_new()) == NULL)
99 if ((group->a = BN_new()) == NULL)
101 if ((group->b = BN_new()) == NULL)
104 if ((group->order = BN_new()) == NULL)
106 if ((group->cofactor = BN_new()) == NULL)
113 return group;
116 EC_GROUP_free(group);
123 EC_GROUP_free(EC_GROUP *group)
125 if (group == NULL)
128 BN_free(group->p);
129 BN_free(group->a);
130 BN_free(group->b);
132 BN_MONT_CTX_free(group->mont_ctx);
134 EC_POINT_free(group->generator);
135 BN_free(group->order);
136 BN_free(group->cofactor);
138 freezero(group->seed, group->seed_len);
139 freezero(group, sizeof *group);
144 EC_GROUP_clear_free(EC_GROUP *group)
146 EC_GROUP_free(group);
206 EC_GROUP *group = NULL;
211 if ((group = EC_GROUP_new(in_group->meth)) == NULL)
213 if (!EC_GROUP_copy(group, in_group))
216 return group;
219 EC_GROUP_free(group);
241 ec_set_cofactor(EC_GROUP *group, const BIGNUM *in_cofactor)
247 BN_zero(group->cofactor);
275 if (BN_num_bits(group->order) <= (BN_num_bits(group->p) + 1) / 2 + 3)
284 if (!BN_rshift1(cofactor, group->order))
290 if (!BN_add(cofactor, cofactor, group->p))
293 if (!BN_div_ct(cofactor, NULL, cofactor, group->order, ctx))
298 if (BN_num_bits(cofactor) > BN_num_bits(group->p) + 1) {
303 if (!bn_copy(group->cofactor, cofactor))
316 EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
325 if (BN_is_zero(group->p) || BN_is_negative(group->p)) {
335 BN_num_bits(order) > BN_num_bits(group->p) + 1) {
340 if (group->generator == NULL)
341 group->generator = EC_POINT_new(group);
342 if (group->generator == NULL)
345 if (!EC_POINT_copy(group->generator, generator))
348 if (!bn_copy(group->order, order))
351 if (!ec_set_cofactor(group, cofactor))
359 EC_GROUP_get0_generator(const EC_GROUP *group)
361 return group->generator;
366 EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)
368 if (!bn_copy(order, group->order))
376 EC_GROUP_get0_order(const EC_GROUP *group)
378 return group->order;
382 EC_GROUP_order_bits(const EC_GROUP *group)
384 return BN_num_bits(group->order);
389 EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
391 if (!bn_copy(cofactor, group->cofactor))
394 return !BN_is_zero(group->cofactor);
399 EC_GROUP_get0_cofactor(const EC_GROUP *group)
401 return group->cofactor;
405 EC_GROUP_set_curve_name(EC_GROUP *group, int nid)
407 group->nid = nid;
412 EC_GROUP_get_curve_name(const EC_GROUP *group)
414 return group->nid;
419 EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag)
421 group->asn1_flag = flag;
426 EC_GROUP_get_asn1_flag(const EC_GROUP *group)
428 return group->asn1_flag;
433 EC_GROUP_set_point_conversion_form(EC_GROUP *group,
436 group->asn1_form = form;
441 EC_GROUP_get_point_conversion_form(const EC_GROUP *group)
443 return group->asn1_form;
448 EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *seed, size_t len)
450 free(group->seed);
451 group->seed = NULL;
452 group->seed_len = 0;
457 if ((group->seed = malloc(len)) == NULL)
459 memcpy(group->seed, seed, len);
460 group->seed_len = len;
467 EC_GROUP_get0_seed(const EC_GROUP *group)
469 return group->seed;
474 EC_GROUP_get_seed_len(const EC_GROUP *group)
476 return group->seed_len;
481 EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
492 if (group->meth->group_set_curve == NULL) {
496 ret = group->meth->group_set_curve(group, p, a, b, ctx);
507 EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
518 if (group->meth->group_get_curve == NULL) {
522 ret = group->meth->group_get_curve(group, p, a, b, ctx);
533 EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
536 return EC_GROUP_set_curve(group, p, a, b, ctx);
541 EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
544 return EC_GROUP_get_curve(group, p, a, b, ctx);
552 EC_GROUP *group;
554 if ((group = EC_GROUP_new(EC_GFp_mont_method())) == NULL)
557 if (!EC_GROUP_set_curve(group, p, a, b, ctx))
560 return group;
563 EC_GROUP_free(group);
570 EC_GROUP_get_degree(const EC_GROUP *group)
572 return BN_num_bits(group->p);
577 EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx_in)
599 if (!EC_GROUP_get_curve(group, p, a, b, ctx))
643 EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx_in)
656 if (!EC_GROUP_check_discriminant(group, ctx)) {
661 if ((generator = EC_GROUP_get0_generator(group)) == NULL) {
665 if (EC_POINT_is_on_curve(group, generator, ctx) <= 0) {
670 if ((point = EC_POINT_new(group)) == NULL)
672 if ((order = EC_GROUP_get0_order(group)) == NULL)
678 if (!EC_POINT_mul(group, point, order, NULL, NULL, ctx))
680 if (!EC_POINT_is_at_infinity(group, point)) {
794 EC_POINT_new(const EC_GROUP *group)
798 if (group == NULL) {
815 point->meth = group->meth;
870 EC_POINT_dup(const EC_POINT *in_point, const EC_GROUP *group)
877 if ((point = EC_POINT_new(group)) == NULL)
893 EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
895 if (group->meth != point->meth) {
908 EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
919 if (group->meth->point_set_affine_coordinates == NULL) {
923 if (group->meth != point->meth) {
927 if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
930 if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
946 EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
949 return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);
954 EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
960 if (EC_POINT_is_at_infinity(group, point) > 0) {
970 if (group->meth->point_get_affine_coordinates == NULL) {
974 if (group->meth != point->meth) {
978 ret = group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
989 EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
992 return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);
997 EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
1031 if (!EC_GROUP_get_curve(group, p, a, b, ctx))
1045 if (group->a_is_minus3) {
1085 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
1101 EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
1104 return EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx);
1109 EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
1120 if (group->meth->add == NULL) {
1124 if (group->meth != r->meth || group->meth != a->meth ||
1125 group->meth != b->meth) {
1129 ret = group->meth->add(group, r, a, b, ctx);
1140 EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
1151 if (group->meth->dbl == NULL) {
1155 if (group->meth != r->meth || r->meth != a->meth) {
1159 ret = group->meth->dbl(group, r, a, ctx);
1170 EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx_in)
1180 if (group->meth->invert == NULL) {
1184 if (group->meth != a->meth) {
1188 ret = group->meth->invert(group, a, ctx);
1199 EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
1201 if (group->meth != point->meth) {
1211 EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
1222 if (group->meth->point_is_on_curve == NULL) {
1226 if (group->meth != point->meth) {
1230 ret = group->meth->point_is_on_curve(group, point, ctx);
1241 EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
1252 if (group->meth->point_cmp == NULL) {
1256 if (group->meth != a->meth || a->meth != b->meth) {
1260 ret = group->meth->point_cmp(group, a, b, ctx);
1271 EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in)
1289 if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))
1291 if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))
1307 EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
1318 if (group->meth->mul_single_ct == NULL ||
1319 group->meth->mul_double_nonct == NULL) {
1333 ret = group->meth->mul_single_ct(group, r, g_scalar,
1334 group->generator, ctx);
1344 ret = group->meth->mul_single_ct(group, r, p_scalar, point, ctx);
1352 ret = group->meth->mul_double_nonct(group, r, g_scalar,
1373 EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
1382 EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
1391 EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[],
1400 EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
1410 EC_GROUP_method_of(const EC_GROUP *group)
1434 EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx_in)
1442 EC_GROUP_have_precompute_mult(const EC_GROUP *group)