**javacard.security** ====Class RandomData ==== *[[javacard:java-card-api:object|java.lang.Object]] \\ ---- public abstract class **RandomData**extends [[javacard:java-card-api:Object|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** | **[[javacard:java-card-api:RandomData#ALG_PSEUDO_RANDOM|ALG_PSEUDO_RANDOM]] **          Utility pseudo-random number generation algorithms. | | **static byte** | **[[javacard:java-card-api:RandomData#ALG_SECURE_RANDOM|ALG_SECURE_RANDOM]] **          Cryptographically secure random number generation algorithms. |   ^ Constructor Summary ^^ | **protected ** | **[[javacard:java-card-api:RandomData#RandomData()|RandomData]] **()          Protected constructor for subclassing. |   ^ Method Summary ^^ | **abstract  void** | **[[javacard:java-card-api:RandomData#generateData(byte[], short, short)|generateData]] **(byte[] buffer,short offset,short length)          Generates random data. | | **static [[javacard:java-card-api:RandomData|RandomData]] ** | **[[javacard:java-card-api:RandomData#getInstance(byte)|getInstance]] **(byte algorithm)          Creates a RandomData instance of the selected algorithm. | | **abstract  void** | **[[javacard:java-card-api:RandomData#setSeed(byte[], short, short)|setSeed]] **(byte[] buffer,short offset,short length)          Seeds the random data generator. |   ^ Methods inherited from class java.lang.Object ^ | [[javacard:java-card-api:Object#equals(java.lang.Object)|equals]] |   ^ Field Detail ^ === ALG_PSEUDO_RANDOM === public static final byte **ALG_PSEUDO_RANDOM** Utility pseudo-random number generation algorithms. The random number sequence generated by this algorithm need not be the same even if seeded with the same seed data. Even if a transaction is in progress, the update of the internal state shall not participate in the transaction. **See Also:**[[javacard:java-card-api:constant-values#javacard.security.RandomData.ALG_PSEUDO_RANDOM|Constant Field Values]] ---- === ALG_SECURE_RANDOM === public static final byte **ALG_SECURE_RANDOM** Cryptographically secure random number generation algorithms. **See Also:**[[javacard:java-card-api:constant-values#javacard.security.RandomData.ALG_SECURE_RANDOM|Constant Field Values]] ^ Constructor Detail ^ === RandomData === protected **RandomData**() Protected constructor for subclassing. ^ Method Detail ^ === getInstance === public static final [[javacard:java-card-api:RandomData|RandomData]] **getInstance**(byte algorithm) throws [[javacard:java-card-api:CryptoException|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 above. See [[javacard:java-card-api:RandomData#ALG_PSEUDO_RANDOM|ALG_PSEUDO_RANDOM]] . **Returns:**the RandomData object instance of the requested algorithm **Throws:** [[javacard:java-card-api:CryptoException|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) throws [[javacard:java-card-api:CryptoException|CryptoException]] Generates random data. **Parameters:**buffer - the output buffer offset - the offset into the output buffer length - the length of random data to generate **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason codes: \\ *CryptoException.ILLEGAL_VALUE if the length parameter is zero. \\ ---- === 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