def sm4_cbc_big

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

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-legacy-ciphers@0.1.0.0/sm4.bend as S
import bend-osdev-crypto@0.1.0.0/crypto.bend as Cr
import bend-osdev-crypto@0.1.0.0/modes.bend as Md
import bend-osdev-crypto@0.1.0.0/inst_cm.bend as CM
import bend-osdev-crypto@0.1.0.0/inst_lc.bend as LC

283def sm4_cbc_big(+k: B.Octets, +iv: B.Octets, +m: B.Octets) -> String:
284  +r = LC.CrLc.key(~S.LcSm4Key, ~S.LcSm4.key, k)
285  +c = Result.bind(&2, &2, Cr.CrError, S.LcSm4Key, B.Octets, r, kk => Md.CrCbc.encrypt(~S.LcSm4Key, ~M.CmBlock, ~16n, ~S.LcSm4.encrypt, ~CM.CrBlk128.xor, ~CM.CrBlk128.of_octets, ~CM.CrBlk128.to_octets, kk, iv, m))
286  round(m, c, Result.bind(&2, &2, Cr.CrError, S.LcSm4Key, B.Octets, r, kk => Result.bind(&2, &2, Cr.CrError, B.Octets, B.Octets, c, x => Md.CrCbc.decrypt(~S.LcSm4Key, ~M.CmBlock, ~16n, ~S.LcSm4.decrypt, ~CM.CrBlk128.xor, ~CM.CrBlk128.of_octets, ~CM.CrBlk128.to_octets, kk, iv, x))))

Uses (16)

Used by (1)