def aes.expand.go

bend-osdev-cipher-modes@0.1.0.0 · aes.bend:193

import bend-osdev-cipher-modes@0.1.0.0/aes.bend as Aes
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B

193# n more words from word i; win holds the last Nk words, oldest first, and acc
194# every word so far, newest first
195def aes.expand.go(n: Nat, +i: Nat, +nk: Nat, +win: List<&2, U32>, acc: List<&2, U32>) -> List<&2, U32>:
196  match n:
197    case 0n:
198      List.reverse(&2, U32, acc)
199    case 1n+p:
200      +w = U32.xor(aes.head(win), aes.temp(Nat.is_eq(Nat.mod(i, nk), 0n), i, nk, aes.last(win, 0)))
201      aes.expand.go(p, 1n+i, nk, B.append(aes.tail(win), Con{w, Nil{}}), Con{w, acc})

Uses (12)

Used by (1)