iaik.security.random
Class MetaSeedGenerator

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

public class MetaSeedGenerator
extends SeedGenerator

This seed generator generates new seeds given an initial seed. Often an application will need a number of seed generators. There is no need to seed each one separately from e.g. new user events, it is secure to generate a random seed only once and deduct further seeds from it using deterministic methods. This is what this class is for, it internally uses the system's default PRNG. The JDK SecureRandom uses a very similar mechanism.

To use it, first set the initial seed via one of the static setSeed() methods. Then create as many instances as you like using the constructors. It is anticipated that this seed generator will often be used as the default seed generator following an initialisation from user input.

NOTE: For obvious reasons, the initial seed should be as least as long as the longest seed that later is to be deducted from it. Also, as this classes uses the system's default PRNG (usually SHA1Random), so it can never generate true random seeds longer than the PRNG digest (160 bits for SHA1Random).

Version:
File Revision 15
See Also:
SeedGenerator, SHA1Random

Fields inherited from class iaik.security.random.SeedGenerator
seedGenListener
 
Constructor Summary
MetaSeedGenerator()
          Initialize generation of a seed with the default amount of randomness (160 bit).
MetaSeedGenerator(int numBits)
          Initialize generation of a seed with the specified amount of randomness.
 
Method Summary
 byte[] getSeed()
          Get the seed.
 int[] getStatus()
          Return the status of seed generation.
static void setSeed(byte[] seed)
          Set the initial seed to this byte array.
 
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

MetaSeedGenerator

public MetaSeedGenerator()
Initialize generation of a seed with the default amount of randomness (160 bit). See the notes at the top of this class about the value of this number.

MetaSeedGenerator

public MetaSeedGenerator(int numBits)
                  throws RandomException
Initialize generation of a seed with the specified amount of randomness. This methods throws a RandomException if no initial seed has been set via setSeed(). See the notes at the top of this class about the value of this number.
Method Detail

setSeed

public static void setSeed(byte[] seed)
Set the initial seed to this byte array. The array can be of any size. Note that this seed itself will never be returned by this class.

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. This will instantly return a seed of constantly 20 bytes length.
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