Lines Matching refs:group

38 /* test multiplication with group order, long and negative scalars */
39 static int group_order_tests(EC_GROUP *group)
51 || !TEST_ptr(G = EC_GROUP_get0_generator(group))
52 || !TEST_ptr(P = EC_POINT_new(group))
53 || !TEST_ptr(Q = EC_POINT_new(group))
54 || !TEST_ptr(R = EC_POINT_new(group))
55 || !TEST_ptr(S = EC_POINT_new(group)))
58 if (!TEST_true(EC_GROUP_get_order(group, order, ctx))
59 || !TEST_true(EC_POINT_mul(group, Q, order, NULL, NULL, ctx))
60 || !TEST_true(EC_POINT_is_at_infinity(group, Q))
62 || !TEST_true(EC_GROUP_precompute_mult(group, ctx))
64 || !TEST_true(EC_POINT_mul(group, Q, order, NULL, NULL, ctx))
65 || !TEST_true(EC_POINT_is_at_infinity(group, Q))
68 || !TEST_true(EC_POINT_mul(group, Q, n1, NULL, NULL, ctx))
69 || !TEST_int_eq(0, EC_POINT_cmp(group, Q, P, ctx))
71 || !TEST_true(EC_POINT_mul(group, Q, n1, NULL, NULL, ctx))
72 || !TEST_true(EC_POINT_invert(group, Q, ctx))
73 || !TEST_int_eq(0, EC_POINT_cmp(group, Q, P, ctx)))
87 || !TEST_true(EC_POINT_mul(group, P, n1, NULL, NULL, ctx))
88 || (i == 1 && !TEST_int_eq(0, EC_POINT_cmp(group, P, G, ctx)))
92 || !TEST_true(EC_POINT_mul(group, Q, NULL, P, n1, ctx))
93 || !TEST_int_eq(0, EC_POINT_cmp(group, Q, P, ctx))
97 || !TEST_true(EC_POINT_mul(group, Q, NULL, P, n2, ctx))
98 || !TEST_int_eq(0, EC_POINT_cmp(group, Q, P, ctx))
102 || !TEST_true(EC_POINT_mul(group, Q, NULL, P, n2, ctx))
103 || !TEST_int_eq(0, EC_POINT_cmp(group, Q, P, ctx)))
108 if (!TEST_true(EC_POINT_mul(group, Q, NULL, P, n2, ctx))
110 || !TEST_true(EC_POINT_add(group, Q, Q, P, ctx))
111 || !TEST_true(EC_POINT_is_at_infinity(group, Q))
112 || !TEST_false(EC_POINT_is_at_infinity(group, P)))
120 if (!TEST_true(EC_POINTs_mul(group, R, NULL, 2, points, scalars, ctx))
121 || !TEST_true(EC_POINT_dbl(group, S, points[0], ctx))
122 || !TEST_int_eq(0, EC_POINT_cmp(group, R, S, ctx)))
137 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx))
138 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
163 EC_GROUP *group = NULL;
181 || !TEST_ptr(group = EC_GROUP_new_curve_GFp(p, a, b, ctx))
182 || !TEST_true(EC_GROUP_get_curve(group, p, a, b, ctx)))
192 if (!TEST_ptr(P = EC_POINT_new(group))
193 || !TEST_ptr(Q = EC_POINT_new(group))
194 || !TEST_ptr(R = EC_POINT_new(group))
195 || !TEST_true(EC_POINT_set_to_infinity(group, P))
196 || !TEST_true(EC_POINT_is_at_infinity(group, P))
197 || !TEST_true(EC_POINT_oct2point(group, Q, buf, 1, ctx))
198 || !TEST_true(EC_POINT_add(group, P, P, Q, ctx))
199 || !TEST_true(EC_POINT_is_at_infinity(group, P))
205 || !TEST_true(EC_POINT_set_compressed_coordinates(group, Q, x, 1, ctx)))
208 if (!TEST_int_gt(EC_POINT_is_on_curve(group, Q, ctx), 0)) {
209 if (!TEST_true(EC_POINT_get_affine_coordinates(group, Q, x, y, ctx)))
223 if (EC_POINT_is_at_infinity(group, P)) {
226 if (!TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y,
235 || !TEST_true(EC_POINT_add(group, P, P, Q, ctx)))
238 } while (!EC_POINT_is_at_infinity(group, P));
240 if (!TEST_true(EC_POINT_add(group, P, Q, R, ctx))
241 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
245 EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED, buf,
248 || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))
249 || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))
254 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED,
257 || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))
258 || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))
263 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID,
266 || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))
267 || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))
272 if (!TEST_true(EC_POINT_invert(group, P, ctx))
273 || !TEST_int_eq(0, EC_POINT_cmp(group, P, R, ctx))
287 || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
297 || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone,
299 || !TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx))
300 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
303 || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one()))
304 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
313 || !TEST_int_eq(EC_GROUP_get_degree(group), 160)
314 || !group_order_tests(group)
325 || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
328 || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx))
329 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
332 || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one()))
333 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
348 || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone,
350 || !TEST_int_eq(EC_GROUP_get_degree(group), 192)
351 || !group_order_tests(group)
362 || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
365 || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 0, ctx))
366 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
369 || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one()))
370 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
385 || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone,
387 || !TEST_int_eq(EC_GROUP_get_degree(group), 224)
388 || !group_order_tests(group)
399 || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
403 || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx))
404 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
407 || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one()))
408 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
423 || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone,
425 || !TEST_int_eq(EC_GROUP_get_degree(group), 256)
426 || !group_order_tests(group)
440 || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
445 || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx))
446 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
450 || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one()))
451 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
467 || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone,
469 || !TEST_int_eq(EC_GROUP_get_degree(group), 384)
470 || !group_order_tests(group)
489 || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
495 || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 0, ctx))
496 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
502 || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one()))
503 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
521 || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone,
523 || !TEST_int_eq(EC_GROUP_get_degree(group), 521)
524 || !group_order_tests(group)
529 || !TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx))
531 || !TEST_false(EC_POINT_is_at_infinity(group, Q))
532 || !TEST_true(EC_POINT_dbl(group, P, P, ctx))
533 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
534 || !TEST_true(EC_POINT_invert(group, Q, ctx)) /* P = -2Q */
535 || !TEST_true(EC_POINT_add(group, R, P, Q, ctx))
536 || !TEST_true(EC_POINT_add(group, R, R, Q, ctx))
537 || !TEST_true(EC_POINT_is_at_infinity(group, R)) /* R = P + 2Q */
538 || !TEST_false(EC_POINT_is_at_infinity(group, Q)))
548 if (!TEST_true(EC_GROUP_get_order(group, z, ctx))
554 scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
557 /* z is still the group order */
558 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
559 || !TEST_true(EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))
560 || !TEST_int_eq(0, EC_POINT_cmp(group, P, R, ctx))
561 || !TEST_int_eq(0, EC_POINT_cmp(group, R, Q, ctx))
569 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
570 || !TEST_true(EC_POINT_is_at_infinity(group, P))
584 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 4, points, scalars, ctx))
585 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
595 EC_GROUP_free(group);
785 EC_GROUP *group = NULL;
804 || !TEST_true(group = EC_GROUP_new_curve_GF2m(p, a, b, ctx))
805 || !TEST_ptr(P = EC_POINT_new(group))
806 || !TEST_ptr(Q = EC_POINT_new(group))
807 || !TEST_ptr(R = EC_POINT_new(group))
819 if (!TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, ctx))
820 || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x,
823 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
826 || !TEST_true(EC_GROUP_set_generator(group, P, z, cof))
827 || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx)))
841 if (!TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, ctx))
842 || !TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx))
843 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
846 || !TEST_true(EC_GROUP_set_generator(group, P, z, cof)))
853 if (!TEST_int_eq(EC_GROUP_get_degree(group), test->degree)
854 || !group_order_tests(group))
859 if (!TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx))
861 || !TEST_false(EC_POINT_is_at_infinity(group, Q))
862 || !TEST_true(EC_POINT_dbl(group, P, P, ctx))
863 || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0)
864 || !TEST_true(EC_POINT_invert(group, Q, ctx)) /* P = -2Q */
865 || !TEST_true(EC_POINT_add(group, R, P, Q, ctx))
866 || !TEST_true(EC_POINT_add(group, R, R, Q, ctx))
867 || !TEST_true(EC_POINT_is_at_infinity(group, R)) /* R = P + 2Q */
868 || !TEST_false(EC_POINT_is_at_infinity(group, Q)))
881 scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
884 /* z is still the group order */
885 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
886 || !TEST_true(EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))
887 || !TEST_int_eq(0, EC_POINT_cmp(group, P, R, ctx))
888 || !TEST_int_eq(0, EC_POINT_cmp(group, R, Q, ctx)))
898 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
899 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
910 if (!TEST_true(EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx))
911 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
930 EC_GROUP_free(group);
938 EC_GROUP *group = NULL;
954 if (!TEST_ptr(group = EC_GROUP_new_curve_GF2m(p, a, b, ctx))
955 || !TEST_true(EC_GROUP_get_curve(group, p, a, b, ctx)))
964 if (!TEST_ptr(P = EC_POINT_new(group))
965 || !TEST_ptr(Q = EC_POINT_new(group))
966 || !TEST_ptr(R = EC_POINT_new(group))
967 || !TEST_true(EC_POINT_set_to_infinity(group, P))
968 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
972 if (!TEST_true(EC_POINT_oct2point(group, Q, buf, 1, ctx))
973 || !TEST_true(EC_POINT_add(group, P, P, Q, ctx))
974 || !TEST_true(EC_POINT_is_at_infinity(group, P))
983 || !TEST_true(EC_POINT_set_compressed_coordinates(group, Q, x, 1, ctx))
986 || !TEST_true(EC_POINT_set_affine_coordinates(group, Q, x, y, ctx))
990 if (!TEST_int_gt(EC_POINT_is_on_curve(group, Q, ctx), 0)) {
993 if (!TEST_true(EC_POINT_get_affine_coordinates(group, Q, x, y, ctx)))
1008 if (EC_POINT_is_at_infinity(group, P))
1011 if (!TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y,
1020 || !TEST_true(EC_POINT_add(group, P, P, Q, ctx)))
1023 while (!EC_POINT_is_at_infinity(group, P));
1025 if (!TEST_true(EC_POINT_add(group, P, Q, R, ctx))
1026 || !TEST_true(EC_POINT_is_at_infinity(group, P)))
1031 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_COMPRESSED,
1034 || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))
1035 || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))
1041 len = EC_POINT_point2oct(group, Q, POINT_CONVERSION_UNCOMPRESSED,
1044 || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))
1045 || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))
1053 EC_POINT_point2oct(group, Q, POINT_CONVERSION_HYBRID, buf, sizeof(buf),
1056 || !TEST_true(EC_POINT_oct2point(group, P, buf, len, ctx))
1057 || !TEST_int_eq(0, EC_POINT_cmp(group, P, Q, ctx)))
1063 if (!TEST_true(EC_POINT_invert(group, P, ctx))
1064 || !TEST_int_eq(0, EC_POINT_cmp(group, P, R, ctx)))
1075 EC_GROUP_free(group);
1090 EC_GROUP *group = NULL;
1098 || !TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_sect571k1))
1099 || !TEST_ptr(point = EC_POINT_new(group))
1100 || !TEST_true(EC_POINT_set_affine_coordinates(group, point, x, y, NULL))
1101 || !TEST_size_t_ne(0, (len = EC_POINT_point2oct(group,
1108 || !TEST_size_t_eq(len, EC_POINT_point2oct(group,
1119 if (!TEST_true(EC_POINT_oct2point(group, point, buf, len, NULL)))
1124 if (!TEST_false(EC_POINT_oct2point(group, point, buf, len, NULL)))
1130 EC_GROUP_free(group);
1139 EC_GROUP *group = NULL;
1142 if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))) {
1147 if (!TEST_true(EC_GROUP_check(group, NULL))) {
1149 EC_GROUP_free(group);
1152 EC_GROUP_free(group);
1159 EC_GROUP *group;
1161 if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))) {
1165 r = group_order_tests(group);
1166 EC_GROUP_free(group);
1494 * This test validates a named curve's group parameters using
1496 * group parameters results in the curve not being valid.
1501 EC_GROUP *group = NULL, *gtest = NULL;
1516 || !TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))
1517 || !TEST_ptr(gtest = EC_GROUP_dup(group))
1522 || !TEST_ptr(group_gen = EC_GROUP_get0_generator(group))
1523 || !TEST_ptr(group_order = EC_GROUP_get0_order(group))
1524 || !TEST_true(EC_GROUP_get_cofactor(group, group_cofactor, NULL))
1525 || !TEST_true(EC_GROUP_get_curve(group, group_p, group_a, group_b, NULL))
1526 || !TEST_ptr(other_gen = EC_POINT_dup(group_gen, group))
1527 || !TEST_true(EC_POINT_add(group, other_gen, group_gen, group_gen, NULL))
1539 has_seed = (EC_GROUP_get_seed_len(group) > 0);
1540 field_nid = EC_GROUP_get_field_type(group);
1561 if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), nid)
1563 || !TEST_int_eq(EC_GROUP_check_named_curve(group, 1, NULL),
1568 EC_GROUP_set_curve_name(group, nid + 1);
1570 if (!TEST_int_le(EC_GROUP_check_named_curve(group, 0, NULL), 0))
1575 EC_GROUP_set_curve_name(group, nid);
1576 if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), nid))
1579 if (!TEST_int_eq(EC_GROUP_set_seed(group, invalid_seed, invalid_seed_len),
1588 if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), 0))
1595 if (!TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), nid))
1599 if (!TEST_int_eq(EC_GROUP_set_seed(group, NULL, 0), 1)
1600 || !TEST_int_eq(EC_GROUP_check_named_curve(group, 0, NULL), nid))
1603 /* Check that a duped group passes */
1682 EC_GROUP_free(group);
1689 * when the given group was created with explicit parameters.
1708 /* replace with group from explicit parameters */
1718 * fail if the returned nid is not an alias of the original group.
1729 /* replace with group from explicit parameters, then compare */
1824 EC_GROUP *group = NULL, *tgroup = NULL, *tmpg = NULL;
1853 /* Generate reference group and params */
1854 || !TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))
1855 || !TEST_ptr(params = EC_GROUP_get_ecparameters(group, NULL))
1856 || !TEST_ptr(group_gen = EC_GROUP_get0_generator(group))
1857 || !TEST_ptr(group_order = EC_GROUP_get0_order(group))
1858 || !TEST_true(EC_GROUP_get_cofactor(group, group_cofactor, NULL))
1860 || !TEST_ptr(tmpg = EC_GROUP_dup(group))
1861 || !TEST_ptr(other_gen = EC_POINT_dup(group_gen, group))
1862 || !TEST_true(EC_POINT_add(group, other_gen, group_gen, group_gen, NULL))
1863 || !TEST_true(EC_POINT_get_affine_coordinates(group, other_gen,
1887 * Creating a group from built-in explicit parameters returns a
1907 * group.
1925 * expect a "named" group.
1944 if (/* Other gen, same group order & cofactor */
2007 EC_GROUP_free(group);
2016 EC_GROUP *group = NULL, *group2 = NULL;
2021 if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_secp384r1))
2022 || !TEST_ptr(ecparameters = EC_GROUP_get_ecparameters(group, NULL))
2024 || !TEST_int_eq(EC_GROUP_cmp(group, group2, NULL), 0))
2027 EC_GROUP_free(group);
2028 group = NULL;
2031 if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_secp521r1))
2032 || !TEST_true((len = i2d_ECPKParameters(group, &buf)) >= 0)
2043 EC_GROUP_set_asn1_flag(group, OPENSSL_EC_EXPLICIT_CURVE);
2044 if (!TEST_true((len = i2d_ECPKParameters(group, &buf)) >= 0)
2050 EC_GROUP_free(group);
2127 EC_GROUP *group = NULL;
2133 if (!TEST_ptr(group = d2i_ECPKParameters(NULL, &b1, sizeof(params_cf_fail)))
2134 || !TEST_BN_eq_zero(EC_GROUP_get0_cofactor(group))
2135 || !TEST_ptr(group = d2i_ECPKParameters(&group, &b2,
2138 || !TEST_BN_eq(cf, EC_GROUP_get0_cofactor(group)))
2143 EC_GROUP_free(group);
2240 const EC_GROUP *group = NULL;
2248 || !TEST_ptr(group = EC_KEY_get0_group(key))
2249 || !TEST_ptr(field = EC_GROUP_get0_field(group))
2253 || !TEST_int_gt(EC_POINT_get_affine_coordinates(group, pub, x, y,
2261 type = EC_GROUP_get_field_type(group);
2293 * (group,P) pair.
2298 int ec_point_hex2point_test_helper(const EC_GROUP *group, const EC_POINT *P,
2308 if (!TEST_ptr(Pinf = EC_POINT_new(group))
2309 || !TEST_true(EC_POINT_set_to_infinity(group, Pinf)))
2314 if (!TEST_ptr(hex = EC_POINT_point2hex(group, P, form, bnctx))
2315 || !TEST_ptr(Q = EC_POINT_hex2point(group, hex, NULL, bnctx))
2316 || !TEST_int_eq(0, EC_POINT_cmp(group, Q, P, bnctx)))
2326 && !TEST_true(EC_POINT_is_at_infinity(group, Q)))
2345 EC_GROUP *group = NULL;
2353 || !TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))
2354 || !TEST_ptr(G = EC_GROUP_get0_generator(group))
2355 || !TEST_ptr(P = EC_POINT_dup(G, group)))
2358 if (!TEST_true(ec_point_hex2point_test_helper(group, P,
2361 || !TEST_true(ec_point_hex2point_test_helper(group, NULL,
2364 || !TEST_true(ec_point_hex2point_test_helper(group, P,
2367 || !TEST_true(ec_point_hex2point_test_helper(group, NULL,
2370 || !TEST_true(ec_point_hex2point_test_helper(group, P,
2373 || !TEST_true(ec_point_hex2point_test_helper(group, NULL,
2382 EC_GROUP_free(group);
2388 static int do_test_custom_explicit_fromdata(EC_GROUP *group, BN_CTX *ctx,
2417 if (EC_GROUP_get_field_type(group) == NID_X9_62_prime_field) {
2422 if (EC_GROUP_get_basis_type(group) == NID_X9_62_tpBasis) {
2424 if (!TEST_true(EC_GROUP_get_trinomial_basis(group, &k1)))
2428 if (!TEST_true(EC_GROUP_get_pentanomial_basis(group, &k1, &k2, &k3)))
2433 if (!TEST_true(EC_GROUP_get_curve(group, p, a, b, ctx))
2441 if (EC_GROUP_get0_seed(group) != NULL) {
2443 OSSL_PKEY_PARAM_EC_SEED, EC_GROUP_get0_seed(group),
2444 EC_GROUP_get_seed_len(group))))
2447 if (EC_GROUP_get0_cofactor(group) != NULL) {
2449 EC_GROUP_get0_cofactor(group))))
2456 EC_GROUP_get0_order(group))))
2468 /* There should be no match to a group name since the generator changed */
2474 /* The encoding should be explicit as it has no group */
2502 || !TEST_BN_eq(order_out, EC_GROUP_get0_order(group)))
2505 if (EC_GROUP_get0_cofactor(group) != NULL) {
2508 || !TEST_BN_eq(cofactor_out, EC_GROUP_get0_cofactor(group)))
2511 if (EC_GROUP_get0_seed(group) != NULL) {
2514 || !TEST_mem_eq(buf, buf_len, EC_GROUP_get0_seed(group),
2515 EC_GROUP_get_seed_len(group)))
2519 if (EC_GROUP_get_field_type(group) == NID_X9_62_prime_field) {
2539 || !TEST_int_eq(EC_GROUP_get_degree(group), i_out)
2546 if (EC_GROUP_get_basis_type(group) == NID_X9_62_tpBasis) {
2614 EC_GROUP *group = NULL;
2628 if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid)))
2632 bsize = (EC_GROUP_get_degree(group) + 7) / 8;
2637 || !TEST_true(BN_rand(k, EC_GROUP_order_bits(group) - 1,
2641 || !TEST_ptr(G2 = EC_POINT_new(group))
2642 || !TEST_ptr(Q1 = EC_POINT_new(group))
2644 || !TEST_true(EC_POINT_mul(group, Q1, k, NULL, NULL, ctx))
2646 || !TEST_int_eq(EC_POINT_point2oct(group, Q1,
2650 || !TEST_int_eq(EC_POINT_point2oct(group, Q1,
2654 || !TEST_true(EC_POINT_dbl(group, G2, EC_GROUP_get0_generator(group),
2656 || !TEST_true(EC_GROUP_set_generator(group, G2,
2657 EC_GROUP_get0_order(group),
2658 EC_GROUP_get0_cofactor(group)))
2659 || !TEST_ptr(Q2 = EC_POINT_new(group))
2662 || !TEST_true(EC_POINT_mul(group, Q2, k, NULL, NULL, ctx))
2663 || !TEST_int_eq(EC_POINT_point2oct(group, Q2,
2667 || !TEST_int_eq(EC_POINT_point2oct(group, Q2,
2674 if (!do_test_custom_explicit_fromdata(group, ctx, b1, bsize))
2683 EC_GROUP_free(group);
2699 EC_GROUP *group = NULL, *altgroup = NULL;
2734 if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid)))
2737 is_prime = EC_GROUP_get_field_type(group) == NID_X9_62_prime_field;
2746 bsize = (EC_GROUP_get_degree(group) + 7) / 8;
2750 if (!TEST_true(EC_GROUP_get_curve(group, p, a, b, ctx))
2751 || !TEST_ptr(G2 = EC_POINT_new(group))
2753 || !TEST_true(EC_POINT_dbl(group, G2,
2754 EC_GROUP_get0_generator(group), ctx))
2756 || !TEST_int_eq(EC_POINT_point2oct(group, G2,
2760 || !TEST_int_eq(EC_POINT_point2oct(group, G2,
2763 || !TEST_ptr(z = EC_GROUP_get0_order(group))
2764 || !TEST_ptr(cof = EC_GROUP_get0_cofactor(group))
2768 /* create a new group using same params (but different generator) */
2781 EC_POINT_free(G2); /* discard G2 as it refers to the original group */
2790 if (/* allocate temporary points on group and altgroup */
2791 !TEST_ptr(Q1 = EC_POINT_new(group))
2794 || !TEST_true(BN_rand(k, EC_GROUP_order_bits(group) - 1,
2798 /* Q1 := kG on group */
2799 || !TEST_true(EC_POINT_mul(group, Q1, k, NULL, NULL, ctx))
2801 || !TEST_int_eq(EC_POINT_point2oct(group, Q1,
2804 || !TEST_int_eq(EC_POINT_point2oct(group, Q1,
2839 * We compute the pub key in the original group as we will later use it to
2840 * define a provider key in the built-in group.
2842 if (!TEST_true(EC_POINT_mul(group, Q1, priv1, NULL, NULL, ctx))
2843 || !TEST_int_eq(EC_POINT_point2oct(group, Q1,
2847 || !TEST_int_eq(EC_POINT_point2oct(group, Q1,
2953 EC_GROUP_free(group);