com.southernstorm.noise.crypto.chacha20

## Class ChaChaCore

- java.lang.Object
- - com.southernstorm.noise.crypto.chacha20.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 and 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` | `initKey256(int[] output, byte[] key, int offset)` Initializes a ChaCha20 block with a 256-bit key.
    `static void` | `xorBlock(byte[] input, int inputOffset, byte[] output, int outputOffset, int length, int[] block)` XOR's the output of ChaCha20 with a byte buffer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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.

    - #### 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.

    - #### 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.

    - #### xorBlock

          public static void xorBlock(byte[] input,
                                      int inputOffset,
                                      byte[] output,
                                      int outputOffset,
                                      int length,
                                      int[] block)

      XOR's the output of ChaCha20 with a byte buffer.
      Parameters:
        `input` - The input byte buffer.
        `inputOffset` - The offset of the first input byte.
        `output` - The output byte buffer (can be the same as the input).
        `outputOffset` - The offset of the first output byte.
        `length` - The number of bytes to XOR between 1 and 64.
        `block` - The ChaCha20 output block.