Correct sign handling in BN_add_word().
authorjsing <jsing@openbsd.org>
Sat, 11 Mar 2023 14:13:11 +0000 (14:13 +0000)
committerjsing <jsing@openbsd.org>
Sat, 11 Mar 2023 14:13:11 +0000 (14:13 +0000)
commit2e57f206af23fa891cf2225aa15a0dfd10eefa14
tree3e4798a5954eb072f2ff762e887cec84080d3e10
parent5482ffcf871da1009c80414fdb8ec8c4ad96e84a
Correct sign handling in BN_add_word().

A sign handling bug was introduced to BN_add_word() in bn_word.c r1.18.
When handling addition to a negative bignum, the BN_sub_word() call can
result in the sign being flipped, which we need to account for. Use the
same code in BN_sub_word() - while not technically needed here it keeps
the code consistent.

Issue discovered by tb@

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