]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[crypto] Extract bigint_reduce_supremum() from bigint_mod_exp()
authorMichael Brown <mcb30@ipxe.org>
Fri, 10 Jan 2025 13:44:13 +0000 (13:44 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 10 Jan 2025 13:47:25 +0000 (13:47 +0000)
commitd88eb0a1935942cdeccd3efee38f9765d2f1c235
tree74c920dced82d2a576bcf7a034cd78c5136c89c6
parent83ba34076ad4ca79be81a71f25303b340c60e7b8
[crypto] Extract bigint_reduce_supremum() from bigint_mod_exp()

Calculating the Montgomery constant (R^2 mod N) is done in our
implementation by zeroing the double-width representation of N,
subtracting N once to give (R^2 - N) in order to obtain a positive
value, then reducing this value modulo N.

Extract this logic from bigint_mod_exp() to a separate function
bigint_reduce_supremum(), to allow for reuse by other code.

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