Commit 46bfb297 authored by Niels Möller's avatar Niels Möller

Deleted redc function pointer.

parent 89742b68
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.
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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++)
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment