public abstract class RandomData extends Object
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.Modifier and Type | Class and Description |
---|---|
static class |
RandomData.OneShot
The
OneShot class is a specialization of the RandomData
class intended to support efficient one-shot random data generation
operations that may avoid persistent memory writes entirely. |
Modifier and Type | Field and Description |
---|---|
static byte |
ALG_FAST
Utility random number generation algorithm.
|
static byte |
ALG_KEYGENERATION
This algorithm creates random numbers suitable to be used for key and
nonce generation.
|
static byte |
ALG_PRESEEDED_DRBG
Deterministic Random Bit Generator (DRBG) algorithm.
|
static byte |
ALG_PSEUDO_RANDOM
Deprecated.
As of release 3.0.5.
|
static byte |
ALG_SECURE_RANDOM
Deprecated.
As of release 3.0.5.
|
static byte |
ALG_TRNG
True Random Number Generation (TRNG) algorithm.
|
Modifier | Constructor and Description |
---|---|
protected |
RandomData()
Protected constructor for subclassing.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
generateData(byte[] buffer,
short offset,
short length)
Deprecated.
As of release 3.0.5, replaced by
nextBytes(byte[], short, short) . |
abstract byte |
getAlgorithm()
Gets the random number generation algorithm.
|
static RandomData |
getInstance(byte algorithm)
Creates a
RandomData instance of the selected algorithm. |
abstract short |
nextBytes(byte[] buffer,
short offset,
short length)
Generates random data.
|
abstract void |
setSeed(byte[] buffer,
short offset,
short length)
Seeds the random data generator.
|
public static final byte ALG_PSEUDO_RANDOM
Even if a transaction is in progress, the update of the internal state shall not participate in the transaction.
The security level and the standards conformance of the pseudo random number algorithm is implementation dependant
public static final byte ALG_SECURE_RANDOM
public static final byte ALG_TRNG
The security level and the standards conformance of the TRNG algorithm is implementation dependant.
public static final byte ALG_PRESEEDED_DRBG
setSeed
method.
The security level and the standards conformance of the DRBG algorithm is implementation dependant.
public static final byte ALG_FAST
public static final byte ALG_KEYGENERATION
The security level and the standards conformance of the this algorithm is implementation dependant.
public static final RandomData getInstance(byte algorithm) throws CryptoException
RandomData
instance of the selected algorithm.
The pseudo random RandomData
instance's seed is
initialized to a internal default value.algorithm
- the desired random number algorithm. Valid codes listed in
ALG_*
constants above, for example
ALG_PRESEEDED_DRBG
.RandomData
object instance of the requested
algorithmCryptoException
- with the following reason codes:
CryptoException.NO_SUCH_ALGORITHM
if
the requested algorithm is not supported.
public abstract void generateData(byte[] buffer, short offset, short length) throws CryptoException
nextBytes(byte[], short, short)
.buffer
- the output bufferoffset
- the offset into the output bufferlength
- the length of random data to generateCryptoException
- with the following reason codes:
CryptoException.ILLEGAL_VALUE
if the
length
parameter is zero.
public abstract short nextBytes(byte[] buffer, short offset, short length) throws CryptoException
short
result, this method sets the
result in an internal state which can be rechecked using assertion methods
of the SensitiveResult
class,
if supported by the platform.buffer
- the output bufferoffset
- the offset into the output bufferlength
- the length of random data to generateoffset+length
CryptoException
- with the following reason codes:
CryptoException.ILLEGAL_VALUE
if the
length
parameter is zero.
public abstract void setSeed(byte[] buffer, short offset, short length)
buffer
- the input bufferoffset
- the offset into the input bufferlength
- the length of the seed datapublic abstract byte getAlgorithm()
ALG_*
constants above, for example,
ALG_PRESEEDED_DRBG
.
In addition to returning a byte
result, this method sets the
result in an internal state which can be rechecked using assertion methods
of the SensitiveResult
class,
if supported by the platform.Copyright © 1998, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms