def sp.rounds

bend-osdev-legacy-ciphers@0.1.0.0 · serpent.bend:339

import bend-osdev-legacy-ciphers@0.1.0.0/serpent.bend as Serpent
import Base
import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M

339# the steps of the 32 rounds from round i: K_i, S_(i mod 8), then LT (rounds
340# 0 to 30) or K_32 (round 31)
341def sp.rounds(ks: List<&2, M.CmBlock>, +i: Nat) -> List<&2, LcSpOp>:
342  match ks:
343    case Con{k, Con{k32, Nil{}}}:
344      [LcSpKey{k}, LcSpS{sp.box(i)}, LcSpKey{k32}]
345    case Con{k, t}:
346      Con{LcSpKey{k}, Con{LcSpS{sp.box(i)}, Con{LcSpLt{}, sp.rounds(t, Nat.add(i, 1n))}}}
347    case Nil{}:
348      Nil{}

Uses (6)

Used by (1)