]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Delete sec_tabselect, use gmp's mpn_sec_tabselect instead.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 11 Oct 2022 18:27:39 +0000 (20:27 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 11 Oct 2022 18:27:39 +0000 (20:27 +0200)
ChangeLog
Makefile.in
ecc-internal.h
ecc-mul-a-eh.c
ecc-mul-a.c
ecc-mul-g-eh.c
ecc-mul-g.c
sec-tabselect.c [deleted file]

index d23e23e5e3b41fa17ea5fe1b28426d0e5742a80f..98dc40a44d7bc2625f1431b19ab0ce719866cf96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-10-11  Niels Möller  <nisse@lysator.liu.se>
+
+       * sec-tabselect.c (sec_tabselect): Delete file and function. All
+       callers updated to use gmp's mpn_sec_tabselect instead, which is
+       implemented in assembly on many platforms.
+
 2022-10-02  Niels Möller  <nisse@lysator.liu.se>
 
        * examples/ecc-benchmark.c (bench_curve): Add benchmarking of
index 73e2532353e8951e04ae5e837a3532f9994ff434..86b8a536e15012e7fdd445215f90f438d70e4cad 100644 (file)
@@ -194,7 +194,7 @@ hogweed_SOURCES = sexp.c sexp-format.c \
                  dsa2sexp.c sexp2dsa.c \
                  pgp-encode.c rsa2openpgp.c \
                  der-iterator.c der2rsa.c der2dsa.c \
-                 sec-add-1.c sec-sub-1.c sec-tabselect.c \
+                 sec-add-1.c sec-sub-1.c \
                  gmp-glue.c cnd-copy.c \
                  ecc-mod.c ecc-mod-inv.c \
                  ecc-mod-arith.c ecc-pp1-redc.c ecc-pm1-redc.c \
index 6201bf0522dd863aadbd356ca4e3eed57c6a3a45..be02de5f534d4e4f7660e721f30245e6aaa6a51e 100644 (file)
@@ -81,7 +81,6 @@
 #define cnd_copy _nettle_cnd_copy
 #define sec_add_1 _nettle_sec_add_1
 #define sec_sub_1 _nettle_sec_sub_1
-#define sec_tabselect _nettle_sec_tabselect
 #define sec_modinv _nettle_sec_modinv
 #define curve25519_eh_to_x _nettle_curve25519_eh_to_x
 #define curve448_eh_to_x _nettle_curve448_eh_to_x
@@ -474,11 +473,6 @@ sec_add_1 (mp_limb_t *rp, mp_limb_t *ap, mp_size_t n, mp_limb_t b);
 mp_limb_t
 sec_sub_1 (mp_limb_t *rp, mp_limb_t *ap, mp_size_t n, mp_limb_t b);
 
-void
-sec_tabselect (mp_limb_t *rp, mp_size_t rn,
-              const mp_limb_t *table, unsigned tn,
-              unsigned k);
-
 void
 curve25519_eh_to_x (mp_limb_t *xp, const mp_limb_t *p,
                    mp_limb_t *scratch);
index 1eb3efccbde1495df65e64621573ee1a12345f2d..980fec3f715e7eb5abd09de6ae5b218c45e5e2b1 100644 (file)
@@ -140,7 +140,7 @@ ecc_mul_a_eh (const struct ecc_curve *ecc,
 
   assert (bits < TABLE_SIZE);
 
-  sec_tabselect (r, 3*ecc->p.size, table, TABLE_SIZE, bits);
+  mpn_sec_tabselect (r, table, 3*ecc->p.size, TABLE_SIZE, bits);
 
   for (;;)
     {
@@ -166,7 +166,7 @@ ecc_mul_a_eh (const struct ecc_curve *ecc,
        ecc->dup (ecc, r, r, scratch_out);
 
       bits &= TABLE_MASK;
-      sec_tabselect (tp, 3*ecc->p.size, table, TABLE_SIZE, bits);
+      mpn_sec_tabselect (tp, table, 3*ecc->p.size, TABLE_SIZE, bits);
       ecc->add_hhh (ecc, r, r, tp, scratch_out);
     }
 #undef table
index cb9c7d4186331c947e1608c4a4df9d9c33df01e3..8e1355ebc933457cfa9b0da797477c9c2f8b1155 100644 (file)
@@ -144,7 +144,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
 
   assert (bits < TABLE_SIZE);
 
-  sec_tabselect (r, 3*ecc->p.size, table, TABLE_SIZE, bits);
+  mpn_sec_tabselect (r, table, 3*ecc->p.size, TABLE_SIZE, bits);
   is_zero = (bits == 0);
 
   for (;;)
@@ -171,7 +171,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
        ecc_dup_jj (ecc, r, r, scratch_out);
 
       bits &= TABLE_MASK;
-      sec_tabselect (tp, 3*ecc->p.size, table, TABLE_SIZE, bits);
+      mpn_sec_tabselect (tp, table, 3*ecc->p.size, TABLE_SIZE, bits);
       cnd_copy (is_zero, r, tp, 3*ecc->p.size);
       ecc_add_jjj (ecc, tp, tp, r, scratch_out);
 
index 8b3ca8f88c228d3a611b6ff805c13a8f9f2e095c..57df1c6d08e4bcd913f92de2513ddc21a415ac97 100644 (file)
@@ -88,10 +88,10 @@ ecc_mul_g_eh (const struct ecc_curve *ecc, mp_limb_t *r,
              shift = bit_index % GMP_NUMB_BITS;
              bits = (bits << 1) | ((np[limb_index] >> shift) & 1);
            }
-         sec_tabselect (tp, 2*ecc->p.size,
-                        (ecc->pippenger_table
-                         + (2*ecc->p.size * (mp_size_t) j << c)),
-                        1<<c, bits);
+         mpn_sec_tabselect (tp,
+                            (ecc->pippenger_table
+                             + (2*ecc->p.size * (mp_size_t) j << c)),
+                             2*ecc->p.size, 1<<c, bits);
 
          ecc->add_hh (ecc, r, r, tp, scratch_out);
        }
index dcc7c3ea08d5cbf341279329dcd3eb14100f71fc..677a37e7a01979b516a5ce2007e5fae5e84d02d1 100644 (file)
@@ -88,10 +88,10 @@ ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r,
              shift = bit_index % GMP_NUMB_BITS;
              bits = (bits << 1) | ((np[limb_index] >> shift) & 1);
            }
-         sec_tabselect (tp, 2*ecc->p.size,
-                        (ecc->pippenger_table
-                         + (2*ecc->p.size * (mp_size_t) j << c)),
-                        1<<c, bits);
+         mpn_sec_tabselect (tp,
+                            (ecc->pippenger_table
+                             + (2*ecc->p.size * (mp_size_t) j << c)),
+                             2*ecc->p.size, 1<<c, bits);
          cnd_copy (is_zero, r, tp, 2*ecc->p.size);
          cnd_copy (is_zero, r + 2*ecc->p.size, ecc->unit, ecc->p.size);
          
diff --git a/sec-tabselect.c b/sec-tabselect.c
deleted file mode 100644 (file)
index e6bf228..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* sec-tabselect.c
-
-   Copyright (C) 2013 Niels Möller
-
-   This file is part of GNU Nettle.
-
-   GNU Nettle is free software: you can redistribute it and/or
-   modify it under the terms of either:
-
-     * the GNU Lesser General Public License as published by the Free
-       Software Foundation; either version 3 of the License, or (at your
-       option) any later version.
-
-   or
-
-     * the GNU General Public License as published by the Free
-       Software Foundation; either version 2 of the License, or (at your
-       option) any later version.
-
-   or both in parallel, as here.
-
-   GNU Nettle is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received copies of the GNU General Public License and
-   the GNU Lesser General Public License along with this program.  If
-   not, see http://www.gnu.org/licenses/.
-*/
-
-/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <assert.h>
-
-#include "ecc-internal.h"
-
-/* Copy the k'th element of the table out tn elements, each of size
-   rn. Always read complete table. Similar to gmp's mpn_tabselect. */
-/* FIXME: Should we need to volatile declare anything? */
-void
-sec_tabselect (mp_limb_t *rp, mp_size_t rn,
-              const mp_limb_t *table, unsigned tn,
-              unsigned k)
-{
-  const mp_limb_t *end = table + tn * rn;
-  const mp_limb_t *p;
-  mp_size_t i;
-  
-  assert (k < tn);
-  mpn_zero (rp, rn);
-  for (p = table; p < end; p += rn, k--)
-    {
-      mp_limb_t mask = - (mp_limb_t) (k == 0);
-      for (i = 0; i < rn; i++)
-       rp[i] += mask & p[i];
-    }
-}