From: Niels Möller Date: Mon, 22 Sep 2014 12:18:05 +0000 (+0200) Subject: Deleted redc function pointer. X-Git-Tag: nettle_3.1rc1~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46bfb297beb343b0b8dfbadf1dc8c28aa2fca69e;p=thirdparty%2Fnettle.git Deleted redc function pointer. --- diff --git a/ChangeLog b/ChangeLog index 21aaca66..8d1cd60e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2014-09-22 Niels Möller + * 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. diff --git a/ecc-192.c b/ecc-192.c index c9bcf8fe..347cdec1 100644 --- a/ecc-192.c +++ b/ecc-192.c @@ -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, diff --git a/ecc-224.c b/ecc-224.c index 72f9fc7b..a5bed64a 100644 --- a/ecc-224.c +++ b/ecc-224.c @@ -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, diff --git a/ecc-25519.c b/ecc-25519.c index 55083b88..e973fc45 100644 --- a/ecc-25519.c +++ b/ecc-25519.c @@ -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, diff --git a/ecc-256.c b/ecc-256.c index a6ac4b6c..a2a03fb5 100644 --- a/ecc-256.c +++ b/ecc-256.c @@ -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, diff --git a/ecc-384.c b/ecc-384.c index cd53f3d7..2493d36e 100644 --- a/ecc-384.c +++ b/ecc-384.c @@ -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, diff --git a/ecc-521.c b/ecc-521.c index 505f6e25..3876f6ed 100644 --- a/ecc-521.c +++ b/ecc-521.c @@ -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, diff --git a/ecc-internal.h b/ecc-internal.h index 22ff181c..1088f25a 100644 --- a/ecc-internal.h +++ b/ecc-internal.h @@ -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; diff --git a/ecc-j-to-a.c b/ecc-j-to-a.c index 874da294..c862d2c4 100644 --- a/ecc-j-to-a.c +++ b/ecc-j-to-a.c @@ -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); } diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c index 87642913..e2b33c4a 100644 --- a/examples/ecc-benchmark.c +++ b/examples/ecc-benchmark.c @@ -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++) diff --git a/testsuite/ecc-redc-test.c b/testsuite/ecc-redc-test.c index a561ea9c..96b58d46 100644 --- a/testsuite/ecc-redc-test.c +++ b/testsuite/ecc-redc-test.c @@ -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);