Lines Matching refs:group

123 void EC_GROUP_free(EC_GROUP *group)
125 if (!group) return;
127 if (group->meth->group_finish != 0)
128 group->meth->group_finish(group);
130 EC_EX_DATA_free_all_data(&group->extra_data);
132 if (group->generator != NULL)
133 EC_POINT_free(group->generator);
134 BN_free(&group->order);
135 BN_free(&group->cofactor);
137 if (group->seed)
138 OPENSSL_free(group->seed);
140 OPENSSL_free(group);
144 void EC_GROUP_clear_free(EC_GROUP *group)
146 if (!group) return;
148 if (group->meth->group_clear_finish != 0)
149 group->meth->group_clear_finish(group);
150 else if (group->meth->group_finish != 0)
151 group->meth->group_finish(group);
153 EC_EX_DATA_clear_free_all_data(&group->extra_data);
155 if (group->generator != NULL)
156 EC_POINT_clear_free(group->generator);
157 BN_clear_free(&group->order);
158 BN_clear_free(&group->cofactor);
160 if (group->seed)
162 OPENSSL_cleanse(group->seed, group->seed_len);
163 OPENSSL_free(group->seed);
166 OPENSSL_cleanse(group, sizeof *group);
167 OPENSSL_free(group);
272 const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group)
274 return group->meth;
284 int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor)
292 if (group->generator == NULL)
294 group->generator = EC_POINT_new(group);
295 if (group->generator == NULL) return 0;
297 if (!EC_POINT_copy(group->generator, generator)) return 0;
300 { if (!BN_copy(&group->order, order)) return 0; }
302 BN_zero(&group->order);
305 { if (!BN_copy(&group->cofactor, cofactor)) return 0; }
307 BN_zero(&group->cofactor);
313 const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group)
315 return group->generator;
319 int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)
321 if (!BN_copy(order, &group->order))
328 int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
330 if (!BN_copy(cofactor, &group->cofactor))
333 return !BN_is_zero(&group->cofactor);
337 void EC_GROUP_set_curve_name(EC_GROUP *group, int nid)
339 group->curve_name = nid;
343 int EC_GROUP_get_curve_name(const EC_GROUP *group)
345 return group->curve_name;
349 void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag)
351 group->asn1_flag = flag;
355 int EC_GROUP_get_asn1_flag(const EC_GROUP *group)
357 return group->asn1_flag;
361 void EC_GROUP_set_point_conversion_form(EC_GROUP *group,
364 group->asn1_form = form;
368 point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *group)
370 return group->asn1_form;
374 size_t EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len)
376 if (group->seed)
378 OPENSSL_free(group->seed);
379 group->seed = NULL;
380 group->seed_len = 0;
386 if ((group->seed = OPENSSL_malloc(len)) == NULL)
388 memcpy(group->seed, p, len);
389 group->seed_len = len;
395 unsigned char *EC_GROUP_get0_seed(const EC_GROUP *group)
397 return group->seed;
401 size_t EC_GROUP_get_seed_len(const EC_GROUP *group)
403 return group->seed_len;
407 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
409 if (group->meth->group_set_curve == 0)
414 return group->meth->group_set_curve(group, p, a, b, ctx);
418 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
420 if (group->meth->group_get_curve == 0)
425 return group->meth->group_get_curve(group, p, a, b, ctx);
429 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
431 if (group->meth->group_set_curve == 0)
436 return group->meth->group_set_curve(group, p, a, b, ctx);
440 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
442 if (group->meth->group_get_curve == 0)
447 return group->meth->group_get_curve(group, p, a, b, ctx);
451 int EC_GROUP_get_degree(const EC_GROUP *group)
453 if (group->meth->group_get_degree == 0)
458 return group->meth->group_get_degree(group);
462 int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
464 if (group->meth->group_check_discriminant == 0)
469 return group->meth->group_check_discriminant(group, ctx);
693 EC_POINT *EC_POINT_new(const EC_GROUP *group)
697 if (group == NULL)
702 if (group->meth->point_init == 0)
715 ret->meth = group->meth;
768 EC_POINT *EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group)
775 t = EC_POINT_new(group);
793 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
795 if (group->meth->point_set_to_infinity == 0)
800 if (group->meth != point->meth)
805 return group->meth->point_set_to_infinity(group, point);
809 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
812 if (group->meth->point_set_Jprojective_coordinates_GFp == 0)
817 if (group->meth != point->meth)
822 return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
826 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
829 if (group->meth->point_get_Jprojective_coordinates_GFp == 0)
834 if (group->meth != point->meth)
839 return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
843 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
846 if (group->meth->point_set_affine_coordinates == 0)
851 if (group->meth != point->meth)
856 return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
860 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
863 if (group->meth->point_set_affine_coordinates == 0)
868 if (group->meth != point->meth)
873 return group->meth->point_set_affine_coordinates(group, point, x, y, ctx);
877 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
880 if (group->meth->point_get_affine_coordinates == 0)
885 if (group->meth != point->meth)
890 return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
894 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point,
897 if (group->meth->point_get_affine_coordinates == 0)
902 if (group->meth != point->meth)
907 return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
911 int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
913 if (group->meth->add == 0)
918 if ((group->meth != r->meth) || (r->meth != a->meth) || (a->meth != b->meth))
923 return group->meth->add(group, r, a, b, ctx);
927 int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
929 if (group->meth->dbl == 0)
934 if ((group->meth != r->meth) || (r->meth != a->meth))
939 return group->meth->dbl(group, r, a, ctx);
943 int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)
945 if (group->meth->invert == 0)
950 if (group->meth != a->meth)
955 return group->meth->invert(group, a, ctx);
959 int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
961 if (group->meth->is_at_infinity == 0)
966 if (group->meth != point->meth)
971 return group->meth->is_at_infinity(group, point);
975 int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
977 if (group->meth->is_on_curve == 0)
982 if (group->meth != point->meth)
987 return group->meth->is_on_curve(group, point, ctx);
991 int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
993 if (group->meth->point_cmp == 0)
998 if ((group->meth != a->meth) || (a->meth != b->meth))
1003 return group->meth->point_cmp(group, a, b, ctx);
1007 int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1009 if (group->meth->make_affine == 0)
1014 if (group->meth != point->meth)
1019 return group->meth->make_affine(group, point, ctx);
1023 int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
1027 if (group->meth->points_make_affine == 0)
1034 if (group->meth != points[i]->meth)
1040 return group->meth->points_make_affine(group, num, points, ctx);
1046 * If group->meth->mul is 0, we use the wNAF-based implementations in ec_mult.c;
1050 int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
1053 if (group->meth->mul == 0)
1055 return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);
1057 return group->meth->mul(group, r, scalar, num, points, scalars, ctx);
1060 int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
1071 return EC_POINTs_mul(group, r, g_scalar, (point != NULL && p_scalar != NULL), points, scalars, ctx);
1074 int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
1076 if (group->meth->mul == 0)
1078 return ec_wNAF_precompute_mult(group, ctx);
1080 if (group->meth->precompute_mult != 0)
1081 return group->meth->precompute_mult(group, ctx);
1086 int EC_GROUP_have_precompute_mult(const EC_GROUP *group)
1088 if (group->meth->mul == 0)
1090 return ec_wNAF_have_precompute_mult(group);
1092 if (group->meth->have_precompute_mult != 0)
1093 return group->meth->have_precompute_mult(group);