diff --git a/ChangeLog b/ChangeLog index 304202a694458bd2acacd380fbc6253456d6df36..c196335c7ea5d688aa8e09a70478d353ad3c9f09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-09-17 Niels Möller <nisse@lysator.liu.se> + + * testsuite/curve25519-dup-test.c: Deleted file. In the way for + conversion to Edwards coordiante convention, and in the end + the tests will be done by ecc-dup-test.c. + * testsuite/curve25519-add-test.c: Similarly deleted. + * testsuite/Makefile.in (TS_HOGWEED_SOURCES): Removed + curve25519-dup-test.c and curve25519-add-test.c. + 2014-09-16 Niels Möller <nisse@lysator.liu.se> * testsuite/ecc-add-test.c: New generalized testcase, to replace diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index 9ca9000cabe43435d75556d1df59e3cc92d5bb40..a5c5458c205cda6c6dd2d0703f000f98c5050d42 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -38,7 +38,6 @@ TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \ pkcs1-test.c \ rsa-test.c rsa-encrypt-test.c rsa-keygen-test.c \ dsa-test.c dsa-keygen-test.c \ - curve25519-dup-test.c curve25519-add-test.c \ curve25519-dh-test.c \ ecc-mod-test.c ecc-modinv-test.c ecc-redc-test.c \ ecc-dup-test.c ecc-add-test.c \ diff --git a/testsuite/curve25519-add-test.c b/testsuite/curve25519-add-test.c deleted file mode 100644 index cee6b51df2ebed7a94be9c771128c72e57350284..0000000000000000000000000000000000000000 --- a/testsuite/curve25519-add-test.c +++ /dev/null @@ -1,136 +0,0 @@ -#include "testutils.h" - -static int -point_zero_p (const struct ecc_curve *ecc, const mp_limb_t *p) -{ - mp_limb_t *d; - int ret; - mp_size_t i; - d = xalloc_limbs (ecc->size); - ecc_modp_sub (ecc, d, p + ecc->size, p + 2*ecc->size); - while (mpn_cmp (d, ecc->p, ecc->size) >= 0) - mpn_sub_n (d, d, ecc->p, ecc->size); - - for (i = 0, ret = 1; i < ecc->size; i++) - if (d[i]) - { - ret = 0; - break; - } - - free (d); - return ret; -} - -void -test_main (void) -{ - const struct ecc_curve *ecc = &nettle_curve25519; - mp_limb_t *g; - mp_limb_t *z; - mp_limb_t *g2; - mp_limb_t *g3; - mp_limb_t *g4; - mp_limb_t *pe; - mp_limb_t *pa; - mp_limb_t *scratch; - const struct ecc_ref_point rg = - { - "9", - "20ae19a1b8a086b4e01edd2c7748d14c923d4d7e6d7c61b229e9c5a27eced3d9" - }; - const struct ecc_ref_point rg2 = - { /* In Edwards coordinates: - x = 0x1a1c31f8665368131698fecfd54233fcdc638bb46d25cc61d8bc4bcdbfbb4459, - y = 0x2260cdf3092329c21da25ee8c9a21f5697390f51643851560e5f46ae6af8a3c9 - */ - "20d342d51873f1b7d9750c687d157114" - "8f3f5ced1e350b5c5cae469cdd684efb", - "13b57e011700e8ae050a00945d2ba2f3" - "77659eb28d8d391ebcd70465c72df563" - }; - const struct ecc_ref_point rg3 = - { - "1c12bc1a6d57abe645534d91c21bba64" - "f8824e67621c0859c00a03affb713c12", - "2986855cbe387eaeaceea446532c338c" - "536af570f71ef7cf75c665019c41222b" - }; - const struct ecc_ref_point rg4 = - { - "79ce98b7e0689d7de7d1d074a15b315f" - "fe1805dfcd5d2a230fee85e4550013ef", - "075af5bf4ebdc75c8fe26873427d275d" - "73c0fb13da361077a565539f46de1c30" - }; - - g = xalloc_limbs (ecc_size_j (ecc)); - z = xalloc_limbs (ecc_size_j (ecc)); - g2 = xalloc_limbs (ecc_size_j (ecc)); - g3 = xalloc_limbs (ecc_size_j (ecc)); - g4 = xalloc_limbs (ecc_size_j (ecc)); - pe = xalloc_limbs (ecc_size_j (ecc)); - pa = xalloc_limbs (ecc_size_j (ecc)); - scratch = xalloc_limbs (ECC_ADD_EHH_ITCH(ecc->size)); - - mpn_copyi (g, ecc->g, 2*ecc->size); - g[2*ecc->size] = 1; - mpn_zero (g+2*ecc->size + 1, ecc->size - 1); - - /* Zero point has x = 0, y = 1, z = 1 */ - mpn_zero (z, 3*ecc->size); - z[ecc->size] = z[2*ecc->size] = 1; - - ecc_add_ehh (ecc, pe, z, z, scratch); - if (!point_zero_p (ecc, pe)) - die ("dup of zero point failed.\n"); - - ecc_add_eh (ecc, pe, z, z, scratch); - if (!point_zero_p (ecc, pe)) - die ("dup of zero point failed.\n"); - - ecc_add_ehh (ecc, pe, g, pe, scratch); - ecc_eh_to_a (ecc, 0, pa, pe, scratch); - test_ecc_point (ecc, &rg, pa); - - ecc_add_eh (ecc, pe, z, g, scratch); - ecc_eh_to_a (ecc, 0, pa, pe, scratch); - test_ecc_point (ecc, &rg, pa); - - ecc_add_ehh (ecc, g2, g, pe, scratch); - ecc_eh_to_a (ecc, 0, pa, g2, scratch); - test_ecc_point (ecc, &rg2, pa); - - ecc_add_eh (ecc, g2, g, g, scratch); - ecc_eh_to_a (ecc, 0, pa, g2, scratch); - test_ecc_point (ecc, &rg2, pa); - - ecc_add_ehh (ecc, g3, g, g2, scratch); - ecc_eh_to_a (ecc, 0, pa, g3, scratch); - test_ecc_point (ecc, &rg3, pa); - - ecc_add_eh (ecc, g3, g2, g, scratch); - ecc_eh_to_a (ecc, 0, pa, g3, scratch); - test_ecc_point (ecc, &rg3, pa); - - ecc_add_ehh (ecc, g4, g, g3, scratch); - ecc_eh_to_a (ecc, 0, pa, g4, scratch); - test_ecc_point (ecc, &rg4, pa); - - ecc_add_eh (ecc, g4, g3, g, scratch); - ecc_eh_to_a (ecc, 0, pa, g4, scratch); - test_ecc_point (ecc, &rg4, pa); - - ecc_add_ehh (ecc, g4, g2, g2, scratch); - ecc_eh_to_a (ecc, 0, pa, g4, scratch); - test_ecc_point (ecc, &rg4, pa); - - free (g); - free (z); - free (g2); - free (g3); - free (g4); - free (pe); - free (pa); - free (scratch); -} diff --git a/testsuite/curve25519-dup-test.c b/testsuite/curve25519-dup-test.c deleted file mode 100644 index 2490900b4637d66102b9922f35a30c0aecd1f2d8..0000000000000000000000000000000000000000 --- a/testsuite/curve25519-dup-test.c +++ /dev/null @@ -1,85 +0,0 @@ -#include "testutils.h" - -static int -point_zero_p (const struct ecc_curve *ecc, const mp_limb_t *p) -{ - mp_limb_t *d; - int ret; - mp_size_t i; - d = xalloc_limbs (ecc->size); - ecc_modp_sub (ecc, d, p + ecc->size, p + 2*ecc->size); - while (mpn_cmp (d, ecc->p, ecc->size) >= 0) - mpn_sub_n (d, d, ecc->p, ecc->size); - - for (i = 0, ret = 1; i < ecc->size; i++) - if (d[i]) - { - ret = 0; - break; - } - - free (d); - return ret; -} - -void -test_main (void) -{ - const struct ecc_curve *ecc = &nettle_curve25519; - mp_limb_t *g; - mp_limb_t *z; - mp_limb_t *pe; - mp_limb_t *pa; - mp_limb_t *scratch; - const struct ecc_ref_point g2 = - { /* In Edwards coordinates: - x = 0x1a1c31f8665368131698fecfd54233fcdc638bb46d25cc61d8bc4bcdbfbb4459, - y = 0x2260cdf3092329c21da25ee8c9a21f5697390f51643851560e5f46ae6af8a3c9 - */ - "20d342d51873f1b7d9750c687d157114" - "8f3f5ced1e350b5c5cae469cdd684efb", - "13b57e011700e8ae050a00945d2ba2f3" - "77659eb28d8d391ebcd70465c72df563" - }; - const struct ecc_ref_point g4 = - { - "79ce98b7e0689d7de7d1d074a15b315f" - "fe1805dfcd5d2a230fee85e4550013ef", - "075af5bf4ebdc75c8fe26873427d275d" - "73c0fb13da361077a565539f46de1c30" - }; - - g = xalloc_limbs (ecc_size_j (ecc)); - z = xalloc_limbs (ecc_size_j (ecc)); - pe = xalloc_limbs (ecc_size_j (ecc)); - pa = xalloc_limbs (ecc_size_j (ecc)); - scratch = xalloc_limbs (ECC_DUP_EH_ITCH(ecc->size)); - - mpn_copyi (g, ecc->g, 2*ecc->size); - g[2*ecc->size] = 1; - mpn_zero (g+2*ecc->size + 1, ecc->size - 1); - - /* Zero point has x = 0, y = 1, z = 1 */ - mpn_zero (z, 3*ecc->size); - z[ecc->size] = z[2*ecc->size] = 1; - - ecc_dup_eh (ecc, pe, z, scratch); - if (!point_zero_p (ecc, pe)) - die ("dup of zero point failed.\n"); - - ecc_dup_eh (ecc, pe, g, scratch); - - ecc_eh_to_a (ecc, 0, pa, pe, scratch); - test_ecc_point (ecc, &g2, pa); - - ecc_dup_eh (ecc, pe, pe, scratch); - - ecc_eh_to_a (ecc, 0, pa, pe, scratch); - test_ecc_point (ecc, &g4, pa); - - free (g); - free (z); - free (pe); - free (pa); - free (scratch); -}