Lrw.CrLrw.key: def of bend-osdev-crypto@0.1.0.0 Import: import bend-osdev-crypto@0.1.0.0/lrw.bend as Lrw Lines 115-123 of bend-osdev-crypto@0.1.0.0/lrw.bend: https://jend.leeeet.dev/read.txt?path=bend-osdev-crypto@0.1.0.0/lrw.bend&start_line=115&end_line=123 import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import bend-osdev-gf@0.1.0.0/gf128.bend as G import bend-osdev-crypto@0.1.0.0/crypto.bend as Cr # a raw key: the cipher's key followed by the 16-byte tweak key # (CrBadKeyLength for a key of 16 bytes or fewer, or one the cipher refuses) def CrLrw.key(~K: Data, ~key: B.Octets -> Result<&2, &2, Cr.CrError, K>, +o: B.Octets) -> Result<&2, &2, Cr.CrError, CrLrwKey>: +n = B.Octets.len(o) do Result<&2, &2, Cr.CrError, CrLrwKey>: Cr.CrError.check(Nat.is_lt(16n, n), Cr.CrBadKeyLength{n}) k : K <- key(B.Octets.take(Nat.sub(n, 16n), o)) t : G.Gf128 <- cr.lrw.gf(n, G.Gf128.of_octets(B.Octets.drop(Nat.sub(n, 16n), o))) return CrLrwKey{k, t} Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets.drop https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets.len https://jend.leeeet.dev/definition.txt?path=bend-osdev-bytes@0.1.1.0/bytes.bend&name=Octets.take https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/crypto.bend&name=CrError https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/crypto.bend&name=CrError.check https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/lrw.bend&name=CrLrwKey https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/lrw.bend&name=cr.lrw.gf https://jend.leeeet.dev/definition.txt?path=bend-osdev-gf@0.1.1.0/gf128.bend&name=Gf128 https://jend.leeeet.dev/definition.txt?path=bend-osdev-gf@0.1.1.0/gf128.bend&name=Gf128.of_octets