diff options
| author | J08nY | 2020-03-09 12:44:03 +0100 |
|---|---|---|
| committer | J08nY | 2020-03-09 12:44:03 +0100 |
| commit | a7d3589c4ba3551ab614dfc9c931c5998fbf7fac (patch) | |
| tree | 7f09b68b16b461ee6fd47d366dfc3d8444cf513e /pyecsca/codegen/bn | |
| parent | 0fde32d49ca8bcba19a370125be99ad0c7572009 (diff) | |
| download | pyecsca-codegen-a7d3589c4ba3551ab614dfc9c931c5998fbf7fac.tar.gz pyecsca-codegen-a7d3589c4ba3551ab614dfc9c931c5998fbf7fac.tar.zst pyecsca-codegen-a7d3589c4ba3551ab614dfc9c931c5998fbf7fac.zip | |
Add inversion to config, change scalar mult command.
Diffstat (limited to 'pyecsca/codegen/bn')
| -rw-r--r-- | pyecsca/codegen/bn/bn.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pyecsca/codegen/bn/bn.c b/pyecsca/codegen/bn/bn.c index 0d83731..53777db 100644 --- a/pyecsca/codegen/bn/bn.c +++ b/pyecsca/codegen/bn/bn.c @@ -202,6 +202,7 @@ bn_err bn_red_decode(bn_t *one, const bn_t *mod, const red_t *red) { } bn_err bn_red_add(const bn_t *one, const bn_t *other, const bn_t *mod, const red_t *red, bn_t *out) { +#ifdef BN_NON_CONST bn_err err; if ((err = mp_add(one, other, out)) != BN_OKAY) { return err; @@ -211,9 +212,13 @@ bn_err bn_red_add(const bn_t *one, const bn_t *other, const bn_t *mod, const red } else { return err; } +#else + return mp_addmod(one, other, mod, out); +#endif } bn_err bn_red_sub(const bn_t *one, const bn_t *other, const bn_t *mod, const red_t *red, bn_t *out) { +#ifdef BN_NON_CONST bn_err err; if ((err = mp_sub(one, other, out)) != BN_OKAY) { return err; @@ -225,6 +230,9 @@ bn_err bn_red_sub(const bn_t *one, const bn_t *other, const bn_t *mod, const red return mp_sub(out, mod, out); } return err; +#else + return mp_submod(one, other, mod, out); +#endif } bn_err bn_red_neg(const bn_t *one, const bn_t *mod, const red_t *red, bn_t *out) { |
