ChaCha20Algorithm constructor

ChaCha20Algorithm(
  1. Uint32List key,
  2. int blockCounter,
  3. Uint32List nonce
)

Expects a key of 8x32 bits, a 32-bit block counter and a nonce of 3x32 bits.

Implementation

ChaCha20Algorithm(Uint32List key, int blockCounter, Uint32List nonce) {
  assert(key.length == 8);
  assert(nonce.length == 3);
  chaChaState = Uint32List.fromList([
    magicConstants[0],
    magicConstants[1],
    magicConstants[2],
    magicConstants[3],
    key[0],
    key[1],
    key[2],
    key[3],
    key[4],
    key[5],
    key[6],
    key[7],
    blockCounter & 0xFFFFFFFF,
    nonce[0],
    nonce[1],
    nonce[2],
  ]);
}