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.
ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
ecc_192_modp,
- ECC_REDC_SIZE >= 1 ? ecc_pp1_redc : NULL,
ecc_192_modp,
ecc_mod,
ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
ecc_224_modp,
- ecc_224_redc,
USE_REDC ? ecc_224_redc : ecc_224_modp,
ecc_mod,
ECC_EH_TO_A_ITCH (ECC_LIMB_SIZE),
ecc_25519_modp,
- NULL,
ecc_25519_modp,
ecc_25519_modq,
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,
ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
ecc_384_modp,
- ECC_REDC_SIZE > 0 ? ecc_pp1_redc : NULL,
ecc_384_modp,
ecc_mod,
ECC_J_TO_A_ITCH (ECC_LIMB_SIZE),
ecc_521_modp,
- ECC_REDC_SIZE > 0 ? ecc_pp1_redc : NULL,
ecc_521_modp,
ecc_mod,
unsigned short h_to_a_itch;
ecc_mod_func *modp;
- ecc_mod_func *redc;
ecc_mod_func *reduce;
ecc_mod_func *modq;
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);
}
}
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
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;
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);
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);
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++)
{
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);
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);