AesModes.CmAes.xts_encrypt: def of bend-osdev-cipher-modes@0.1.0.0 Import: import bend-osdev-cipher-modes@0.1.0.0/aes_modes.bend as AesModes Lines 39-47 of bend-osdev-cipher-modes@0.1.0.0/aes_modes.bend: https://jend.leeeet.dev/read.txt?path=bend-osdev-cipher-modes@0.1.0.0/aes_modes.bend&start_line=39&end_line=47 import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M import bend-osdev-cipher-modes@0.1.0.0/aes.bend as X import bend-osdev-cipher-modes@0.1.0.0/xts.bend as T # the data unit p with 16-byte sequence number i (Xts.sector(n) for sector n) def CmAes.xts_encrypt(+key: B.Octets, i: B.Octets, p: B.Octets) -> Result<&2, &2, M.CmError, B.Octets>: +n = B.Octets.len(key) +h = Nat.div(n, 2n) do Result<&2, &2, M.CmError, B.Octets>: M.cm.check(Bool.or(Nat.is_eq(n, 32n), Nat.is_eq(n, 64n)), M.CmBadKeyLength{n}) k1 : X.CmAesKey <- X.CmAes.key(B.Octets.take(h, key)) k2 : X.CmAesKey <- X.CmAes.key(B.Octets.drop(h, key)) T.Xts.encrypt(~X.CmAesKey, ~X.CmAes.encrypt, k1, k2, i, p) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.is_eq 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=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-cipher-modes@0.1.0.0/aes.bend&name=CmAes.encrypt https://jend.leeeet.dev/definition.txt?path=bend-osdev-cipher-modes@0.1.0.0/aes.bend&name=CmAes.key https://jend.leeeet.dev/definition.txt?path=bend-osdev-cipher-modes@0.1.0.0/aes.bend&name=CmAesKey https://jend.leeeet.dev/definition.txt?path=bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend&name=CmError https://jend.leeeet.dev/definition.txt?path=bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend&name=cm.check https://jend.leeeet.dev/definition.txt?path=bend-osdev-cipher-modes@0.1.0.0/xts.bend&name=Xts.encrypt