Provide bn_div_rem_words() and make use of it.
authorjsing <jsing@openbsd.org>
Sat, 28 Jan 2023 16:33:34 +0000 (16:33 +0000)
committerjsing <jsing@openbsd.org>
Sat, 28 Jan 2023 16:33:34 +0000 (16:33 +0000)
commit519d53cbde5b8b75b2de2564dbfbef9f15a1c8a5
tree20a5191a5482e86fb47c70dbd09996328a2f85d9
parentd489aa7e717ce5815367bce2310fbfd057a8f7bf
Provide bn_div_rem_words() and make use of it.

Provide a function that divides a double word (h:l) by d, returning the
quotient q and the remainder r, such that q * d + r is equal to the
numerator. Call this from the three places that currently implement this
themselves.

This is implemented with some slight indirection, which allows for per
architecture implementations, replacing the define/macro tangle, which
messes with variables that are not passed to it.

Also remove a duplicate of bn_div_words() for the BN_ULLONG && BN_DIV2W
case - this is already handled.

ok tb@
lib/libcrypto/bn/arch/amd64/bn_arch.h
lib/libcrypto/bn/arch/i386/bn_arch.h
lib/libcrypto/bn/bn_div.c
lib/libcrypto/bn/bn_local.h
lib/libcrypto/bn/bn_word.c