]> git.ipfire.org Git - thirdparty/nettle.git/commit
Make ecc modular inversion use redc form, for relevant curves. invert-with-redc
authorNiels Möller <nisse@lysator.liu.se>
Wed, 29 Jan 2020 16:16:03 +0000 (17:16 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Wed, 29 Jan 2020 16:16:03 +0000 (17:16 +0100)
commit87099691e752f25e3c044ed59ae47224599291bf
tree2abf884b2842be0ea41647ae6d8ed6af7ae3738e
parent4733b05484304fc766ed0d904dfe833ff35df92d
Make ecc modular inversion use redc form, for relevant curves.

* ecc-mod-inv.c (ecc_mod_inv_destructive): New helper function,
not preserving input argument. Extracted from old ecc_mod_inv.
(ecc_mod_inv): Call ecc_mod_inv_destructive.
(ecc_mod_inv_redc): New inversion function, with input and output
in redc form.

* ecc-secp224r1.c: Select between ecc_mod_inv and ecc_mod_inv_redc.
* ecc-secp256r1.c: Likewise.

* ecc-j-to-a.c (ecc_j_to_a): Simplify redc-related logic, taking
advantage of ecc->p.invert handling redc, when appropriate. Reduce
scratch need from 5n to 4n in the process (assuming inversion
needs 2n).

* testsuite/ecc-modinv-test.c (ref_modinv): Updated to do redc, if
appropriate.
ChangeLog
ecc-internal.h
ecc-j-to-a.c
ecc-mod-inv.c
ecc-secp224r1.c
ecc-secp256r1.c
testsuite/ecc-modinv-test.c