iaik.me.security
Class SecureRandom

java.lang.Object
  |
  +--iaik.me.security.SecureRandom

public class SecureRandom
extends Object

A class to generate secure random bytes. It makes use of the SHA message digest to generate secure pseudo random bytes from an initial true random seed. This true random seed must be provided by the user, either by setting it via addSeed() for a particular SecureRandom instance or by specifying a system default seed via SecureRandom.getSeedGenerator().addSeed(). If a seed has not been set, a warning message is displayed on the system console.


Constructor Summary
SecureRandom()
          Generate a new random number generator.
 
Method Summary
 void addSeed(byte[] newSeed)
          Add new entropy to the seed.
static SecureRandom getDefault()
          Get a new random number generator of the system default type.
static SecureRandom getSeedGenerator()
          Get the system default seed generator.
 byte[] nextBytes(byte[] bytes)
          Return bytes.length random bytes.
 int nextInt()
          Return a 32 bit random value as an integer.
 void setSeed(byte[] newSeed)
          Set the seed to the specified value.
static void setSeedGenerator(SecureRandom random)
          Set the system default seed generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureRandom

public SecureRandom()
Generate a new random number generator. The static method SecureRandom.getDefault() should be preferably used instead of this constructor.
Method Detail

getDefault

public static SecureRandom getDefault()
Get a new random number generator of the system default type.

getSeedGenerator

public static SecureRandom getSeedGenerator()
Get the system default seed generator.

setSeedGenerator

public static void setSeedGenerator(SecureRandom random)
Set the system default seed generator.

setSeed

public void setSeed(byte[] newSeed)
Set the seed to the specified value. Previous seeding information is lost, in most cases the method addSeed() is to be preferred.

addSeed

public void addSeed(byte[] newSeed)
Add new entropy to the seed. The data is automatically added to the seed generator as well.

nextBytes

public byte[] nextBytes(byte[] bytes)
Return bytes.length random bytes.

nextInt

public int nextInt()
Return a 32 bit random value as an integer.

This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note).

IAIK-JCE ME 3.04, (c) 2002 IAIK, (c) 2003 to 2006 Stiftung SIC