static struct test_curve test_curves[] = {
#if 2001
{ NID_id_GostR3410_2001_TestParamSet, },
+#endif
{ NID_id_GostR3410_2001_CryptoPro_A_ParamSet },
{ NID_id_GostR3410_2001_CryptoPro_B_ParamSet },
{ NID_id_GostR3410_2001_CryptoPro_C_ParamSet },
{ NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet },
{ NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet },
-#endif
- {
- NID_id_tc26_gost_3410_2012_512_paramSetA,
- "id-tc26-gost-3410-2012-512-paramSetA",
- },
- {
- NID_id_tc26_gost_3410_2012_512_paramSetB,
- "id-tc26-gost-3410-2012-512-paramSetB",
- },
- {
- NID_id_tc26_gost_3410_2012_512_paramSetC,
- "id-tc26-gost-3410-2012-512-paramSetC",
- },
- {
- NID_id_tc26_gost_3410_2012_256_paramSetA,
- "id-tc26-gost-3410-2012-256-paramSetA",
- },
+ { NID_id_tc26_gost_3410_2012_512_paramSetA, "id-tc26-gost-3410-2012-512-paramSetA", },
+ { NID_id_tc26_gost_3410_2012_512_paramSetB, "id-tc26-gost-3410-2012-512-paramSetB", },
+ { NID_id_tc26_gost_3410_2012_512_paramSetC, "id-tc26-gost-3410-2012-512-paramSetC", },
+ { NID_id_tc26_gost_3410_2012_256_paramSetA, "id-tc26-gost-3410-2012-256-paramSetA", },
+ { NID_id_tc26_gost_3410_2012_256_paramSetB, "id-tc26-gost-3410-2012-256-paramSetB", },
+ { NID_id_tc26_gost_3410_2012_256_paramSetC, "id-tc26-gost-3410-2012-256-paramSetC", },
+ { NID_id_tc26_gost_3410_2012_256_paramSetD, "id-tc26-gost-3410-2012-256-paramSetD", },
0,
};
T(p = BN_new());
T(a = BN_new());
T(b = BN_new());
- EC_GROUP_get_curve_GFp(group, p, a, b, ctx);
+ EC_GROUP_get_curve(group, p, a, b, ctx);
print_bn("p", p);
print_bn("a", a);
print_bn("b", b);
BIGNUM *x, *y;
T(x = BN_new());
T(y = BN_new());
- T(EC_POINT_get_affine_coordinates_GFp(group, generator, x, y, ctx));
+ T(EC_POINT_get_affine_coordinates(group, generator, x, y, ctx));
print_bn("x", x);
print_bn("y", y);
T(!BN_is_zero(y));
BN_mod_add(xxx, xxx, ax, p, ctx);
BN_mod_add(xxx, xxx, b, p, ctx);
T(BN_cmp(yy, xxx) == 0);
+ BN_free(yy);
+ BN_free(r);
+ BN_free(xxx);
+ BN_free(ax);
+ BN_free(p);
+ BN_free(a);
+ BN_free(b);
+ BN_free(x);
+ BN_free(y);
/* Check order */
const BIGNUM *order;
T(order = EC_GROUP_get0_order(group));
T(!BN_is_zero(order));
- print_bn("m", order);
- T(!BN_is_zero(order));
+ print_bn("q", order);
+ T(BN_is_odd(order));
EC_POINT *point;
T((point = EC_POINT_new(group)));
T(EC_POINT_mul(group, point, NULL, generator, order, ctx));
/* generator * order is the point at infinity? */
T(EC_POINT_is_at_infinity(group, point) == 1);
+ EC_POINT_free(point);
/* Check if order is cyclic */
BIGNUM *k1 = BN_new();
BN_add(k2, k2, order);
T(EC_POINT_mul(group, p1, NULL, generator, k1, ctx));
T(EC_POINT_mul(group, p2, NULL, generator, k2, ctx));
+ T(EC_POINT_cmp(group, p1, p2, ctx) == 0);
+ BN_free(k1);
+ BN_free(k2);
+ EC_POINT_free(p1);
+ EC_POINT_free(p2);
/* Cofactor is 1 or 4 */
const BIGNUM *c;
T(c = EC_GROUP_get0_cofactor(group));
- if (BN_is_odd(order))
- T(BN_is_word(c, 1));
- else
- T(BN_is_word(c, 4));
+ T(BN_is_word(c, 1) || BN_is_word(c, 4));
+ BN_CTX_free(ctx);
+ EC_KEY_free(ec);
TEST_ASSERT(0);
return test;
}
{
int ret = 0;
+ setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
+ OPENSSL_add_all_algorithms_conf();
+ ERR_load_crypto_strings();
+ ENGINE *eng;
+ T(eng = ENGINE_by_id("gost"));
+ T(ENGINE_init(eng));
+ T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
+
struct test_curve *tc;
for (tc = test_curves; tc->nid; tc++) {
ret |= parameter_test(tc);
}
+ ENGINE_finish(eng);
+ ENGINE_free(eng);
+
if (ret)
printf(cDRED "= Some tests FAILED!\n" cNORM);
else