bn: procduce correct sign for result of BN_mod()
authorPauli <pauli@openssl.org>
Mon, 5 Jul 2021 01:01:59 +0000 (11:01 +1000)
committerPauli <pauli@openssl.org>
Wed, 7 Jul 2021 09:12:48 +0000 (19:12 +1000)
commit105c83150f15af3f78ea0758859062842bdbe30e
tree2c1e1ea773116bea76651a767c1b478825997114
parent0f71b1eb6c390e58059a4c4225bcbecac9aef2c7
bn: procduce correct sign for result of BN_mod()

There is a problem that appears when calling BN_div(a, c, a, b) with negative b.
In this case, the sign of the remainder c is incorrect.  The problem only
occurs if the dividend and the quotient are the same BIGNUM.

Fixes #15982

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/15991)
crypto/bn/bn_div.c
test/bntest.c