From ee6730fdaa287d03fc911e7d41d863f394cc1ccb Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Thu, 3 Feb 2011 15:46:24 +0000
Subject: [PATCH]     * RandomSource: Fix seeding from /dev/urandom

---
 core/java/src/net/i2p/util/RandomSource.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/core/java/src/net/i2p/util/RandomSource.java b/core/java/src/net/i2p/util/RandomSource.java
index c7c87239c9..fe04291521 100644
--- a/core/java/src/net/i2p/util/RandomSource.java
+++ b/core/java/src/net/i2p/util/RandomSource.java
@@ -146,14 +146,18 @@ public class RandomSource extends SecureRandom implements EntropyHarvester {
     public final boolean initSeed(byte buf[]) {
         // why urandom?  because /dev/random blocks, and there are arguments
         // suggesting such blockages are largely meaningless
-        boolean ok = seedFromFile("/dev/urandom", buf);
+        boolean ok = seedFromFile(new File("/dev/urandom"), buf);
         // we merge (XOR) in the data from /dev/urandom with our own seedfile
-        ok = seedFromFile("prngseed.rnd", buf) || ok;
+        File localFile = new File(_context.getConfigDir(), SEEDFILE);
+        ok = seedFromFile(localFile, buf) || ok;
         return ok;
     }
     
-    private static final boolean seedFromFile(String filename, byte buf[]) {
-        File f = new File(I2PAppContext.getGlobalContext().getConfigDir(), filename);
+    /**
+     *  @param f absolute path
+     *  @return success
+     */
+    private static final boolean seedFromFile(File f, byte buf[]) {
         if (f.exists()) {
             FileInputStream fis = null;
             try {
-- 
GitLab