FileDocCategorySizeDatePackage
SecureRandom.javaAPI DocphoneME MR2 API (J2ME)3297Wed May 02 18:00:26 BST 2007com.sun.midp.crypto

SecureRandom

public abstract class SecureRandom extends Object
Implements an abstract class that generalizes random number generators.

Fields Summary
public static final byte
ALG_PSEUDO_RANDOM
Identifies a utility pseudo random number generation algorithm.
public static final byte
ALG_SECURE_RANDOM
Identifies a cryptographically secure random number generation algorithm.
Constructors Summary
protected SecureRandom()
Protected constructor for subclassing.

    
              
      
    
Methods Summary
public static com.sun.midp.crypto.SecureRandomgetInstance(byte alg)
Creates a RandomData instance of the selected algorithm.

WARNING: Requests for a secure random number generator are currently redirected to a class that implements a weakly unpredictable source of random data. Licensees of this reference implementation are strongly urged to link requests for ALG_SECURE_RANDOM to better generators that may be available on their specific platforms.

param
alg the desired random number generation algorithm, e.g. ALG_PSEUDO_RANDOM
return
a RandomData instance implementing the selected algorithm.
exception
NoSuchAlgorithmException if an unsupported algorithm is requested.

	switch (alg) {
	 case ALG_SECURE_RANDOM:
	    // return (new SRand());
	 case ALG_PSEUDO_RANDOM:
	    return (new PRand());
	 default:
	    throw new NoSuchAlgorithmException();
	}
    
public abstract voidnextBytes(byte[] buf, int off, int len)
Generates the next bytes of random data.

param
buf output buffer in which the random data is to be placed
param
off starting offset within buf for the random data
param
len number of bytes of random data to be placed in buf

public abstract voidsetSeed(byte[] buf, int off, int len)
Seeds the random number generator.

param
buf input buffer containing the seed
param
off offset within buf where the seed starts
param
len number of bytes of seed data in buf