I'd like to consult some question on the common myth of SecureRandom in Java, on security vs. performance tradeoff.
I've been researching on the Internet for a while and I've put the following information together. I'd like people here help me confirm what I got and hopefully get some ideas on what to actually choose for implementation.
Basically here are some most popular and thorough articles for SecureRandom:
Proper use of Java's SecureRandom: https://www.synopsys.com/blogs/software-security/proper-use-of-javas-securerandom/
Issues when using Java's SecureRandom: https://www.synopsys.com/blogs/software-security/issues-when-using-java-securerandom/
Using the SecureRandom class: http://moi.vonos.net/java/securerandom/
And, Sun's official "confession" of bug/confusion and a proposed release in Java 8: http://openjdk.java.net/jeps/123
Now that Java 8 is out, I am honestly not sure how better this actually been fixed, by just looking at the documentation: http://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html
So after all, this is what I got (please help me to see if I got them sorted):
People like Amit Sethi suggests using specified instantiation like: SecureRandom sr3 = SecureRandom.getInstance("SHA1PRNG", "SUN"), where in reality, Sun tells us that this will end up always reading from /dev/random(???), which means it can be potentially blocking for EVERY call. As opposed to if you use new SecureRandom() it will then always read from /dev/urandom unless generateSeed() is called. See
http://bugs.java.com/view_bug.do?bug_id=6202721
Does that mean "new SecureRandom()" is still preferred in current Java? Not many other documenation I found state the above point explicitly so I want to know if that is still true?
Now if "new SecureRandom()" is the choice and will lead to never blocking call, then I think what I should do for periodic reseeding would be:
Make SecureRandom a static instance in the class and let another Executor thread periodically call generateSeed() on it, thus even though the call is blocking, it's not affecting my main request handling thread in my application. Does that sound like a good way doing it?
Really appreciate any Java and crypto experts to shed some light on this issue here. Thanks!
Edit: Another useful thread here, seems to back up my guess: https://bugs.openjdk.java.net/browse/JDK-4705093