summaryrefslogtreecommitdiff
path: root/ecc-internal.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2020-11-01 10:22:48 +0100
committerNiels Möller <nisse@lysator.liu.se>2020-11-01 10:22:48 +0100
commit172448b05931e791ce3470b45afe8de4cdffaaad (patch)
treecd7d238a5ba07568c71619a9bb7819e107cfe205 /ecc-internal.h
parent98402b3b32b346a568c0d0d8e56a64f27116250c (diff)
downloadnettle-172448b05931e791ce3470b45afe8de4cdffaaad.tar.gz
Separate result area for ecc_mod_mul and ecc_mod_sqr.
* ecc-mod-arith.c (ecc_mod_mul, ecc_mod_sqr): Separate argument for scratch area, reducing required size of result area. Update all callers to naïvely keep using result in scratch area. (ecc_mod_pow_2k, ecc_mod_pow_2k_mul): Simplified, also reducing required size of result area.
Diffstat (limited to 'ecc-internal.h')
-rw-r--r--ecc-internal.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/ecc-internal.h b/ecc-internal.h
index b2ee8350..52bea1c9 100644
--- a/ecc-internal.h
+++ b/ecc-internal.h
@@ -255,23 +255,26 @@ void
ecc_mod_submul_1 (const struct ecc_modulo *m, mp_limb_t *rp,
const mp_limb_t *ap, mp_limb_t b);
-/* The mul and sqr functions need 2*m->size limbs at rp */
+/* The mul and sqr function need 2*m->size limbs at tp. rp may overlap
+ ap or bp, and may equal tp or tp + m->size, but no other overlap
+ with tp is allowed. */
void
ecc_mod_mul (const struct ecc_modulo *m, mp_limb_t *rp,
- const mp_limb_t *ap, const mp_limb_t *bp);
+ const mp_limb_t *ap, const mp_limb_t *bp, mp_limb_t *tp);
void
ecc_mod_sqr (const struct ecc_modulo *m, mp_limb_t *rp,
- const mp_limb_t *ap);
+ const mp_limb_t *ap, mp_limb_t *tp);
-/* The pow functions needs 2*m->size limbs at both rp and tp. */
-/* R <-- X^{2^k} */
+/* R <-- X^{2^k} mod M. Needs 2*ecc->size limbs of scratch space, same
+ overlap requirements as mul and sqr above. */
void
ecc_mod_pow_2k (const struct ecc_modulo *m,
mp_limb_t *rp, const mp_limb_t *xp,
unsigned k, mp_limb_t *tp);
-/* R <-- X^{2^k} Y */
+/* R <-- X^{2^k} Y mod M. Similar requirements as ecc_mod_pow_2k, but
+ rp and yp can't overlap. */
void
ecc_mod_pow_2k_mul (const struct ecc_modulo *m,
mp_limb_t *rp, const mp_limb_t *xp,