Lines Matching defs:group

116 static void timings(EC_GROUP *group, int type, BN_CTX *ctx)
127 fprintf(stdout, "Timings for %d-bit field, ", EC_GROUP_get_degree(group));
128 if (!EC_GROUP_get_order(group, s, ctx)) ABORT;
132 P = EC_POINT_new(group);
134 EC_POINT_copy(P, EC_GROUP_get0_generator(group));
152 if (!EC_POINT_mul(group, P, (type != TIMING_RAND_PT) ? r[i] : NULL,
195 /* test multiplication with group order, long and negative scalars */
196 static void group_order_tests(EC_GROUP *group)
199 EC_POINT *P = EC_POINT_new(group);
200 EC_POINT *Q = EC_POINT_new(group);
205 fprintf(stdout, "verify group order ...");
207 if (!EC_GROUP_get_order(group, order, ctx)) ABORT;
208 if (!EC_POINT_mul(group, Q, order, NULL, NULL, ctx)) ABORT;
209 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
212 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
213 if (!EC_POINT_mul(group, Q, order, NULL, NULL, ctx)) ABORT;
214 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
228 if (!EC_POINT_mul(group, P, n1, NULL, NULL, ctx)) ABORT;
233 if (!EC_POINT_mul(group, Q, NULL, P, n1, ctx)) ABORT;
234 if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
238 if (!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
239 if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
243 if (!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
244 if (0 != EC_POINT_cmp(group, Q, P, ctx)) ABORT;
248 if (!EC_POINT_mul(group, Q, NULL, P, n2, ctx)) ABORT;
250 if (!EC_POINT_add(group, Q, Q, P, ctx)) ABORT;
251 if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
254 if (EC_POINT_is_at_infinity(group, P)) ABORT;
261 if (!EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx)) ABORT;
262 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
278 EC_GROUP *group;
300 group = EC_GROUP_new(EC_GFp_mont_method()); /* applications should use EC_GROUP_new_curve_GFp
302 if (!group) ABORT;
304 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
308 tmp = EC_GROUP_new(EC_GROUP_method_of(group));
310 if (!EC_GROUP_copy(tmp, group)) ABORT;
311 EC_GROUP_free(group);
312 group = tmp;
315 if (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx)) ABORT;
325 P = EC_POINT_new(group);
326 Q = EC_POINT_new(group);
327 R = EC_POINT_new(group);
330 if (!EC_POINT_set_to_infinity(group, P)) ABORT;
331 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
334 if (!EC_POINT_oct2point(group, Q, buf, 1, ctx)) ABORT;
336 if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;
337 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
345 if (!EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, ctx)) ABORT;
346 if (!EC_POINT_is_on_curve(group, Q, ctx))
348 if (!EC_POINT_get_affine_coordinates_GFp(group, Q, x, y, ctx)) ABORT;
363 if (EC_POINT_is_at_infinity(group, P))
367 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
377 if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;
386 if (!EC_POINTs_make_affine(group, 2, points, ctx)) ABORT;
391 while (!EC_POINT_is_at_infinity(group, P));
393 if (!EC_POINT_add(group, P, Q, R, ctx)) ABORT;
394 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
396 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, sizeof buf, ctx);
398 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
399 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
403 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, sizeof buf, ctx);
405 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
406 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
410 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, ctx);
412 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
413 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
417 if (!EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z, ctx)) ABORT;
426 if (!EC_POINT_invert(group, P, ctx)) ABORT;
427 if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;
437 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
441 if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
442 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
444 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
446 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
457 if (EC_GROUP_get_degree(group) != 160) ABORT;
460 group_order_tests(group);
462 if (!(P_160 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
463 if (!EC_GROUP_copy(P_160, group)) ABORT;
472 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
475 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;
476 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
478 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
480 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
491 if (EC_GROUP_get_degree(group) != 192) ABORT;
494 group_order_tests(group);
496 if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
497 if (!EC_GROUP_copy(P_192, group)) ABORT;
506 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
509 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT;
510 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
512 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
514 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
525 if (EC_GROUP_get_degree(group) != 224) ABORT;
528 group_order_tests(group);
530 if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
531 if (!EC_GROUP_copy(P_224, group)) ABORT;
540 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
543 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;
544 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
547 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
549 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
560 if (EC_GROUP_get_degree(group) != 256) ABORT;
563 group_order_tests(group);
565 if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
566 if (!EC_GROUP_copy(P_256, group)) ABORT;
578 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
582 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, ctx)) ABORT;
583 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
586 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
588 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
600 if (EC_GROUP_get_degree(group) != 384) ABORT;
603 group_order_tests(group);
605 if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
606 if (!EC_GROUP_copy(P_384, group)) ABORT;
621 if (!EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) ABORT;
626 if (!EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, ctx)) ABORT;
627 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
631 if (!EC_GROUP_set_generator(group, P, z, BN_value_one())) ABORT;
633 if (!EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx)) ABORT;
646 if (EC_GROUP_get_degree(group) != 521) ABORT;
649 group_order_tests(group);
651 if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT;
652 if (!EC_GROUP_copy(P_521, group)) ABORT;
658 if (EC_POINT_is_at_infinity(group, Q)) ABORT;
659 if (!EC_POINT_dbl(group, P, P, ctx)) ABORT;
660 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
661 if (!EC_POINT_invert(group, Q, ctx)) ABORT; /* P = -2Q */
663 if (!EC_POINT_add(group, R, P, Q, ctx)) ABORT;
664 if (!EC_POINT_add(group, R, R, Q, ctx)) ABORT;
665 if (!EC_POINT_is_at_infinity(group, R)) ABORT; /* R = P + 2Q */
672 if (EC_POINT_is_at_infinity(group, Q)) ABORT;
678 if (!EC_GROUP_get_order(group, z, ctx)) ABORT;
682 scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
688 /* z is still the group order */
689 if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;
690 if (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx)) ABORT;
691 if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;
692 if (0 != EC_POINT_cmp(group, R, Q, ctx)) ABORT;
703 if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;
704 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
720 if (!EC_POINTs_mul(group, P, NULL, 4, points, scalars, ctx)) ABORT;
721 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
754 EC_GROUP_free(group);
773 if (!EC_POINT_set_compressed_coordinates_GF2m(group, P, x, _y_bit, ctx)) ABORT; \
774 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; \
777 if (!EC_GROUP_set_generator(group, P, z, cof)) ABORT; \
778 if (!EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; \
791 if (!EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT; \
792 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT; \
795 if (!EC_GROUP_set_generator(group, P, z, cof)) ABORT; \
807 if (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) ABORT; \
810 if (EC_GROUP_get_degree(group) != _degree) ABORT; \
812 group_order_tests(group); \
813 if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \
814 if (!EC_GROUP_copy(_variable, group)) ABORT; \
822 EC_GROUP *group;
845 group = EC_GROUP_new(EC_GF2m_simple_method()); /* applications should use EC_GROUP_new_curve_GF2m
847 if (!group) ABORT;
848 if (!EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) ABORT;
852 tmp = EC_GROUP_new(EC_GROUP_method_of(group));
854 if (!EC_GROUP_copy(tmp, group)) ABORT;
855 EC_GROUP_free(group);
856 group = tmp;
859 if (!EC_GROUP_get_curve_GF2m(group, p, a, b, ctx)) ABORT;
869 P = EC_POINT_new(group);
870 Q = EC_POINT_new(group);
871 R = EC_POINT_new(group);
874 if (!EC_POINT_set_to_infinity(group, P)) ABORT;
875 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
878 if (!EC_POINT_oct2point(group, Q, buf, 1, ctx)) ABORT;
880 if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;
881 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
892 if (!EC_POINT_set_compressed_coordinates_GF2m(group, Q, x, 1, ctx)) ABORT;
895 if (!EC_POINT_set_affine_coordinates_GF2m(group, Q, x, y, ctx)) ABORT;
897 if (!EC_POINT_is_on_curve(group, Q, ctx))
901 if (!EC_POINT_get_affine_coordinates_GF2m(group, Q, x, y, ctx)) ABORT;
917 if (EC_POINT_is_at_infinity(group, P))
921 if (!EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, ctx)) ABORT;
931 if (!EC_POINT_add(group, P, P, Q, ctx)) ABORT;
933 while (!EC_POINT_is_at_infinity(group, P));
935 if (!EC_POINT_add(group, P, Q, R, ctx)) ABORT;
936 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
940 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf, sizeof buf, ctx);
942 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
943 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
948 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED, buf, sizeof buf, ctx);
950 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
951 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
957 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof buf, ctx);
959 if (!EC_POINT_oct2point(group, P, buf, len, ctx)) ABORT;
960 if (0 != EC_POINT_cmp(group, P, Q, ctx)) ABORT;
967 if (!EC_POINT_invert(group, P, ctx)) ABORT;
968 if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;
1134 if (EC_POINT_is_at_infinity(group, Q)) ABORT;
1135 if (!EC_POINT_dbl(group, P, P, ctx)) ABORT;
1136 if (!EC_POINT_is_on_curve(group, P, ctx)) ABORT;
1137 if (!EC_POINT_invert(group, Q, ctx)) ABORT; /* P = -2Q */
1139 if (!EC_POINT_add(group, R, P, Q, ctx)) ABORT;
1140 if (!EC_POINT_add(group, R, R, Q, ctx)) ABORT;
1141 if (!EC_POINT_is_at_infinity(group, R)) ABORT; /* R = P + 2Q */
1147 if (EC_POINT_is_at_infinity(group, Q)) ABORT;
1155 scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
1161 /* z is still the group order */
1162 if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;
1163 if (!EC_POINTs_mul(group, R, z, 2, points, scalars, ctx)) ABORT;
1164 if (0 != EC_POINT_cmp(group, P, R, ctx)) ABORT;
1165 if (0 != EC_POINT_cmp(group, R, Q, ctx)) ABORT;
1176 if (!EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx)) ABORT;
1177 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
1189 if (!EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx)) ABORT;
1190 if (!EC_POINT_is_at_infinity(group, P)) ABORT;
1233 EC_GROUP_free(group);
1276 EC_GROUP *group = NULL;
1278 if ((group = EC_GROUP_new_by_curve_name(nid)) == NULL)
1286 if (!EC_GROUP_check(group, NULL))
1291 EC_GROUP_free(group);
1297 EC_GROUP_free(group);