def lrw_aes

bend-osdev-crypto@0.1.0.0 · check.bend:320

import bend-osdev-crypto@0.1.0.0/check.bend as Check
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-crypto@0.1.0.0/crypto.bend as Cr
import bend-osdev-crypto@0.1.0.0/inst_cm.bend as CM
import bend-osdev-crypto@0.1.0.0/inst_aes.bend as A
import bend-osdev-crypto@0.1.0.0/lrw.bend as Lw

320def lrw_aes(+k: B.Octets, +iv: B.Octets, +m: B.Octets) -> String:
321  +r = Lw.CrLrw.key(~X.CmAesKey, ~A.CrAes.key, k)
322  +c = Result.bind(&2, &2, Cr.CrError, Lw.CrLrwKey<X.CmAesKey>, B.Octets, r, kk => Lw.CrLrw.encrypt(~X.CmAesKey, ~M.CmBlock, ~16n, ~X.CmAes.encrypt, ~CM.CrBlk128.xor, ~CM.CrBlk128.of_octets, ~CM.CrBlk128.to_octets, kk, iv, m))
323  both(c, Result.bind(&2, &2, Cr.CrError, Lw.CrLrwKey<X.CmAesKey>, B.Octets, r, kk => Result.bind(&2, &2, Cr.CrError, B.Octets, B.Octets, c, x => Lw.CrLrw.decrypt(~X.CmAesKey, ~M.CmBlock, ~16n, ~X.CmAes.decrypt, ~CM.CrBlk128.xor, ~CM.CrBlk128.of_octets, ~CM.CrBlk128.to_octets, kk, iv, x))))

Uses (17)

Used by (1)