def des.perm32
import bend-osdev-legacy-ciphers@0.1.0.0/des.bend as Desimport Base
import bend-osdev-legacy-ciphers@0.1.0.0/legacy_ciphers.bend as L
169# a permutation of a 32-bit word (P): entry t is bit t of x
170def des.perm32(tab: List<&2, Nat>, +x: U32, acc: U32) -> U32:
171 match tab:
172 case Nil{}:
173 acc
174 case Con{t, rest}:
175 des.perm32(rest, x, U32.or(U32.shl(acc), L.lc.bit(x, Nat.sub(32n, t))))