CVSROOT:        /cvs
Module name:    src
Changes by:     t...@cvs.openbsd.org    2023/08/03 12:53:56

Modified files:
        lib/libcrypto/bn: bn_bpsw.c bn_local.h bn_mod_sqrt.c bn_rand.c 
        lib/libcrypto/dh: dh_key.c 
        lib/libcrypto/dsa: dsa_key.c dsa_ossl.c 
        lib/libcrypto/ec: ec_key.c ecp_smpl.c 
        lib/libcrypto/ecdsa: ecdsa.c 
        regress/lib/libcrypto/bn: bn_isqrt.c 

Log message:
Make the bn_rand_interval() API a bit more ergonomic

Provide bn_rand_in_range() which is a slightly tweaked version of what was
previously called bn_rand_range().

The way bn_rand_range() is called in libcrypto, the lower bound is always
expressible as a word. In fact, most of the time it is 1, the DH code uses
a 2, the MR tests in BPSW use 3 and an exceptinally high number appears in
the Tonelli-Shanks implementation where we use 32. Converting these lower
bounds to BIGNUMs on the call site is annoying so let bn_rand_interval()
do that internally and route that through bn_rand_in_range(). This way we
can avoid using BN_sub_word().

Adjust the bn_isqrt() test to use bn_rand_in_range() since that's the
only caller that uses actual BIGNUMs as lower bounds.

ok jsing

Reply via email to