Does the SHA1PRNG algorithm for SecureRandom use /dev/random for entropy?

情到浓时终转凉″ 提交于 2019-12-31 04:33:20

问题


I tried looking for this in the javadocs and online but couldn't find a definitive answer. The answer by Dan Dyer in

How to solve performance problem with Java SecureRandom?

Seems to suggest SHA1PRNG does not use any system resources for entropy. Is this correct?


回答1:


No, in the default Oracle implementation it uses system resources, unless you seed it before calling nextBytes(). From the Sun/Oracle documentation of SecureRandom:

The SecureRandom implementation attempts to completely randomize the internal state of the generator itself unless the caller follows the call to a getInstance method with a call to the setSeed method:

 SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
 random.setSeed(seed);


来源:https://stackoverflow.com/questions/13923247/does-the-sha1prng-algorithm-for-securerandom-use-dev-random-for-entropy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!