Ensure negative input to BN_mod_exp_mont_consttime() is correctly reduced.
authorjsing <jsing@openbsd.org>
Wed, 15 Mar 2023 04:30:20 +0000 (04:30 +0000)
committerjsing <jsing@openbsd.org>
Wed, 15 Mar 2023 04:30:20 +0000 (04:30 +0000)
commitec747b4beaa253269b2c18925e90dec4dc91d328
tree8606191802ea425676053701e5f5407db956d5dc
parent6b6aa922fa0cfc156d20f66d39ba7a8d6b705f87
Ensure negative input to BN_mod_exp_mont_consttime() is correctly reduced.

A negative input to BN_mod_exp_mont_consttime() is not correctly reduced,
remaining negative (when it should be in the range [0, m)). Fix this by
unconditionally calling BN_nnmod() on the input.

Fixes ossfuzz #55997.

ok tb@
lib/libcrypto/bn/bn_exp.c