[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/27372] BigInteger should use nextBytes()

From: gnu at frogcircus dot org
Subject: [Bug classpath/27372] BigInteger should use nextBytes()
Date: 1 May 2006 23:30:33 -0000

------- Comment #1 from gnu at frogcircus dot org  2006-05-01 23:30 -------
Additional Comments from David Hook <address@hidden>:

As an additional note, the root of the problem with the test is that by
using nextInt the BigInteger class is consuming extra bytes in the data
stream which it discards. This makes it very difficult to create a
general purpose predictable class based on SecureRandom (or Random for
that matter) which can be used for regression testing, as the standard
implementation only consumes as many bytes as required, and it is not
simple to write a SecureRandom class that can second guess why nextInt
is being called. BC already has some tests where nextInt, nextLong, and
nextBytes are all used. It is likely more will be added in the future.

It's probably also worth noting that the use of nextInt also makes the
constructor a lot less efficient than the standard one when a
SecureRandom is used as SecureRandom, unlike Random, uses nextBytes() as
its principal source.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]