summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2014-08-23 23:22:03 +0200
committerNiels Möller <nisse@lysator.liu.se>2014-08-23 23:24:14 +0200
commit308c10895e695edd08b09453360b390b591c3c7e (patch)
treeb2d037a0c0ec772d4974fce8894bb61301c3ce2f
parentb9f98cb7360ddf563419ad236911347ba71a0961 (diff)
downloadnettle-308c10895e695edd08b09453360b390b591c3c7e.tar.gz
Deleted unused INITIAL argument for ecc_mul_a.
-rw-r--r--ChangeLog7
-rw-r--r--ecc-ecdsa-verify.c2
-rw-r--r--ecc-mul-a.c12
-rw-r--r--ecc-point-mul.c2
-rw-r--r--ecc.h8
-rw-r--r--examples/ecc-benchmark.c2
-rw-r--r--testsuite/ecc-mul-a-test.c21
7 files changed, 23 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 31dc3b1e..3ba0c738 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2014-08-23 Niels Möller <nisse@lysator.liu.se>
+ * ecc-mul-a.c (ecc_mul_a): Deleted INITIAL argument, all callers,
+ except the tests, pass 1. Updated all callers.
+ (table_init): Likewise deleted INITIAL.
+ * ecc.h (ecc_mul_a): Updated prototype.
+ * testsuite/ecc-mul-a-test.c (test_main): Deleted tests for
+ ecc_mul_a with INITIAL == 0.
+
* ecc-internal.h (struct ecc_curve): Reordered struct, moved
function pointers before pointers to bignum constants.
diff --git a/ecc-ecdsa-verify.c b/ecc-ecdsa-verify.c
index 6337d7ba..1310b312 100644
--- a/ecc-ecdsa-verify.c
+++ b/ecc-ecdsa-verify.c
@@ -114,7 +114,7 @@ ecc_ecdsa_verify (const struct ecc_curve *ecc,
ecc_modq_mul (ecc, u2, rp, sinv);
/* Total storage: 5*ecc->size + ECC_MUL_A_ITCH (ecc->size) */
- ecc_mul_a (ecc, 1, P2, u2, pp, u2 + ecc->size);
+ ecc_mul_a (ecc, P2, u2, pp, u2 + ecc->size);
/* u1 = h / s, P1 = u1 * G */
ecc_hash (ecc, hp, length, digest);
diff --git a/ecc-mul-a.c b/ecc-mul-a.c
index 17bc6d25..6cfc8a48 100644
--- a/ecc-mul-a.c
+++ b/ecc-mul-a.c
@@ -55,7 +55,7 @@ ecc_mul_a_itch (const struct ecc_curve *ecc)
#if ECC_MUL_A_WBITS == 0
void
ecc_mul_a (const struct ecc_curve *ecc,
- int initial, mp_limb_t *r,
+ mp_limb_t *r,
const mp_limb_t *np, const mp_limb_t *p,
mp_limb_t *scratch)
{
@@ -67,7 +67,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
unsigned i;
- ecc_a_to_j (ecc, initial, pj, p);
+ ecc_a_to_j (ecc, 1, pj, p);
mpn_zero (r, 3*ecc->size);
for (i = ecc->size, is_zero = 1; i-- > 0; )
@@ -104,14 +104,14 @@ ecc_mul_a (const struct ecc_curve *ecc,
static void
table_init (const struct ecc_curve *ecc,
mp_limb_t *table, unsigned bits,
- int initial, const mp_limb_t *p,
+ const mp_limb_t *p,
mp_limb_t *scratch)
{
unsigned size = 1 << bits;
unsigned j;
mpn_zero (TABLE(0), 3*ecc->size);
- ecc_a_to_j (ecc, initial, TABLE(1), p);
+ ecc_a_to_j (ecc, 1, TABLE(1), p);
for (j = 2; j < size; j += 2)
{
@@ -122,7 +122,7 @@ table_init (const struct ecc_curve *ecc,
void
ecc_mul_a (const struct ecc_curve *ecc,
- int initial, mp_limb_t *r,
+ mp_limb_t *r,
const mp_limb_t *np, const mp_limb_t *p,
mp_limb_t *scratch)
{
@@ -140,7 +140,7 @@ ecc_mul_a (const struct ecc_curve *ecc,
unsigned shift = bit_index % GMP_NUMB_BITS;
mp_limb_t w, bits;
- table_init (ecc, table, ECC_MUL_A_WBITS, initial, p, scratch_out);
+ table_init (ecc, table, ECC_MUL_A_WBITS, p, scratch_out);
w = np[limb_index];
bits = w >> shift;
diff --git a/ecc-point-mul.c b/ecc-point-mul.c
index d8329cf5..09d4f642 100644
--- a/ecc-point-mul.c
+++ b/ecc-point-mul.c
@@ -51,7 +51,7 @@ ecc_point_mul (struct ecc_point *r, const struct ecc_scalar *n,
assert (n->ecc == p->ecc);
assert (r->ecc == p->ecc);
- ecc_mul_a (p->ecc, 1, scratch, n->p, p->p, scratch + 3*size);
+ ecc_mul_a (p->ecc, scratch, n->p, p->p, scratch + 3*size);
ecc_j_to_a (r->ecc, 1, r->p, scratch, scratch + 3*size);
gmp_free_limbs (scratch, itch);
}
diff --git a/ecc.h b/ecc.h
index e2efbeb0..97de76e1 100644
--- a/ecc.h
+++ b/ecc.h
@@ -285,15 +285,13 @@ ecc_mul_g (const struct ecc_curve *ecc, mp_limb_t *r,
const mp_limb_t *np, mp_limb_t *scratch);
/* Computes N * P. The scalar N is the same as for ecc_mul_g. P is a
- non-zero point on the curve, in affine coordinates. Pass a non-zero
- INITIAL if the point coordinates have not previously been converted
- to Montgomery representation. Output R is a non-zero point, in
- Jacobian coordinates. */
+ non-zero point on the curve, in affine coordinates. Output R is a
+ non-zero point, in Jacobian coordinates. */
mp_size_t
ecc_mul_a_itch (const struct ecc_curve *ecc);
void
ecc_mul_a (const struct ecc_curve *ecc,
- int initial, mp_limb_t *r,
+ mp_limb_t *r,
const mp_limb_t *np, const mp_limb_t *p,
mp_limb_t *scratch);
diff --git a/examples/ecc-benchmark.c b/examples/ecc-benchmark.c
index 51b560a0..0d4ee783 100644
--- a/examples/ecc-benchmark.c
+++ b/examples/ecc-benchmark.c
@@ -234,7 +234,7 @@ static void
bench_mul_a (void *p)
{
struct ecc_ctx *ctx = (struct ecc_ctx *) p;
- ecc_mul_a (ctx->ecc, 1, ctx->rp, ctx->ap, ctx->bp, ctx->tp);
+ ecc_mul_a (ctx->ecc, ctx->rp, ctx->ap, ctx->bp, ctx->tp);
}
static void
diff --git a/testsuite/ecc-mul-a-test.c b/testsuite/ecc-mul-a-test.c
index eef09c72..e182aacc 100644
--- a/testsuite/ecc-mul-a-test.c
+++ b/testsuite/ecc-mul-a-test.c
@@ -31,34 +31,21 @@ test_main (void)
mpn_zero (n, size);
n[0] = 1;
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
ecc_j_to_a (ecc, 1, p, p, scratch);
if (mpn_cmp (p, ecc->g, 2*size != 0))
die ("curve %d: ecc_mul_a with n = 1 failed.\n", ecc->bit_size);
- if (ecc->use_redc)
- {
- ecc_mul_a (ecc, 0, p, n, ecc->redc_g, scratch);
- ecc_j_to_a (ecc, 1, p, p, scratch);
-
- if (mpn_cmp (p, ecc->g, 2*size != 0))
- die ("curve %d: ecc_mul_a with n = 1 and redc failed.\n", ecc->bit_size);
- }
for (n[0] = 2; n[0] <= 4; n[0]++)
{
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
test_ecc_mul_j (i, n[0], p);
- if (ecc->use_redc)
- {
- ecc_mul_a (ecc, 0, p, n, ecc->redc_g, scratch);
- test_ecc_mul_j (i, n[0], p);
- }
}
/* (order - 1) * g = - g */
mpn_sub_1 (n, ecc->q, size, 1);
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
ecc_j_to_a (ecc, 1, p, p, scratch);
mpn_sub_n (p + size, ecc->p, p + size, size);
if (mpn_cmp (p, ecc->g, 2*size) != 0)
@@ -80,7 +67,7 @@ test_main (void)
mpz_limbs_copy (n, r, size);
n[size - 1] %= ecc->q[size - 1];
- ecc_mul_a (ecc, 1, p, n, ecc->g, scratch);
+ ecc_mul_a (ecc, p, n, ecc->g, scratch);
ecc_j_to_a (ecc, 1, p, p, scratch);
ecc_mul_g (ecc, q, n, scratch);