I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 8afe7c26 authored by zzz's avatar zzz
Browse files

* RandomSource: Seed from SecureRandom too

parent 543870ff
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import net.i2p.I2PAppContext;
......@@ -170,9 +171,14 @@ public class RandomSource extends SecureRandom implements EntropyHarvester {
}
public final boolean initSeed(byte buf[]) {
boolean ok = false;
try {
SecureRandom.getInstance("SHA1PRNG").nextBytes(buf);
ok = true;
} catch (NoSuchAlgorithmException e) {}
// why urandom? because /dev/random blocks, and there are arguments
// suggesting such blockages are largely meaningless
boolean ok = seedFromFile(new File("/dev/urandom"), buf);
ok = seedFromFile(new File("/dev/urandom"), buf) || ok;
// we merge (XOR) in the data from /dev/urandom with our own seedfile
File localFile = new File(_context.getConfigDir(), SEEDFILE);
ok = seedFromFile(localFile, buf) || ok;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment