Hi.

I was playing with the Fortuna PRNG a little, and found a bug where it would not initialize its block when `setup' is called (the Generator PRNG also has this problem). As a consequence, the first block you get out of the PRNG is all zeros. This patch fixes that problem.

2006-04-12  Casey Marshall  <[EMAIL PROTECTED]>

        * gnu/javax/crypto/prng/Fortuna.java (setup): call `fillBlock.'
        (Generator.setup): call `fillBlock.'

Committed.

Index: gnu/javax/crypto/prng/Fortuna.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/javax/crypto/prng/Fortuna.java,v
retrieving revision 1.1
diff -u -B -b -r1.1 Fortuna.java
--- gnu/javax/crypto/prng/Fortuna.java  26 Jan 2006 02:25:09 -0000      1.1
+++ gnu/javax/crypto/prng/Fortuna.java  12 Apr 2006 18:00:39 -0000
@@ -142,6 +142,14 @@
     pool = 0;
     pool0Count = 0;
     generator.init(attributes);
+    try
+      {
+        fillBlock ();
+      }
+    catch (LimitReachedException shouldNotHappen)
+      {
+        throw new RuntimeException (shouldNotHappen);
+      }
   }
 
   public void fillBlock() throws LimitReachedException
@@ -324,6 +332,7 @@
       byte[] seed = (byte[]) attributes.get(SEED);
       if (seed != null)
         addRandomBytes(seed);
+      fillBlock ();
     }
 
     /**

Reply via email to