CVSROOT:        /cvs
Module name:    src
Changes by:     js...@cvs.openbsd.org   2023/02/12 21:25:37

Modified files:
        lib/libcrypto/bn: bn_add.c bn_div.c bn_mont.c bn_mpi.c bn_mul.c 
                          bn_print.c bn_recp.c bn_shift.c bn_sqr.c 
                          bn_word.c 

Log message:
Avoid negative zero.

Whenever setting negative to one (or when it could potentially be one),
always use BN_set_negative() since it checks for a zero valued bignum and
will not permit negative to be set in this case. Since BN_is_zero()
currently relies on top == 0, call BN_set_negative() after top has been
set (or bn_correct_top() has been called).

This fixes a long standing issue where -0 and +0 have been permitted,
however multiple code paths (such as BN_cmp()) fail to treat these as
equivalent.

Prompted by Guido Vranken who is adding negative zero fuzzing to oss-fuzz.

ok tb@

Reply via email to