summaryrefslogtreecommitdiff
path: root/ecc-internal.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2021-03-11 19:37:41 +0100
committerNiels Möller <nisse@lysator.liu.se>2021-03-11 19:37:41 +0100
commit2bf497ba4d6acc6f352bca015837fad33008565c (patch)
treed19e4e6928212dd6eb5d87f32f23abb599fd9710 /ecc-internal.h
parentfe7ae87d1b837e82f7c7968b068bca7d853a4cec (diff)
downloadnettle-2bf497ba4d6acc6f352bca015837fad33008565c.tar.gz
New functions ecc_mod_mul_canonical and ecc_mod_sqr_canonical.
* ecc-mod-arith.c (ecc_mod_mul_canonical, ecc_mod_sqr_canonical): New functions. * ecc-internal.h: Declare and document new functions. * curve448-eh-to-x.c (curve448_eh_to_x): Use ecc_mod_sqr_canonical. * curve25519-eh-to-x.c (curve25519_eh_to_x): Use ecc_mod_mul_canonical. * ecc-eh-to-a.c (ecc_eh_to_a): Likewise. * ecc-j-to-a.c (ecc_j_to_a): Likewise. * ecc-mul-m.c (ecc_mul_m): Likewise.
Diffstat (limited to 'ecc-internal.h')
-rw-r--r--ecc-internal.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/ecc-internal.h b/ecc-internal.h
index 55c9be27..acfcb4d7 100644
--- a/ecc-internal.h
+++ b/ecc-internal.h
@@ -49,6 +49,8 @@
#define ecc_mod_submul_1 _nettle_ecc_mod_submul_1
#define ecc_mod_mul _nettle_ecc_mod_mul
#define ecc_mod_sqr _nettle_ecc_mod_sqr
+#define ecc_mod_mul_canonical _nettle_ecc_mod_mul_canonical
+#define ecc_mod_sqr_canonical _nettle_ecc_mod_sqr_canonical
#define ecc_mod_pow_2k _nettle_ecc_mod_pow_2k
#define ecc_mod_pow_2k_mul _nettle_ecc_mod_pow_2k_mul
#define ecc_mod_random _nettle_ecc_mod_random
@@ -264,6 +266,19 @@ void
ecc_mod_sqr (const struct ecc_modulo *m, mp_limb_t *rp,
const mp_limb_t *ap, mp_limb_t *tp);
+/* These mul and sqr functions produce a canonical result, 0 <= R < M.
+ Requirements on input and output areas are similar to the above
+ functions, except that it is *not* allowed to pass rp = rp +
+ m->size.
+ */
+void
+ecc_mod_mul_canonical (const struct ecc_modulo *m, mp_limb_t *rp,
+ const mp_limb_t *ap, const mp_limb_t *bp, mp_limb_t *tp);
+
+void
+ecc_mod_sqr_canonical (const struct ecc_modulo *m, mp_limb_t *rp,
+ const mp_limb_t *ap, mp_limb_t *tp);
+
/* R <-- X^{2^k} mod M. Needs 2*ecc->size limbs of scratch space, same
overlap requirements as mul and sqr above. */
void