CVSROOT:        /cvs
Module name:    src
Changes by:     t...@cvs.openbsd.org    2023/06/02 11:15:30

Modified files:
        lib/libcrypto/bn: bn_gcd.c 

Log message:
Fix variable reuse in BN_mod_inverse()

The somewhat strange calculation m = a^{-1} (mod m) can return 0. This
breaks because of BN_nnmod() having delicate semantics of which variable
can be reused. BN_nnmod(a, a, m, ctx) works and the library relies on that.

Here, the code ends up doing BN_nnmod(m, a, m, ctx) and this doesn't work.
If the result of the initial BN_mod() is negative, then BN_nnmod() will
return 0.

Problem reported by Guido Vranken in
https://github.com/openssl/openssl/issues/21110

This code is well covered by regress, but it does not currently have
explicit test coverage. Such will be added soon.

ok beck jsing

Reply via email to