Skip to main content

hchacha20

Function hchacha20 

Source
pub fn hchacha20(key: &[u8; 32], input: &[u8; 16]) -> [u8; 32]
Expand description

HChaCha20 is a hash function derived from ChaCha20.

It takes a 256-bit key and a 128-bit input (nonce) and produces a 256-bit hash. It is used internally by XChaCha20 to derive a subkey.

ยงAlgorithm

  1. Initialize a ChaCha20 state with the constant, key, and 128-bit nonce (placed in the counter and nonce positions).
  2. Perform 20 rounds (10 double rounds) of ChaCha quarter rounds.
  3. Output words 0-3 and 12-15 of the final state, serialized as little-endian bytes (without adding the initial state back).