Deleted redc function pointer.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 22 Sep 2014 12:18:05 +0000 (14:18 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 22 Sep 2014 12:18:05 +0000 (14:18 +0200)
ChangeLog
ecc-192.c
ecc-224.c
ecc-25519.c
ecc-256.c
ecc-384.c
ecc-521.c
ecc-internal.h
ecc-j-to-a.c
examples/ecc-benchmark.c
testsuite/ecc-redc-test.c

index 21aaca6670ce32d492a6a0e38ca6708ea79d984f..8d1cd60e13f45ce7992593967efee46b0c6982e5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-09-22  Niels Möller  <nisse@lysator.liu.se>
 
+       * ecc-internal.h (struct ecc_curve): Deleted redc function
+       pointer. Use only reduce pointer, which is redc or modp as
+       applicable. Updated all users.
+
        * ecc-generic-modp.c (ecc_generic_modp): Deleted file and
        function. We no longer need a wrapper around ecc_mod.
        * ecc-generic-modq.c (ecc_generic_modq): Likewise deleted.
index c9bcf8fe239d7fd70ffe75c8b3557e36e9b74985..347cdec13c186523dadaf1052d31da082ed8585e 100644 (file)
--- a/ecc-192.c
+++ b/ecc-192.c
@@ -143,7 +143,6 @@ const struct ecc_curve nettle_secp_192r1 =
   ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
 
   ecc_192_modp,
-  ECC_REDC_SIZE >= 1 ? ecc_pp1_redc : NULL,
   ecc_192_modp,
   ecc_mod,
 
index 72f9fc7b6c718a7a455acaad79fcdafdd2a087df..a5bed64ac513888f8ae72190f27f2626c5ea80ee 100644 (file)
--- a/ecc-224.c
+++ b/ecc-224.c
@@ -95,7 +95,6 @@ const struct ecc_curve nettle_secp_224r1 =
   ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
 
   ecc_224_modp,
-  ecc_224_redc,
   USE_REDC ? ecc_224_redc : ecc_224_modp,
   ecc_mod,
 
index 55083b88d1c4210964b8bee6313d6242d3d6b437..e973fc45d33d830b8b4bce7fc8cd13b5e355847e 100644 (file)
@@ -263,7 +263,6 @@ const struct ecc_curve nettle_curve25519 =
   ECC_EH_TO_A_ITCH (ECC_LIMB_SIZE),
 
   ecc_25519_modp,
-  NULL,
   ecc_25519_modp,
   ecc_25519_modq,
 
index a6ac4b6c520245ee044fb5571c5870aee2ce5148..a2a03fb5fd08515e40ae07a63946bbb468bdd5aa 100644 (file)
--- a/ecc-256.c
+++ b/ecc-256.c
@@ -258,7 +258,6 @@ const struct ecc_curve nettle_secp_256r1 =
   ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
 
   ecc_256_modp,
-  ecc_256_redc,
   USE_REDC ? ecc_256_redc : ecc_256_modp,
   ecc_256_modq,
 
index cd53f3d786121282477d51a01316011144fa7057..2493d36ea13f1e5978ec2e2ac3f3be1f5229f78e 100644 (file)
--- a/ecc-384.c
+++ b/ecc-384.c
@@ -180,7 +180,6 @@ const struct ecc_curve nettle_secp_384r1 =
   ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
 
   ecc_384_modp,
-  ECC_REDC_SIZE > 0 ? ecc_pp1_redc : NULL,
   ecc_384_modp,
   ecc_mod,
 
index 505f6e259aa017e1e98ee53c7a8c31190e5956e7..3876f6edda587600fa170a81cd65a2db7384edc1 100644 (file)
--- a/ecc-521.c
+++ b/ecc-521.c
@@ -108,7 +108,6 @@ const struct ecc_curve nettle_secp_521r1 =
   ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
 
   ecc_521_modp,
-  ECC_REDC_SIZE > 0 ? ecc_pp1_redc : NULL,
   ecc_521_modp,
   ecc_mod,
 
index 22ff181c8f35c034cd35eeb1c3463b6ac601a323..1088f25ae193f9b0332ca7a47231a2e88f6c74b7 100644 (file)
@@ -138,7 +138,6 @@ struct ecc_curve
   unsigned short h_to_a_itch;
 
   ecc_mod_func *modp;
-  ecc_mod_func *redc;
   ecc_mod_func *reduce;
   ecc_mod_func *modq;
 
index 874da294df21616c3d0cdec028be00ecdc7f2970..c862d2c41629708e9f585a5655747b750c770fd9 100644 (file)
@@ -73,16 +73,16 @@ ecc_j_to_a (const struct ecc_curve *ecc,
 
       mpn_copyi (up, p + 2*ecc->p.size, ecc->p.size);
       mpn_zero (up + ecc->p.size, ecc->p.size);
-      ecc->redc (&ecc->p, up);
+      ecc->reduce (&ecc->p, up);
       mpn_zero (up + ecc->p.size, ecc->p.size);
-      ecc->redc (&ecc->p, up);
+      ecc->reduce (&ecc->p, up);
 
       ecc_modp_inv (ecc, izp, up, up + ecc->p.size);
 
       /* Divide this common factor by B */
       mpn_copyi (izBp, izp, ecc->p.size);
       mpn_zero (izBp + ecc->p.size, ecc->p.size);
-      ecc->redc (&ecc->p, izBp);
+      ecc->reduce (&ecc->p, izBp);
 
       ecc_modp_mul (ecc, iz2p, izp, izBp);
     }
index 87642913c16ae72f85fd2f9675b5c3834672c9f2..e2b33c4af6e9e9060029eacd37c7e853e6a8561b 100644 (file)
@@ -154,11 +154,11 @@ bench_modp (void *p)
 }
 
 static void
-bench_redc (void *p)
+bench_reduce (void *p)
 {
   struct ecc_ctx *ctx = (struct ecc_ctx *) p;
   mpn_copyi (ctx->rp, ctx->ap, 2*ctx->ecc->p.size);
-  ctx->ecc->redc (&ctx->ecc->p, ctx->rp);
+  ctx->ecc->reduce (&ctx->ecc->p, ctx->rp);
 }
 
 static void
@@ -265,7 +265,7 @@ static void
 bench_curve (const struct ecc_curve *ecc)
 {
   struct ecc_ctx ctx;  
-  double modp, redc, modq, modinv, modinv_gcd, modinv_powm,
+  double modp, reduce, modq, modinv, modinv_gcd, modinv_powm,
     dup_jj, add_jja, add_hhh,
     mul_g, mul_a;
 
@@ -299,7 +299,7 @@ bench_curve (const struct ecc_curve *ecc)
   ctx.bp[3*ecc->p.size - 1] &= mask;
 
   modp = time_function (bench_modp, &ctx);
-  redc = ecc->redc ? time_function (bench_redc, &ctx) : 0;
+  reduce = time_function (bench_reduce, &ctx);
 
   modq = time_function (bench_modq, &ctx);
 
@@ -335,7 +335,7 @@ bench_curve (const struct ecc_curve *ecc)
   free (ctx.tp);
 
   printf ("%4d %6.4f %6.4f %6.4f %6.2f %6.3f %6.2f %6.3f %6.3f %6.3f %6.1f %6.1f\n",
-         ecc->p.bit_size, 1e6 * modp, 1e6 * redc, 1e6 * modq,
+         ecc->p.bit_size, 1e6 * modp, 1e6 * reduce, 1e6 * modq,
          1e6 * modinv, 1e6 * modinv_gcd, 1e6 * modinv_powm,
          1e6 * dup_jj, 1e6 * add_jja, 1e6 * add_hhh,
          1e6 * mul_g, 1e6 * mul_a);
@@ -359,7 +359,7 @@ main (int argc UNUSED, char **argv UNUSED)
 
   time_init();
   printf ("%4s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s %6s (us)\n",
-         "size", "modp", "redc", "modq", "modinv", "mi_gcd", "mi_pow",
+         "size", "modp", "reduce", "modq", "modinv", "mi_gcd", "mi_pow",
          "dup_jj", "ad_jja", "ad_hhh",
          "mul_g", "mul_a");
   for (i = 0; i < numberof (curves); i++)
index a561ea9cd9a5df8aa06bce3cedb5068377da4f26..96b58d46a8b99f478c07301202fc4f86352ecdca 100644 (file)
@@ -57,7 +57,7 @@ test_main (void)
     {
       const struct ecc_curve *ecc = ecc_curves[i];
       unsigned j;
-      if (!ecc->redc)
+      if (ecc->reduce == ecc->modp)
        continue;
       ASSERT (ecc->p.redc_size != 0);
 
@@ -73,13 +73,13 @@ test_main (void)
          ref_redc (ref, a, ecc->p.m, ecc->p.size);
 
          mpn_copyi (m, a, 2*ecc->p.size);
-         ecc->redc (&ecc->p, m);
+         ecc->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->redc failed: bit_size = %u\n",
+             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);