Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.javax.crypto.prng
Class Fortuna  view Fortuna download Fortuna.java

java.lang.Object
  extended bygnu.java.security.prng.BasePRNG
      extended bygnu.javax.crypto.prng.Fortuna
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, gnu.java.security.prng.IRandom, gnu.java.security.prng.RandomEventListener, java.io.Serializable

public class Fortuna
extends gnu.java.security.prng.BasePRNG
implements java.io.Serializable, gnu.java.security.prng.RandomEventListener

The Fortuna continuously-seeded pseudo-random number generator. This generator is composed of two major pieces: the entropy accumulator and the generator function. The former takes in random bits and incorporates them into the generator's state. The latter takes this base entropy and generates pseudo-random bits from it.

There are some things users of this class must be aware of:

Adding Random Data
This class does not do any polling of random sources, but rather provides an interface for adding random events. Applications that use this code must provide this mechanism. We use this design because an application writer who knows the system he is targeting is in a better position to judge what random data is available.
Storing the Seed
This class implements java.io.Serializable in such a way that it writes a 64 byte seed to the stream, and reads it back again when being deserialized. This is the extent of seed file management, however, and those using this class are encouraged to think deeply about when, how often, and where to store the seed.

References:


Nested Class Summary
static class Fortuna.Generator
          The Fortuna generator function.
 
Field Summary
private  Fortuna.Generator generator
           
private  long lastReseed
           
private static int MIN_POOL_SIZE
           
private static int NUM_POOLS
           
private  int pool
           
private  int pool0Count
           
private  gnu.java.security.hash.IMessageDigest[] pools
           
private  int reseedCount
           
static java.lang.String SEED
           
private static int SEED_FILE_SIZE
           
private static long serialVersionUID
           
 
Fields inherited from class gnu.java.security.prng.BasePRNG
buffer, initialised, name, ndx
 
Constructor Summary
Fortuna()
           
 
Method Summary
 void addRandomByte(byte b)
          Supplement, or possibly replace, the random state of this PRNG with a random byte.
 void addRandomBytes(byte[] buf, int offset, int length)
          Supplement, or possibly replace, the random state of this PRNG with a sequence of new random bytes.
 void addRandomEvent(gnu.java.security.prng.RandomEvent event)
           
 void fillBlock()
           
private  void readObject(java.io.ObjectInputStream in)
           
 void setup(java.util.Map attributes)
           
private  void writeObject(java.io.ObjectOutputStream out)
           
 
Methods inherited from class gnu.java.security.prng.BasePRNG
addRandomBytes, clone, init, isInitialised, name, nextByte, nextBytes, nextBytes
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

SEED_FILE_SIZE

private static final int SEED_FILE_SIZE
See Also:
Constant Field Values

NUM_POOLS

private static final int NUM_POOLS
See Also:
Constant Field Values

MIN_POOL_SIZE

private static final int MIN_POOL_SIZE
See Also:
Constant Field Values

generator

private final Fortuna.Generator generator

pools

private final gnu.java.security.hash.IMessageDigest[] pools

lastReseed

private long lastReseed

pool

private int pool

pool0Count

private int pool0Count

reseedCount

private int reseedCount

SEED

public static final java.lang.String SEED
See Also:
Constant Field Values
Constructor Detail

Fortuna

public Fortuna()
Method Detail

setup

public void setup(java.util.Map attributes)

fillBlock

public void fillBlock()
               throws gnu.java.security.prng.LimitReachedException

addRandomByte

public void addRandomByte(byte b)
Description copied from interface: gnu.java.security.prng.IRandom

Supplement, or possibly replace, the random state of this PRNG with a random byte.

Implementations are not required to implement this method in any meaningful way; this may be a no-operation, and implementations may throw an java.lang.UnsupportedOperationException.

Specified by:
addRandomByte in interface gnu.java.security.prng.IRandom

addRandomBytes

public void addRandomBytes(byte[] buf,
                           int offset,
                           int length)
Description copied from interface: gnu.java.security.prng.IRandom

Supplement, or possibly replace, the random state of this PRNG with a sequence of new random bytes.

Implementations are not required to implement this method in any meaningful way; this may be a no-operation, and implementations may throw an java.lang.UnsupportedOperationException.

Specified by:
addRandomBytes in interface gnu.java.security.prng.IRandom

addRandomEvent

public void addRandomEvent(gnu.java.security.prng.RandomEvent event)
Specified by:
addRandomEvent in interface gnu.java.security.prng.RandomEventListener

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException