Skip to content
Permalink
Browse files
8263978: Clarify why 0 argument is ignored in SecureRandom::setSeed
Reviewed-by: valeriep
  • Loading branch information
wangweij committed Mar 23, 2021
1 parent 15bcf6d commit 0b2aa1b6050eeeb4d13cbedfcfc86fb700e975a2
Showing 1 changed file with 5 additions and 4 deletions.
@@ -730,10 +730,11 @@ public void setSeed(byte[] seed) {
@Override
public void setSeed(long seed) {
/*
* Ignore call from super constructor (as well as any other calls
* unfortunate enough to be passing 0). It's critical that we
* ignore call from superclass constructor, as digest has not
* yet been initialized at that point.
* Ignore call from super constructor as well as any other calls
* unfortunate enough to be passing 0. All SecureRandom
* constructors call `super(0)` which leads to `setSeed(0)`.
* We either keep the object unseeded (in `new SecureRandom()`)
* or we seed the object explicitly (in `new SecureRandom(byte[])`).
*/
if (seed != 0) {
setSeed(longToByteArray(seed));

0 comments on commit 0b2aa1b

Please sign in to comment.