def sm4.schedule

bend-osdev-legacy-ciphers@0.1.0.0 · sm4.bend:101

import bend-osdev-legacy-ciphers@0.1.0.0/sm4.bend as Sm4
import Base
import bend-osdev-legacy-ciphers@0.1.0.0/legacy_ciphers.bend as L

101# rk_i = K_(i+4) = K_i xor T'(K_(i+1) xor K_(i+2) xor K_(i+3) xor CK_i), for
102# n more rounds from round i, the window K_i .. K_(i+3) in k0 .. k3
103def sm4.schedule(n: Nat, +tab: L.LcTab, +i: U32, k0: U32, +k1: U32, +k2: U32, +k3: U32) -> List<&2, U32>:
104  match n:
105    case 0n:
106      Nil{}
107    case 1n+p:
108      +k4 = U32.xor(k0, sm4.t2(tab, U32.xor(U32.xor(U32.xor(k1, k2), k3), sm4.ck(i))))
109      Con{k4, sm4.schedule(p, tab, U32.add(i, 1), k1, k2, k3, k4)}

Uses (8)

Used by (1)