Commit 2a224b1a authored by Davide Galassi's avatar Davide Galassi

ECP groups parameters load tests

parent b0766c1f
Pipeline #60826973 passed with stages
in 1 minute and 29 seconds
......@@ -693,7 +693,7 @@ static void ecp_grp_load(cry_ecp_grp *grp,
int cry_ecp_grp_load(cry_ecp_grp *grp, int grp_id)
{
int res;
int res = 0;
switch (grp_id) {
#ifdef CRY_ECP_GRP_SECP192R1_ENABLE
......
......@@ -39,7 +39,7 @@ static void point_check(const cry_ecp *p, const cry_ecp_grp *grp)
cry_mpi_clear_list(&v, &t, NULL);
}
static void ecp_add_test(void)
static void add_test(void)
{
cry_ecp_grp ec;
cry_ecp p;
......@@ -48,18 +48,18 @@ static void ecp_add_test(void)
load_simple_curve(&ec);
cry_ecp_init(&p);
do {
printf("n = %d\n", i);
cry_mpi_print(&p.x, 10);
cry_mpi_print(&p.y, 10);
cry_mpi_print(&p.z, 10);
//printf("n = %d\n", i);
//cry_mpi_print(&p.x, 10);
//cry_mpi_print(&p.y, 10);
//cry_mpi_print(&p.z, 10);
point_check(&p, &ec);
printf("--------------------\n");
//printf("--------------------\n");
cry_ecp_add(&p, &p, &ec.g, &ec);
i++;
} while (!cry_ecp_is_zero(&p));
}
static void ecp_mul_test(void)
static void mul_test(void)
{
cry_ecp_grp ec;
cry_ecp p;
......@@ -73,16 +73,146 @@ static void ecp_mul_test(void)
point_check(&p, &ec);
}
static void ecp_secp224r1_load_test()
static void secp192r1_load_test(void)
{
int res;
cry_ecp_grp grp;
cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP224R1);
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP192R1);
ASSERT(res == 0);
}
static void secp224r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP224R1);
ASSERT(res == 0);
}
static void secp256r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP256R1);
ASSERT(res == 0);
}
static void secp384r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP384R1);
ASSERT(res == 0);
}
static void secp521r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP521R1);
ASSERT(res == 0);
}
static void secp192k1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP192K1);
ASSERT(res == 0);
}
static void secp224k1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP224K1);
ASSERT(res == 0);
}
static void secp256k1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_SECP256K1);
ASSERT(res == 0);
}
static void bp256r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_BP256R1);
ASSERT(res == 0);
}
static void bp384r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_BP384R1);
ASSERT(res == 0);
}
static void bp512r1_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, CRY_ECP_GRP_BP512R1);
ASSERT(res == 0);
}
static void bad_curve_load_test(void)
{
int res;
cry_ecp_grp grp;
res = cry_ecp_grp_load(&grp, 0xFFFF);
ASSERT(res != 0);
}
static void curve_params_load(void)
{
RUN(secp192r1_load_test);
RUN(secp224r1_load_test);
RUN(secp256r1_load_test);
RUN(secp384r1_load_test);
RUN(secp521r1_load_test);
RUN(secp192k1_load_test);
RUN(secp224k1_load_test);
RUN(secp256k1_load_test);
RUN(bp256r1_load_test);
RUN(bp384r1_load_test);
RUN(bp512r1_load_test);
RUN(bad_curve_load_test);
}
void ecp_test(void)
{
ecp_secp224r1_load_test();
ecp_add_test();
ecp_mul_test();
printf("* ECP load curves parameters\n");
curve_params_load();
add_test();
mul_test();
}
......@@ -34,6 +34,8 @@ int raw_init(unsigned char *raw, size_t rawlen, const char *asc);
void run(const char *name, void (* test)(void),
void (* setup)(void), void (* teardown)(void));
#define RUN(test) run(#test, test, NULL, NULL)
#define ASSERT(test) do { \
if ((test) == 0) { \
g_fails++; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment