[freenet-cvs] r13730 - trunk/freenet/src/freenet/crypt

nextgens at freenetproject.org nextgens at freenetproject.org
Sat Jun 23 10:45:56 UTC 2007


Author: nextgens
Date: 2007-06-23 10:45:56 +0000 (Sat, 23 Jun 2007)
New Revision: 13730

Modified:
   trunk/freenet/src/freenet/crypt/Yarrow.java
Log:
implement 228: If /dev/random doesn't exist we should block on SecureRandom.generateSeed

Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Yarrow.java	2007-06-23 10:26:14 UTC (rev 13729)
+++ trunk/freenet/src/freenet/crypt/Yarrow.java	2007-06-23 10:45:56 UTC (rev 13730)
@@ -122,6 +122,7 @@
 		        }
 	        }
 
+	        boolean isSystemEntropyAvailable = true;
 	        // Read some bits from /dev/urandom
 	        try {
 	            fis = new FileInputStream("/dev/urandom");
@@ -132,6 +133,9 @@
 	            consumeBytes(buf);
 	        } catch (Throwable t) {
 	            Logger.normal(this, "Can't read /dev/urandom: "+t, t);
+	            // We can't read it; let's skip /dev/random and seed from SecureRandom.generateSeed()
+	            canBlock = true;
+	            isSystemEntropyAvailable = false;
 	        } finally {
 	            try {
 	            	if(fis != null)
@@ -140,7 +144,7 @@
 	                    dis.close();
 	            } catch (IOException e) {}
 	        }
-	        if(canBlock) {
+	        if(canBlock && isSystemEntropyAvailable) {
 	            // Read some bits from /dev/random
 	            try {
 	                fis = new FileInputStream("/dev/random");




More information about the cvs mailing list