For the latest news and information visit
The GNU Crypto project

gnu.crypto.prng
Class Fortuna

java.lang.Object
  extended by gnu.crypto.prng.BasePRNG
      extended by gnu.crypto.prng.Fortuna
All Implemented Interfaces:
IRandom, RandomEventListener, Serializable, Cloneable, EventListener

public class Fortuna
extends BasePRNG
implements Serializable, 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 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:

See Also:
Serialized Form

Nested Class Summary
static class Fortuna.Generator
          The Fortuna generator function.
 
Field Summary
static String SEED
           
 
Fields inherited from class gnu.crypto.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(RandomEvent event)
           
 void fillBlock()
           
 void setup(Map attributes)
           
 
Methods inherited from class gnu.crypto.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

SEED

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

Fortuna

public Fortuna()
Method Detail

setup

public void setup(Map attributes)
Specified by:
setup in class BasePRNG

fillBlock

public void fillBlock()
               throws LimitReachedException
Specified by:
fillBlock in class BasePRNG
Throws:
LimitReachedException

addRandomByte

public void addRandomByte(byte b)
Description copied from interface: 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 UnsupportedOperationException.

Specified by:
addRandomByte in interface IRandom
Overrides:
addRandomByte in class BasePRNG
Parameters:
b - The byte to add.

addRandomBytes

public void addRandomBytes(byte[] buf,
                           int offset,
                           int length)
Description copied from interface: 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 UnsupportedOperationException.

Specified by:
addRandomBytes in interface IRandom
Overrides:
addRandomBytes in class BasePRNG
Parameters:
buf - The buffer of new random bytes to add.
offset - The offset from whence to begin reading random bytes.
length - The number of random bytes to add.

addRandomEvent

public void addRandomEvent(RandomEvent event)
Specified by:
addRandomEvent in interface RandomEventListener

For the latest news and information visit
The GNU Crypto project

Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.