iaik.security.random
Class JDKSeedGenerator

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

public class JDKSeedGenerator
extends SeedGenerator

This class is a simple wrapper for the seed generator used in JDK SecureRandom. It can generate as many bytes as you need, but it is fairly slow. That process is started when you call getSeed(). Per default this class generates a 160 bit seed (20 bytes).

Depending on the platform and JDK version you are using the performance may vary. On Windows NT it generates about 3 bytes per second regardsless of your CPU speed, on the same machine with Windows 95/98 it might take several seconds for a single byte, i.e. possibly a couple of minutes for the 160 bit seed. Also, performance may degrade extremely if the CPU load changes while the seed generator is running or is very high when it is started. Note that it consumes your entire CPU while running.

In short, I am not very happy with the seed generation in the JDK. Unfortunately, we are currently not able to offer an alternative that works without user interaction and generates a secure seed on all the various platforms.

Version:
File Revision 15

Fields inherited from class iaik.security.random.SeedGenerator
seedGenListener
 
Constructor Summary
JDKSeedGenerator()
          Initialize generation of a seed with the default amount of randomness (160 bit).
JDKSeedGenerator(int numBits)
          Initialize generation of a seed with the specified number of bits of randomness.
 
Method Summary
 byte[] getSeed()
          Return the seed.
 int[] getStatus()
          Return the status of seed generation.
 
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

JDKSeedGenerator

public JDKSeedGenerator()
Initialize generation of a seed with the default amount of randomness (160 bit).

JDKSeedGenerator

public JDKSeedGenerator(int numBits)
Initialize generation of a seed with the specified number of bits of randomness.
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()
Return the seed. It takes about 1/3 of a second per byte until this method returns (when called for the first time, later it will return the same seed again instantly).
Overrides:
getSeed in class SeedGenerator

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