public class ISAACRandomGenerator extends java.lang.Object implements RandomGenerator
Modifier and Type | Field and Description |
---|---|
private ISAACEngine |
engine |
private byte[] |
seed |
Constructor and Description |
---|
ISAACRandomGenerator(StreamCipher engine)
Default constructor, at the moment only ISAAC engine is supported,
but in future ISAAC+ will also be supported.
|
Modifier and Type | Method and Description |
---|---|
void |
addSeedMaterial(byte[] seed)
Add more seed material to the generator.
|
void |
addSeedMaterial(long seed)
Add more seed material to the generator.
|
void |
init(byte[] seed)
Initialize the ISAAC random generator with an initial seed value.
|
java.math.BigInteger |
nextBigInteger()
Since most PRNG are used for NUMBERS it seems prudent to add an additional
function to return randomly generated data as BigInteger instead of having to
always convert manually from bytes.
|
void |
nextBytes(byte[] bytes)
Generates a random data using ISAAC stream cipher and populates
the byte array provided with the random number.
|
void |
nextBytes(byte[] bytes,
int start,
int len)
Generates a random data using ISAAC stream cipher and populates
the byte array provided with the random number.
|
int |
nextInt()
Since most PRNG are used for NUMBERS it seems prudent to add an additional
function to return randomly generated data as int instead of having to
always convert manually from bytes.
|
void |
reset()
Resets the CSPRNG, after resetting the CSPRNG you must either re-initialize
it or add additional seed material.
|
private ISAACEngine engine
private byte[] seed
public ISAACRandomGenerator(StreamCipher engine) throws java.lang.IllegalArgumentException
engine
- The ISAAC engine, currently ISAAC+ is NOT supportedjava.lang.IllegalArgumentException
- if the stream cipher is not ISAACpublic void init(byte[] seed) throws DataLengthException
seed
- The seed value, must be specifiedDataLengthException
- if the seed is not specified or has weak entropypublic void addSeedMaterial(byte[] seed) throws DataLengthException
RandomGenerator
addSeedMaterial
in interface RandomGenerator
seed
- a byte array to be mixed into the generator's state.DataLengthException
public void addSeedMaterial(long seed) throws DataLengthException
RandomGenerator
addSeedMaterial
in interface RandomGenerator
seed
- a long value to be mixed into the generator's state.DataLengthException
public void nextBytes(byte[] bytes)
nextBytes
in interface RandomGenerator
bytes
- The output byte array to populate with the random numberpublic void nextBytes(byte[] bytes, int start, int len)
nextBytes
in interface RandomGenerator
bytes
- The output byte array to populate with the random numberstart
- The index to start filling atlen
- The length of the segment to fillpublic java.math.BigInteger nextBigInteger()
public int nextInt()
public void reset()