Class ChaCha20Random

  • All Implemented Interfaces:
    java.io.Serializable

    public class ChaCha20Random
    extends java.security.SecureRandom
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int[] basestate
      ChaCha base state
      protected long blockcount
      Current block count.
      protected IEntropySource entropysource
      Entropy source for seeding, use SSecurity.
      protected int outptr
      Pointer to unused output.
      protected byte[] outputblock
      The output block.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] generateSeed​(int numbytes)
      Generates a seed value from OS source.
      protected void nextBlock()
      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, 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
    • Field Detail

      • entropysource

        protected IEntropySource entropysource
        Entropy source for seeding, use SSecurity.
      • basestate

        protected int[] basestate
        ChaCha base state
      • blockcount

        protected long blockcount
        Current block count.
      • outputblock

        protected byte[] outputblock
        The output block.
      • outptr

        protected int outptr
        Pointer to unused output.
    • Constructor Detail

      • ChaCha20Random

        public ChaCha20Random()
        Initializes the PRNG.
      • ChaCha20Random

        public ChaCha20Random​(IEntropySource seedrandom)
        Initializes the PRNG.
      • ChaCha20Random

        public ChaCha20Random​(byte[] initialseed)
        Initializes the PRNG.
      • ChaCha20Random

        public ChaCha20Random​(IEntropySource entropysource,
                              byte[] initialseed)
        Initializes the PRNG.
    • Method Detail

      • nextLong

        public long nextLong()
        Gets the next long.
        Overrides:
        nextLong in class java.util.Random
      • nextInt

        public int nextInt()
        Gets the next int.
        Overrides:
        nextInt in class java.util.Random
      • nextBytes

        public void nextBytes​(byte[] bytes)
        Gets the next bytes.
        Overrides:
        nextBytes in class java.security.SecureRandom
      • nextBlock

        protected void nextBlock()
        Generates the next ChaCha block.
      • reseed

        public void reseed()
        Reseeds the PRNG.
        Overrides:
        reseed in class java.security.SecureRandom
      • 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 class java.security.SecureRandom