def aes.inv_rounds
import bend-osdev-aes@0.1.0.0/aes.bend as Aesimport Base
import bend-collections@1.0.0.0/src/crypto/aes/types.bend as T
158# bend-collections' rounds (n full rounds, then the last, a round key each)
159# undone, the last round key first
160def aes.inv_rounds(n: Nat, ks: List<&2, T.State>, c: T.State) -> T.State:
161 match n ks:
162 case 0n Con{k, rest}:
163 aes.inv_last(c, k)
164 case 1n+p Con{k, rest}:
165 aes.inv_round(aes.inv_rounds(p, rest, c), k)
166 case _ _:
167 aes.mask(c)