javacard.security
Class RandomData

java.lang.Object
  extended byjavacard.security.RandomData

public abstract class RandomData
extends Object

The RandomData abstract class is the base class for random number generation. Implementations of RandomData algorithms must extend this class and implement all the abstract methods.


Field Summary
static byte ALG_PSEUDO_RANDOM
          Utility pseudo random number generation algorithms.
static byte ALG_SECURE_RANDOM
          Cryptographically secure random number generation algorithms.
 
Constructor Summary
protected RandomData()
          Protected constructor for subclassing.
 
Method Summary
abstract  void generateData(byte[] buffer, short offset, short length)
          Generates random data.
static RandomData getInstance(byte algorithm)
          Creates a RandomData instance of the selected algorithm.
abstract  void setSeed(byte[] buffer, short offset, short length)
          Seeds the random data generator.
 
Methods inherited from class java.lang.Object
equals
 

Field Detail

ALG_PSEUDO_RANDOM

public static final byte ALG_PSEUDO_RANDOM
Utility pseudo random number generation algorithms.

See Also:
Constant Field Values

ALG_SECURE_RANDOM

public static final byte ALG_SECURE_RANDOM
Cryptographically secure random number generation algorithms.

See Also:
Constant Field Values
Constructor Detail

RandomData

protected RandomData()
Protected constructor for subclassing.

Method Detail

getInstance

public static final RandomData getInstance(byte algorithm)
                                    throws CryptoException
Creates a RandomData instance of the selected algorithm. The pseudo random RandomData instance's seed is initialized to a internal default value.

Parameters:
algorithm - the desired random number algorithm. Valid codes listed in ALG_.. constants. See above.
Returns:
the RandomData object instance of the requested algorithm.
Throws:
CryptoException - with the following reason codes:
  • CryptoException.NO_SUCH_ALGORITHM if the requested algorithm is not supported.

generateData

public abstract void generateData(byte[] buffer,
                                  short offset,
                                  short length)
Generates random data.

Parameters:
buffer - the output buffer
offset - the offset into the output buffer
length - the length of random data to generate

setSeed

public abstract void setSeed(byte[] buffer,
                             short offset,
                             short length)
Seeds the random data generator.

Parameters:
buffer - the input buffer
offset - the offset into the input buffer
length - the length of the seed data


Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.