+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
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 \
#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
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);
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 (;;)
{
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
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 (;;)
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);
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);
}
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);
+++ /dev/null
-/* 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];
- }
-}