inst_rc4.bend
bend-osdev-crypto@0.1.0.0 · 27 lines · 3 definitions
1
2
3
4
5
6
7
8import Base
9import bend-osdev-bytes@0.1.0.0/bytes.bend as B
10import bend-osdev-legacy-ciphers@0.1.0.0/legacy_ciphers.bend as L
11import bend-osdev-legacy-ciphers@0.1.0.0/rc4.bend as R
12import bend-osdev-crypto@0.1.0.0/crypto.bend as Cr
13import bend-osdev-crypto@0.1.0.0/inst_lc.bend as LC
14
15def cr.rc4.start(+n: Nat, r: Result<&2, &2, L.LcError, R.LcRc4State>) -> Result<&2, &2, Cr.CrError, R.LcRc4State>:
16 do Result<&2, &2, Cr.CrError, R.LcRc4State>:
17 Cr.CrError.check(Nat.is_eq(n, 0n), Cr.CrBadIvLength{n})
18 LC.CrLc.lift(~R.LcRc4State, r)
19
20
21
22def CrRc4.start(key: B.Octets, iv: B.Octets) -> Result<&2, &2, Cr.CrError, R.LcRc4State>:
23 cr.rc4.start(B.Octets.len(iv), R.LcRc4.start(key))
24
25
26def CrRc4.start_drop(~n: Nat, key: B.Octets, iv: B.Octets) -> Result<&2, &2, Cr.CrError, R.LcRc4State>:
27 cr.rc4.start(B.Octets.len(iv), R.LcRc4.start_drop(key, n))