diff --git a/ChangeLog b/ChangeLog index 8b2e04ac9c40835495a4a3eaaa1ab3f7da71681a..e5a3f1eb5161d59aae5cc06ba2129885b9a1007b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2014-09-22 Niels Möller <nisse@lysator.liu.se> + * testsuite/ecc-redc-test.c (test_main): Relaxed tests for which + tests to run. + * testsuite/ecc-modinv-test.c (test_modulo): New function, same organization as in ecc-mod-test.c below. diff --git a/testsuite/ecc-redc-test.c b/testsuite/ecc-redc-test.c index 98dc41e384829893f25100c8428eb3ab8a71b191..aa46fb8ee98380f282c9fb419c9e7b7e86aea6cd 100644 --- a/testsuite/ecc-redc-test.c +++ b/testsuite/ecc-redc-test.c @@ -57,9 +57,6 @@ test_main (void) { const struct ecc_curve *ecc = ecc_curves[i]; unsigned j; - if (ecc->p.reduce == ecc->p.mod) - continue; - ASSERT (ecc->p.redc_size != 0); for (j = 0; j < COUNT; j++) { @@ -72,38 +69,43 @@ test_main (void) ref_redc (ref, a, ecc->p.m, ecc->p.size); - mpn_copyi (m, a, 2*ecc->p.size); - ecc->p.reduce (&ecc->p, m); - if (mpn_cmp (m, ecc->p.m, ecc->p.size) >= 0) - mpn_sub_n (m, m, ecc->p.m, ecc->p.size); - - if (mpn_cmp (m, ref, ecc->p.size)) + if (ecc->p.reduce != ecc->p.mod) { - fprintf (stderr, "ecc->reduce failed: bit_size = %u\n", - ecc->p.bit_size); - gmp_fprintf (stderr, "a = %Nx\n", a, 2*ecc->p.size); - gmp_fprintf (stderr, "m = %Nx (bad)\n", m, ecc->p.size); - gmp_fprintf (stderr, "ref = %Nx\n", ref, ecc->p.size); - abort (); + mpn_copyi (m, a, 2*ecc->p.size); + ecc->p.reduce (&ecc->p, m); + if (mpn_cmp (m, ecc->p.m, ecc->p.size) >= 0) + mpn_sub_n (m, m, ecc->p.m, ecc->p.size); + + if (mpn_cmp (m, ref, ecc->p.size)) + { + fprintf (stderr, "ecc->p.reduce failed: bit_size = %u\n", + ecc->p.bit_size); + gmp_fprintf (stderr, "a = %Nx\n", a, 2*ecc->p.size); + gmp_fprintf (stderr, "m = %Nx (bad)\n", m, ecc->p.size); + gmp_fprintf (stderr, "ref = %Nx\n", ref, ecc->p.size); + abort (); + } } - - mpn_copyi (m, a, 2*ecc->p.size); - if (ecc->p.m[0] == 1) - ecc_pm1_redc (&ecc->p, m); - else - ecc_pp1_redc (&ecc->p, m); - - if (mpn_cmp (m, ecc->p.m, ecc->p.size) >= 0) - mpn_sub_n (m, m, ecc->p.m, ecc->p.size); - - if (mpn_cmp (m, ref, ecc->p.size)) - { - fprintf (stderr, "ecc_p%c1_redc failed: bit_size = %u\n", - (ecc->p.m[0] == 1) ? 'm' : 'p', ecc->p.bit_size); - gmp_fprintf (stderr, "a = %Nx\n", a, 2*ecc->p.size); - gmp_fprintf (stderr, "m = %Nx (bad)\n", m, ecc->p.size); - gmp_fprintf (stderr, "ref = %Nx\n", ref, ecc->p.size); - abort (); + if (ecc->p.redc_size != 0) + { + mpn_copyi (m, a, 2*ecc->p.size); + if (ecc->p.m[0] == 1) + ecc_pm1_redc (&ecc->p, m); + else + ecc_pp1_redc (&ecc->p, m); + + if (mpn_cmp (m, ecc->p.m, ecc->p.size) >= 0) + mpn_sub_n (m, m, ecc->p.m, ecc->p.size); + + if (mpn_cmp (m, ref, ecc->p.size)) + { + fprintf (stderr, "ecc_p%c1_redc failed: bit_size = %u\n", + (ecc->p.m[0] == 1) ? 'm' : 'p', ecc->p.bit_size); + gmp_fprintf (stderr, "a = %Nx\n", a, 2*ecc->p.size); + gmp_fprintf (stderr, "m = %Nx (bad)\n", m, ecc->p.size); + gmp_fprintf (stderr, "ref = %Nx\n", ref, ecc->p.size); + abort (); + } } } }