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

Quick Search    Search Deep

gnu.java.security.prng
Class MDGenerator  view MDGenerator download MDGenerator.java

java.lang.Object
  extended bygnu.java.security.prng.BasePRNG
      extended bygnu.java.security.prng.MDGenerator
All Implemented Interfaces:
java.lang.Cloneable, IRandom

public class MDGenerator
extends BasePRNG
implements java.lang.Cloneable

A simple pseudo-random number generator that relies on a hash algorithm, that (a) starts its operation by hashing a seed, and then (b) continuously re-hashing its output. If no hash algorithm name is specified in the java.util.Map of attributes used to initialise the instance then the SHA-160 algorithm is used as the underlying hash function. Also, if no seed is given, an empty octet sequence is used.


Field Summary
private  gnu.java.security.hash.IMessageDigest md
          The underlying hash instance.
static java.lang.String MD_NAME
          Property name of underlying hash algorithm for this generator.
static java.lang.String SEEED
          Property name of seed material.
 
Fields inherited from class gnu.java.security.prng.BasePRNG
buffer, initialised, name, ndx
 
Constructor Summary
MDGenerator()
          Trivial 0-arguments constructor.
 
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 off, int len)
          Supplement, or possibly replace, the random state of this PRNG with a sequence of new random bytes.
 java.lang.Object clone()
          Returns a clone copy of this instance.
 void fillBlock()
           
 void setup(java.util.Map attributes)
           
 
Methods inherited from class gnu.java.security.prng.BasePRNG
addRandomBytes, 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

MD_NAME

public static final java.lang.String MD_NAME
Property name of underlying hash algorithm for this generator.

See Also:
Constant Field Values

SEEED

public static final java.lang.String SEEED
Property name of seed material.

See Also:
Constant Field Values

md

private gnu.java.security.hash.IMessageDigest md
The underlying hash instance.

Constructor Detail

MDGenerator

public MDGenerator()
Trivial 0-arguments constructor.

Method Detail

setup

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

fillBlock

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

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 java.lang.UnsupportedOperationException.

Specified by:
addRandomByte in interface IRandom
Overrides:
addRandomByte in class BasePRNG

addRandomBytes

public void addRandomBytes(byte[] buf,
                           int off,
                           int len)
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 java.lang.UnsupportedOperationException.

Specified by:
addRandomBytes in interface IRandom
Overrides:
addRandomBytes in class BasePRNG

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: IRandom

Returns a clone copy of this instance.

Specified by:
clone in interface IRandom
Overrides:
clone in class BasePRNG