org.logi.crypto.random
Class PureSpinner

java.lang.Object
  |
  +--java.util.Random
        |
        +--org.logi.crypto.random.PureSpinner
All Implemented Interfaces:
java.io.Serializable

public class PureSpinner
extends java.util.Random

This class uses the scheduler to gather entropy.

To generate one byte of data it launches a thread which counts in a tight loop. After a certain time, this thread is killed and the 8 lowest order bytes of the counter are returned.

The spin-period is set when a PureSpinner object is created. It is chosen so that the counter will reach at least 1024 when a byte is generated. However, under excessive load the counter may not count much above 256.

The output of this RNG is may not have very good statistical properties, but each byte of data should contain one or two bits of entropy. It should not be used directly, but rather to gather entropy for another PRNG class such as the RandomSpinner class.

The helper class which does the actual number generation is based on code by Henry Strickland (strix@versant.com) and Greg Noel (greg@qualcomm.com). This was in turn based on similar C code by Matt Blaze, Jack Lacy, and Don Mitchell.

Author:
Logi Ragnarsson (logir@logi.org)
See Also:
RandomMD5, Spinner, Serialized Form

Constructor Summary
PureSpinner()
           
 
Method Summary
 void nextBytes(byte[] bytes)
          Generates a user specified number of random bytes.
 
Methods inherited from class java.util.Random
nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PureSpinner

public PureSpinner()
Method Detail

nextBytes

public void nextBytes(byte[] bytes)
Generates a user specified number of random bytes.
Overrides:
nextBytes in class java.util.Random


Copyright 1997-2000 Logi Ragnarsson