ChaCha20Algorithm constructor

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

Expects a key with 8*32 bit, a 32-bit block-counter and a 3x32 bit nonce

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,
    nonce[0],
    nonce[1],
    nonce[2]
  ]);
}