You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The former implementation of os.urandom generated an N-byte random
BigInteger and got its contents as a byte array. However, because the
byte array returned by a BigInteger can have one additional byte to
account for the sign it truncated the array to only the first N bytes.
This causes a big problem with the first byte; any time the high bit of
the first byte would have been a 1, it would instead make the entire
first byte 0.
I've rewritten the urandom function not to use a BigInteger and instead
use the Random.nextBytes function. This both fixes the bug and likely
makes the code faster because it removes the array-copy needed to
truncate the array.
0 commit comments