]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Deleted unused INITIAL argument for ecc_mul_a.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 23 Aug 2014 21:22:03 +0000 (23:22 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 23 Aug 2014 21:24:14 +0000 (23:24 +0200)
ChangeLog
ecc-ecdsa-verify.c
ecc-mul-a.c
ecc-point-mul.c
ecc.h
examples/ecc-benchmark.c
testsuite/ecc-mul-a-test.c

index 31dc3b1e62f7903ed5b23152961a056e9025f49f..3ba0c738a890616ceeb5af9700f168a57be5ccff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2014-08-23  Niels Möller  <nisse@lysator.liu.se>
 
+       * ecc-mul-a.c (ecc_mul_a): Deleted INITIAL argument, all callers,
+       except the tests, pass 1. Updated all callers.
+       (table_init): Likewise deleted INITIAL.
+       * ecc.h (ecc_mul_a): Updated prototype.
+       * testsuite/ecc-mul-a-test.c (test_main): Deleted tests for
+       ecc_mul_a with INITIAL == 0.
+
        * ecc-internal.h (struct ecc_curve): Reordered struct, moved
        function pointers before pointers to bignum constants.
 
index 6337d7bad24e0cc30f250b9507788438835a412e..1310b3125c206ad1ae9ba6135b3fc0bcbd0ca2a4 100644 (file)
@@ -114,7 +114,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
   ecc_modq_mul (ecc, u2, rp, sinv);
 
    /* Total storage: 5*ecc->size + ECC_MUL_A_ITCH (ecc->size) */
-  ecc_mul_a (ecc, 1, P2, u2, pp, u2 + ecc->size);
+  ecc_mul_a (ecc, P2, u2, pp, u2 + ecc->size);
 
   /* u1 = h / s, P1 = u1 * G */
   ecc_hash (ecc, hp, length, digest);
index 17bc6d2585f8a11dcb3f7a55aff5aee16bdb3f9c..6cfc8a48ef1e7b61cb5fe6523a8d824013defa47 100644 (file)
@@ -55,7 +55,7 @@ ecc_mul_a_itch (const struct ecc_curve *ecc)
 #if ECC_MUL_A_WBITS == 0
 void
 ecc_mul_a (const struct ecc_curve *ecc,
-          int initial, mp_limb_t *r,
+          mp_limb_t *r,
           const mp_limb_t *np, const mp_limb_t *p,
           mp_limb_t *scratch)
 {
@@ -67,7 +67,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
 
   unsigned i;
 
-  ecc_a_to_j (ecc, initial, pj, p);
+  ecc_a_to_j (ecc, 1, pj, p);
   mpn_zero (r, 3*ecc->size);
   
   for (i = ecc->size, is_zero = 1; i-- > 0; )
@@ -104,14 +104,14 @@ ecc_mul_a (const struct ecc_curve *ecc,
 static void
 table_init (const struct ecc_curve *ecc,
            mp_limb_t *table, unsigned bits,
-           int initial, const mp_limb_t *p,
+           const mp_limb_t *p,
            mp_limb_t *scratch)
 {
   unsigned size = 1 << bits;
   unsigned j;
 
   mpn_zero (TABLE(0), 3*ecc->size);
-  ecc_a_to_j (ecc, initial, TABLE(1), p);
+  ecc_a_to_j (ecc, 1, TABLE(1), p);
 
   for (j = 2; j < size; j += 2)
     {
@@ -122,7 +122,7 @@ table_init (const struct ecc_curve *ecc,
 
 void
 ecc_mul_a (const struct ecc_curve *ecc,
-          int initial, mp_limb_t *r,
+          mp_limb_t *r,
           const mp_limb_t *np, const mp_limb_t *p,
           mp_limb_t *scratch)
 {
@@ -140,7 +140,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
   unsigned shift = bit_index % GMP_NUMB_BITS;
   mp_limb_t w, bits;
 
-  table_init (ecc, table, ECC_MUL_A_WBITS, initial, p, scratch_out);
+  table_init (ecc, table, ECC_MUL_A_WBITS, p, scratch_out);
 
   w = np[limb_index];
   bits = w >> shift;
index d8329cf5112538e342dac44bed03c860b74c7923..09d4f642108b47a8032ce3f292ffd93c897bb543 100644 (file)
@@ -51,7 +51,7 @@ ecc_point_mul (struct ecc_point *r, const struct ecc_scalar *n,
   assert (n->ecc == p->ecc);
   assert (r->ecc == p->ecc);
 
-  ecc_mul_a (p->ecc, 1, scratch, n->p, p->p, scratch + 3*size);
+  ecc_mul_a (p->ecc, scratch, n->p, p->p, scratch + 3*size);
   ecc_j_to_a (r->ecc, 1, r->p, scratch, scratch + 3*size);
   gmp_free_limbs (scratch, itch);
 }
diff --git a/ecc.h b/ecc.h
index e2efbeb02e113ecae6332b9cab4f0912220c9a53..97de76e1e129b00306800dc9ac1babc1d9d30387 100644 (file)
--- a/ecc.h
+++ b/ecc.h
@@ -285,15 +285,13 @@ ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r,
           const mp_limb_t *np, mp_limb_t *scratch);
 
 /* Computes N * P. The scalar N is the same as for ecc_mul_g. P is a
-   non-zero point on the curve, in affine coordinates. Pass a non-zero
-   INITIAL if the point coordinates have not previously been converted
-   to Montgomery representation. Output R is a non-zero point, in
-   Jacobian coordinates. */
+   non-zero point on the curve, in affine coordinates. Output R is a
+   non-zero point, in Jacobian coordinates. */
 mp_size_t
 ecc_mul_a_itch (const struct ecc_curve *ecc);
 void
 ecc_mul_a (const struct ecc_curve *ecc,
-          int initial, mp_limb_t *r,
+          mp_limb_t *r,
           const mp_limb_t *np, const mp_limb_t *p,
           mp_limb_t *scratch);
 
index 51b560a0e5def714a472bd6ac050d8ede78fa8d6..0d4ee783cf8d21b25835b802f22d523a14896a32 100644 (file)
@@ -234,7 +234,7 @@ static void
 bench_mul_a (void *p)
 {
   struct ecc_ctx *ctx = (struct ecc_ctx *) p;
-  ecc_mul_a (ctx->ecc, 1, ctx->rp, ctx->ap, ctx->bp, ctx->tp);
+  ecc_mul_a (ctx->ecc, ctx->rp, ctx->ap, ctx->bp, ctx->tp);
 }
 
 static void
index eef09c725f018721862ff142fb0ce9be9fb642c9..e182aacc44e45e0fe126590bf45ff1d95276d4e0 100644 (file)
@@ -31,34 +31,21 @@ test_main (void)
       mpn_zero (n, size);
 
       n[0] = 1;
-      ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+      ecc_mul_a (ecc, p, n, ecc->g, scratch);
       ecc_j_to_a (ecc, 1, p, p, scratch);
 
       if (mpn_cmp (p, ecc->g, 2*size != 0))
        die ("curve %d: ecc_mul_a with n = 1 failed.\n", ecc->bit_size);
 
-      if (ecc->use_redc)
-       {
-         ecc_mul_a (ecc, 0, p, n, ecc->redc_g, scratch);
-         ecc_j_to_a (ecc, 1, p, p, scratch);
-
-         if (mpn_cmp (p, ecc->g, 2*size != 0))
-           die ("curve %d: ecc_mul_a with n = 1 and redc failed.\n", ecc->bit_size);
-       }
       for (n[0] = 2; n[0] <= 4; n[0]++)
        {
-         ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+         ecc_mul_a (ecc, p, n, ecc->g, scratch);
          test_ecc_mul_j (i, n[0], p);
-         if (ecc->use_redc)
-           {
-             ecc_mul_a (ecc, 0, p, n, ecc->redc_g, scratch);
-             test_ecc_mul_j (i, n[0], p);
-           }
        }
 
       /* (order - 1) * g = - g */
       mpn_sub_1 (n, ecc->q, size, 1);
-      ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+      ecc_mul_a (ecc, p, n, ecc->g, scratch);
       ecc_j_to_a (ecc, 1, p, p, scratch);
       mpn_sub_n (p + size, ecc->p, p + size, size);
       if (mpn_cmp (p, ecc->g, 2*size) != 0)
@@ -80,7 +67,7 @@ test_main (void)
          mpz_limbs_copy (n, r, size);
          n[size - 1] %= ecc->q[size - 1];
 
-         ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+         ecc_mul_a (ecc, p, n, ecc->g, scratch);
          ecc_j_to_a (ecc, 1, p, p, scratch);
 
          ecc_mul_g (ecc, q, n, scratch);