org.hd.d.efs
Class InternalEntropySource

java.lang.Object
  extended by org.hd.d.efs.InternalEntropySource

public final class InternalEntropySource
extends java.lang.Object

Used by EntropyPool (and Gatherer) to generate entropy within the JVM. Follows the same sort of strategy as the default SecureRandom up to at least JDK1.4, but always generates new entropy each time. This is not provably real entropy, but plausibly so. This is not a good substitute for real external entropy.

This may not work with all VMs but attempts to adapt itself to the current VM and workload to be as robust (and fast) as possible.

This is expensive in terms of CPU time.

This can be used as an explicit entropy source by the gatherer.

TODO: make sure that the creation of the background thread does not cause problems when called from an EJB source; if it does we may be able fall back to timing increments of a counter in the current thread, throwing in creation and GC of objects for example.


Constructor Summary
InternalEntropySource()
           
 
Method Summary
static byte[] generateSeed(int numBytes)
          Generates seed bits for the internal generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InternalEntropySource

public InternalEntropySource()
Method Detail

generateSeed

public static byte[] generateSeed(int numBytes)
Generates seed bits for the internal generator. Returns the given number of seed bytes. This call may be used to seed other random number generators.

Other than memory-allocation overheads, it should not be dreadfully inefficient to get one byte at a time.

Parameters:
numBytes - the number of seed bytes to generate.
Returns:
the seed bytes.