Class ChaChaCore


  • public final class ChaChaCore
    extends Object
    Implementation of the ChaCha20 core hash transformation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void hash​(int[] output, int[] input)
      Hashes an input block with ChaCha20.
      static void initIV​(int[] output, long iv)
      Initializes the 64-bit initialization vector in a ChaCha20 block.
      static void initIV​(int[] output, long iv, long counter)
      Initializes the 64-bit initialization vector and counter in a ChaCha20 block.
      static void initKey256​(int[] output, byte[] key, int offset)
      Initializes a ChaCha20 block with a 256-bit key.
    • Method Detail

      • hash

        public static void hash​(int[] output,
                                int[] input)
        Hashes an input block with ChaCha20.
        Parameters:
        output - The output block, which must contain at least 16 elements and must not overlap with the input.
        input - The input block, which must contain at least 16 elements.
      • initKey256

        public static void initKey256​(int[] output,
                                      byte[] key,
                                      int offset)
        Initializes a ChaCha20 block with a 256-bit key.
        Parameters:
        output - The output block, which must consist of at least 16 words.
        key - The buffer containing the key.
        offset - Offset of the key in the buffer.
      • initIV

        public static void initIV​(int[] output,
                                  long iv)
        Initializes the 64-bit initialization vector in a ChaCha20 block.
        Parameters:
        output - The output block, which must consist of at least 16 words and must have been initialized by initKey256() or initKey128().
        iv - The 64-bit initialization vector value. The counter portion of the output block is set to zero.
      • initIV

        public static void initIV​(int[] output,
                                  long iv,
                                  long counter)
        Initializes the 64-bit initialization vector and counter in a ChaCha20 block.
        Parameters:
        output - The output block, which must consist of at least 16 words and must have been initialized by initKey256() or initKey128().
        iv - The 64-bit initialization vector value.
        counter - The 64-bit counter value.