Class au.net.aba.security.SecureRandom
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class au.net.aba.security.SecureRandom

java.lang.Object
   |
   +----java.util.Random
           |
           +----au.net.aba.security.SecureRandom

public final class SecureRandom
extends Random
This class provides a cryptographically strong pseudo-random number generator based on the SHA-1 hash algorithm. The calls inherited from Random will be implemented in terms of the strengthened functionality. NOTE: For seed generator (ie the default constructor) we only use a very small number of random bytes using an entropy generator of unknown quality. For secure results further entropy should be added to the generator.

Variable Index

 o ident

Constructor Index

 o SecureRandom()
This empty constructor automatically seeds the generator.
 o SecureRandom(byte[])
This constructor uses a user-provided seed in preference to the self-seeding algorithm referred to in the empty constructor description.

Method Index

 o getSeed(int)
Generate random bytes.
 o next(int)
Generates an integer containing the user-specified number of pseudo-random bits (right justified, with leading zeros).
 o nextBytes(byte[])
Generates a user-specified number of random bytes.
 o setSeed(byte[])
Re-seeds this random object.
 o setSeed(long)
Re-seeds this random object, using the eight bytes contained in the given long seed.

Variables

 o ident
  public final static String ident

Constructors

 o SecureRandom
  public SecureRandom()
This empty constructor automatically seeds the generator. We attempt to provide sufficient seed bytes to completely randomise the internal state of the generator (20 bytes). Note, however, that our seed generation algorithm has not been thoroughly studied or widely deployed. It relies on counting the number of times that the calling thread can yield while waiting for another thread to sleep for a specified interval.
 o SecureRandom
  public SecureRandom(byte seed[])
This constructor uses a user-provided seed in preference to the self-seeding algorithm referred to in the empty constructor description. It may be preferable to the empty constructor if the caller has access to high-quality random bytes from some physical device (for example, a radiation detector or a noisy diode).
Parameters:
seed - the seed for this generator

Methods

 o setSeed
  public synchronized void setSeed(byte seed[])
Re-seeds this random object. The given seed supplements, rather * than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.
Parameters:
seed - A series of bytes to seed with.
 o setSeed
  public void setSeed(long l)
Re-seeds this random object, using the eight bytes contained in the given long seed. The given seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness. This method is defined for compatibility with java.util.Random.
Parameters:
l - the seed.
Overrides:
setSeed in class Random
 o nextBytes
  public synchronized void nextBytes(byte bytes[])
Generates a user-specified number of random bytes. This method is used as the basis of all random entities returned by this class (except seed bytes). Thus, it may be overridden to change the behaviour of the class.
Parameters:
bytes - the array to be filled in with random bytes.
 o next
  protected final int next(int numBits)
Generates an integer containing the user-specified number of pseudo-random bits (right justified, with leading zeros). This method overrides a java.util.Random method, and serves to provide a source of random bits to all of the methods inherited from that class (for example, nextInt, nextLong, and nextFloat).
Parameters:
numBits - - number of pseudo-random bits to be generated, where 0 <= numBits <= 32.
Overrides:
next in class Random
 o getSeed
  public static byte[] getSeed(int numBytes)
Generate random bytes. This is a poor mans version of what is available in the JDK 1.1 and should be chucked as soon as possible. We allocate a minimum of 1 second for each loop, adding some number between 0 and 127 milliseconds at each iteration. Note: this will give us much greater protection than we get from just using the date, don't rely on it as the only source of randomness though.

All Packages  Class Hierarchy  This Package  Previous  Next  Index