Check.ccm: def of bend-osdev-crypto@0.1.0.0 Import: import bend-osdev-crypto@0.1.0.0/check.bend as Check Lines 233-240 of bend-osdev-crypto@0.1.0.0/check.bend: https://jend.leeeet.dev/read.txt?path=bend-osdev-crypto@0.1.0.0/check.bend&start_line=233&end_line=240 import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B 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/aead.bend as Ae import bend-osdev-crypto@0.1.0.0/inst_aes.bend as A import bend-osdev-crypto@0.1.0.0/inst_ccm.bend as CC # CCM-AES through the AEAD interface, an m-byte tag: the sealed message, the # plaintext opened again, and the result of opening it with the tag's last # byte changed def ccm(~tlen: Nat, +k: B.Octets, +n: B.Octets, +a: B.Octets, +p: B.Octets) -> String: +c = Ae.CrAead.seal_with(~X.CmAesKey, ~A.CrAes.key_enc, ~CC.CrCcm.seal(~X.CmAesKey, ~X.CmAes.encrypt, ~tlen), k, n, a, p) +o = Result.bind(&2, &2, Cr.CrError, B.Octets, B.Octets, c, x => Ae.CrAead.open_with(~X.CmAesKey, ~A.CrAes.key_enc, ~CC.CrCcm.open(~X.CmAesKey, ~X.CmAes.encrypt, ~tlen), k, n, a, x)) +bad = Result.bind(&2, &2, Cr.CrError, B.Octets, B.Octets, c, x => Ae.CrAead.open_with(~X.CmAesKey, ~A.CrAes.key_enc, ~CC.CrCcm.open(~X.CmAesKey, ~X.CmAes.encrypt, ~tlen), k, n, a, flip_last(x))) cat(show(c), cat(" ", cat(show(o), cat(" ", show(bad))))) Uses (15): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String 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-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=CmAesKey https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/aead.bend&name=CrAead.open_with https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/aead.bend&name=CrAead.seal_with https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/check.bend&name=cat https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/check.bend&name=flip_last https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/check.bend&name=show 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/inst_aes.bend&name=CrAes.key_enc https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/inst_ccm.bend&name=CrCcm.open https://jend.leeeet.dev/definition.txt?path=bend-osdev-crypto@0.1.0.0/inst_ccm.bend&name=CrCcm.seal