Package jadex.ipc.impl.security.random
Class ChaCha20Random
java.lang.Object
java.util.Random
java.security.SecureRandom
jadex.ipc.impl.security.random.ChaCha20Random
- All Implemented Interfaces:
Serializable
,RandomGenerator
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[]
ChaCha base stateprotected long
Current block count.protected IEntropySource
Entropy source for seeding, use SSecurity.protected int
Pointer to unused output.protected byte[]
The output block. -
Constructor Summary
ConstructorsConstructorDescriptionInitializes the PRNG.ChaCha20Random
(byte[] initialseed) Initializes the PRNG.ChaCha20Random
(IEntropySource seedrandom) Initializes the PRNG.ChaCha20Random
(IEntropySource entropysource, byte[] initialseed) Initializes the PRNG. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
generateSeed
(int numbytes) Generates a seed value from OS source.protected void
Generates the next ChaCha block.void
nextBlock
(byte[] outputblock) Generate next block (64 bytes).void
nextBytes
(byte[] bytes) Gets the next bytes.int
nextInt()
Gets the next int.long
nextLong()
Gets the next long.void
reseed()
Reseeds the PRNG.void
reseed
(byte[] providedseed) Reseeds the PRNG.Methods inherited from class java.security.SecureRandom
getAlgorithm, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getInstanceStrong, getParameters, getProvider, getSeed, next, nextBytes, reseed, setSeed, setSeed, toString
Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, from, ints, ints, ints, ints, longs, longs, longs, longs, nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Field Details
-
entropysource
Entropy source for seeding, use SSecurity. -
basestate
protected int[] basestateChaCha base state -
blockcount
protected long blockcountCurrent block count. -
outputblock
protected byte[] outputblockThe output block. -
outptr
protected int outptrPointer to unused output.
-
-
Constructor Details
-
ChaCha20Random
public ChaCha20Random()Initializes the PRNG. -
ChaCha20Random
Initializes the PRNG. -
ChaCha20Random
public ChaCha20Random(byte[] initialseed) Initializes the PRNG. -
ChaCha20Random
Initializes the PRNG.
-
-
Method Details
-
nextLong
public long nextLong()Gets the next long.- Specified by:
nextLong
in interfaceRandomGenerator
- Overrides:
nextLong
in classRandom
-
nextInt
public int nextInt()Gets the next int.- Specified by:
nextInt
in interfaceRandomGenerator
- Overrides:
nextInt
in classRandom
-
nextBytes
public void nextBytes(byte[] bytes) Gets the next bytes.- Specified by:
nextBytes
in interfaceRandomGenerator
- Overrides:
nextBytes
in classSecureRandom
-
nextBlock
protected void nextBlock()Generates the next ChaCha block. -
reseed
public void reseed()Reseeds the PRNG.- Overrides:
reseed
in classSecureRandom
-
reseed
public void reseed(byte[] providedseed) Reseeds the PRNG. -
nextBlock
public void nextBlock(byte[] outputblock) Generate next block (64 bytes).- Parameters:
outputblock
- The block.
-
generateSeed
public byte[] generateSeed(int numbytes) Generates a seed value from OS source.- Overrides:
generateSeed
in classSecureRandom
-