jeudi 27 mai 2021

Is SecureRandom weaken when seed with Random?

Could a seed from java.util.Random for java.security.SecureRandom weaken the cryptographically strong random number generator?

I saw this code and wonder why this is done in that specific way.

randomGenerator = new SecureRandom();
final Random rnd = new Random();
randomGenerator.setSeed(rnd.nextLong());

From the documentation, the call of setSeed will never reduce randomness. So why is setSeed called anyway?

public void setSeed(long seed)
Reseeds this random object, using the eight bytes contained in the given long seed. The given seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.
docs.oracle.com




Aucun commentaire:

Enregistrer un commentaire