]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Reduce duplication in ecc-dup-test.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 23 Sep 2017 09:01:39 +0000 (11:01 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 23 Sep 2017 09:01:39 +0000 (11:01 +0200)
* testsuite/ecc-dup-test.c (test_main): Reduce test duplication.
Use ecc->dup_itch.

ChangeLog
testsuite/ecc-dup-test.c

index 123860194c1c11c7a6535a7174553c9a3add6fae..1647625513998065fa13c6f8dd270157b50c058b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        * testsuite/ecc-add-test.c (test_main): Reduce test duplication.
        Use ecc->add_hhh_itch.
+       * testsuite/ecc-dup-test.c (test_main): Reduce test duplication.
+       Use ecc->dup_itch.
 
 2017-09-23  Daiki Ueno  <dueno@redhat.com>
 
index f987b165150e6f5fa18088c7bf39fa3e452af991..0ae4444a7cb0da540424679dcead6428310aeffc 100644 (file)
@@ -10,37 +10,34 @@ test_main (void)
       const struct ecc_curve *ecc = ecc_curves[i];
       mp_limb_t *g = xalloc_limbs (ecc_size_j (ecc));
       mp_limb_t *p = xalloc_limbs (ecc_size_j (ecc));
-      mp_limb_t *scratch = xalloc_limbs (ECC_DUP_EH_ITCH(ecc->p.size));;
+      mp_limb_t *scratch = xalloc_limbs (ecc->dup_itch);
+
+      ecc_a_to_j (ecc, g, ecc->g);
 
       if (ecc->p.bit_size == 255)
        {
          mp_limb_t *z = xalloc_limbs (ecc_size_j (ecc));
+
+         ASSERT (ecc->dup == ecc_dup_eh);
+
          /* Zero point has x = 0, y = 1, z = 1 */
          mpn_zero (z, 3*ecc->p.size);
          z[ecc->p.size] = z[2*ecc->p.size] = 1;
          
-         ecc_a_to_j (ecc, g, ecc->g);
-
          ecc->dup (ecc, p, z, scratch);
          test_ecc_mul_h (i, 0, p);
 
-         ecc->dup (ecc, p, g, scratch);
-         test_ecc_mul_h (i, 2, p);
-
-         ecc->dup (ecc, p, p, scratch);
-         test_ecc_mul_h (i, 4, p);
          free (z);
        }
       else
-       {
-         ecc_a_to_j (ecc, g, ecc->g);
+       ASSERT (ecc->dup == ecc_dup_jj);
 
-         ecc->dup (ecc, p, g, scratch);
-         test_ecc_mul_h (i, 2, p);
+      ecc->dup (ecc, p, g, scratch);
+      test_ecc_mul_h (i, 2, p);
+
+      ecc->dup (ecc, p, p, scratch);
+      test_ecc_mul_h (i, 4, p);
 
-         ecc->dup (ecc, p, p, scratch);
-         test_ecc_mul_h (i, 4, p);
-       }
       free (p);
       free (g);
       free (scratch);