def encrypt_blocks

bend-collections@1.0.0.0 · spec/crypto/chacha.bend:158

import bend-collections@1.0.0.0/spec/crypto/chacha.bend as Chacha
import Base

158# for j = 0 .. : block j is XORed with chacha20_block(key, counter + j, nonce).
159def encrypt_blocks(bs: List<&2, List<&2, U32>>, +n: Nat, +key: List<&2, U32>, +counter: U32, +nonce: List<&2, U32>) -> List<&2, U32>:
160  match bs:
161    case Nil{}: Nil{}
162    case b <> rest:
163      List.append(&2, U32, xor_bytes(b, block_rounds(n, key, counter, nonce)),
164        encrypt_blocks(rest, n, key, U32.add(counter, 1), nonce))

Uses (7)

Used by (1)