From 4031de2dc0405d6d0218b8c410f92e9f5583b247 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niels=20M=C3=B6ller?= Date: Tue, 3 Nov 2020 20:26:34 +0100 Subject: [PATCH] Stricter requirements for in-place ecc_add_func. --- ChangeLog | 4 ++++ ecc-internal.h | 1 + ecc-mul-a-eh.c | 2 +- testsuite/ecc-add-test.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f44401fb..025403c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2020-11-03 Niels Möller + * ecc-internal.h (ecc_add_func): Document in-place operation. + * ecc-mul-a-eh.c (ecc_mul_a_eh): Fix call to ecc->add_hhh accordingly. + * testsuite/ecc-add-test.c (test_main): Likewise. + * ecc-add-eh.c (ecc_add_eh): Reduce scratch need. * ecc-add-th.c (ecc_add_th): Analogous changes. * ecc-internal.h (ECC_ADD_EH_ITCH, ECC_ADD_TH_ITCH): Now 4*size. diff --git a/ecc-internal.h b/ecc-internal.h index 0afd7c6b..6dba06d1 100644 --- a/ecc-internal.h +++ b/ecc-internal.h @@ -129,6 +129,7 @@ typedef int ecc_mod_sqrt_func (const struct ecc_modulo *m, const mp_limb_t *up, const mp_limb_t *vp, mp_limb_t *scratch); +/* Allows in-place operation with r == p, but not r == q */ typedef void ecc_add_func (const struct ecc_curve *ecc, mp_limb_t *r, const mp_limb_t *p, const mp_limb_t *q, diff --git a/ecc-mul-a-eh.c b/ecc-mul-a-eh.c index d7765ebf..b0aa2697 100644 --- a/ecc-mul-a-eh.c +++ b/ecc-mul-a-eh.c @@ -167,7 +167,7 @@ ecc_mul_a_eh (const struct ecc_curve *ecc, bits &= TABLE_MASK; sec_tabselect (tp, 3*ecc->p.size, table, TABLE_SIZE, bits); - ecc->add_hhh (ecc, r, tp, r, scratch_out); + ecc->add_hhh (ecc, r, r, tp, scratch_out); } #undef table #undef tp diff --git a/testsuite/ecc-add-test.c b/testsuite/ecc-add-test.c index d3b0bd92..6f58a3bb 100644 --- a/testsuite/ecc-add-test.c +++ b/testsuite/ecc-add-test.c @@ -35,7 +35,7 @@ test_main (void) ecc->add_hh (ecc, p, z, z, scratch); test_ecc_mul_h (i, 0, p); - ecc->add_hhh (ecc, p, g, p, scratch); + ecc->add_hhh (ecc, p, p, g, scratch); test_ecc_mul_h (i, 1, p); ecc->add_hh (ecc, p, z, g, scratch); -- 2.47.2