]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[crypto] Calculate inverse of modulus on demand in bigint_montgomery()
authorMichael Brown <mcb30@ipxe.org>
Mon, 16 Dec 2024 15:09:56 +0000 (15:09 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 16 Dec 2024 15:13:37 +0000 (15:13 +0000)
commit97079553b66ea9036348543e2b92cbe29bfd2c6b
tree37cf2929a45ab0f0f640e5440a4d89b6c09aab6a
parent24db39fb2983ca83ab5c6ee37cb57a4f7f6f94e6
[crypto] Calculate inverse of modulus on demand in bigint_montgomery()

Reduce the number of parameters passed to bigint_montgomery() by
calculating the inverse of the modulus modulo the element size on
demand.  Cache the result, since Montgomery reduction will be used
repeatedly with the same modulus value.

In all currently supported algorithms, the modulus is a public value
(or a fixed value defined by specification) and so this non-constant
timing does not leak any private information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/crypto/bigint.c
src/include/ipxe/bigint.h
src/tests/bigint_test.c