def sm4.key.pick

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

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

120def sm4.key.pick(ok: Bool, +xs: List<&2, U32>) -> Result<&2, &2, L.LcError, LcSm4Key>:
121  match ok:
122    case True{}:
123      +tab = sm4.sbox()
124      Done{LcSm4Key{tab, sm4.schedule(32n, tab, 0, sm4.mk(xs, 0n), sm4.mk(xs, 1n), sm4.mk(xs, 2n), sm4.mk(xs, 3n))}}
125    case False{}:
126      Fail{L.LcBadKeyLength{B.len(xs)}}

Uses (10)

Used by (1)