From 92cb16e8103da998aa1bf226d24ef6771a92c5d5 Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 20 Feb 2020 15:06:18 +0100 Subject: Allocate and initialize formula variables only once. --- pyecsca/codegen/bn/bn.c | 5 +++++ pyecsca/codegen/bn/bn.h | 1 + 2 files changed, 6 insertions(+) (limited to 'pyecsca/codegen/bn') diff --git a/pyecsca/codegen/bn/bn.c b/pyecsca/codegen/bn/bn.c index 635eaae..c953119 100644 --- a/pyecsca/codegen/bn/bn.c +++ b/pyecsca/codegen/bn/bn.c @@ -72,6 +72,11 @@ void bn_mod_sub(const bn_t *one, const bn_t *other, const bn_t *mod, bn_t *out) mp_submod(one, other, mod, out); } +void bn_mod_neg(const bn_t *one, const bn_t *mod, bn_t *out) { + mp_neg(one, out); + mp_mod(out, mod, out); +} + void bn_mod_mul(const bn_t *one, const bn_t *other, const bn_t *mod, bn_t *out) { mp_mulmod(one, other, mod, out); } diff --git a/pyecsca/codegen/bn/bn.h b/pyecsca/codegen/bn/bn.h index a5b1ba9..e323170 100644 --- a/pyecsca/codegen/bn/bn.h +++ b/pyecsca/codegen/bn/bn.h @@ -41,6 +41,7 @@ void bn_rand_mod_reduce(bn_t *out, const bn_t *mod); void bn_mod_add(const bn_t *one, const bn_t *other, const bn_t *mod, bn_t *out); void bn_mod_sub(const bn_t *one, const bn_t *other, const bn_t *mod, bn_t *out); +void bn_mod_neg(const bn_t *one, const bn_t *mod, bn_t *out); void bn_mod_mul(const bn_t *one, const bn_t *other, const bn_t *mod, bn_t *out); void bn_mod_sqr(const bn_t *one, const bn_t *mod, bn_t *out); void bn_mod_div(const bn_t *one, const bn_t *other, const bn_t *mod, bn_t *out); -- cgit v1.3.1