|
From: Martijn B. <mar...@gm...> - 2019-03-13 22:01:21
|
On 12-03-19 21:02, Jaime Hablutzel wrote:
> I'm looking the following code pattern in several places of the source
> code (mostly in tests):
>
> SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
> random.setSeed(new Date().getTime());
> random.nextBytes(serno);
>
> Where the setSeed call just before the call to nextBytes prevents the
> SHA1PRNG default implementation from feeding itself from system entropy,
> so it relies on the provided timestamp as its only source of entropy,
> which looks like a bad idea.
According to SecureRandom javadoc, this should not have any implication
on the security of the random generator (i.e., the randomness)
https://docs.oracle.com/javase/7/docs/api/
The given seed supplements, rather than replaces, the existing seed.
Thus, repeated calls are guaranteed never to reduce randomness.
Kind regards,
Martijn Brinkers
|