iaik.security.random
Class AutoSeedGenerator

java.lang.Object
  |
  +--iaik.security.random.SeedGenerator
        |
        +--iaik.security.random.AutoSeedGenerator

public class AutoSeedGenerator
extends SeedGenerator

This seed generator automatically generates random bits without the need for user interaction. It was designed to work in Applets and therefore does not utilize access to files or to the network. It is intended to serve as a replacement for the JDKSeedGenerator and can generate seeds of any length.

Basically it continously calls System.currentTimeMillis() and waits until time has progressed by a certain amount. The number of the calls made is counted and the lowest bit is used as the next random bit. The time it waits is automatically adjusted in order to make the call-count large enough to serve as a reliable random bit source. This class always generates 16 bits at a time, i.e. if you ask it for 17 bits, it will generate 32 bits and return them as a byte array with four elements.

The speed of random bit generation is dependent on your virtual machine implementation and your execution speed. In general higher clock resolution and faster CPUs will yield a higher bit generation rate. On a Pentium class machine under Windows NT and a JIT compiler you should get about 80-90 bits per second (once it is jitted). Slower or non JIT machines will achieve 40-50 bps. Unix systems will usually perform slightly better and especially have a reduced slowdown as they typically have a hight clock resolution. The JDK seedgenerator is much less dependent on CPU speed but more dependent on the OS and VM implementation. Under Windows NT it does only about 30-40 bps with JIT, under Solaris 40-60 (without JIT!).

Security considerations: This seedgenerator makes extensive use of System.currentTimeMillis(). An attacker who has full control over that method could very easily make this seedgenerator generate any seed he wants. However, if we assume an attacker has that much control over the virtual machine, alternative seed generators cannot be much better. Still, this seedgenerator seems to be hardly affected by differences in implementation of the virtual machine and the currentTimeMillis() method and *should* work fine on all systems.

WARNING: Although this class has been subject to a significant amount of testing using the FIPS140Test class under Windows NT, Linux, and Solaris this class should still be considered beta and not used in critical applications, especially under untested operating systems and virtual machine implementations.

Version:
File Revision 18

Fields inherited from class iaik.security.random.SeedGenerator
seedGenListener
 
Constructor Summary
AutoSeedGenerator()
          Create a new AutoSeedGenerator that generates the default amount of random bits (currently 160).
AutoSeedGenerator(int numBits)
          Create a new AutoSeedGenerator that generates the specified number of random bits.
 
Method Summary
 byte[] getSeed()
          Get the seed.
 int[] getStatus()
          Return the status of seed generation.
static void main(String[] args)
           
 
Methods inherited from class iaik.security.random.SeedGenerator
callSeedGenListener, getDefault, getDefaultSeedGenerator, longToBytes, seedAvailable, setDefault, setDefaultSeedGenerator, setSeedGenListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoSeedGenerator

public AutoSeedGenerator()
Create a new AutoSeedGenerator that generates the default amount of random bits (currently 160).

AutoSeedGenerator

public AutoSeedGenerator(int numBits)
Create a new AutoSeedGenerator that generates the specified number of random bits.
Method Detail

getStatus

public int[] getStatus()
Return the status of seed generation. This is always {numBits, numBits}, i.e. it is always ok to call getSeed().
Overrides:
getStatus in class SeedGenerator

getSeed

public byte[] getSeed()
Get the seed. It will take a while until this method returns, random bit generation speed is typically 40 - 90 bits per second. If you call this method again on the same object, it will return the same seed again immediately.
Overrides:
getSeed in class SeedGenerator

main

public static void main(String[] args)

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK