inst_ccm.bend checks
raw source on the hub · import bend-osdev-crypto@0.1.0.0/inst_ccm.bend as Inst_ccm
CCM as an AEAD: cipher-modes' CCM (NIST SP 800-38C, RFC 3610) over any 128-bit block cipher, with a tag of tlen bytes (4, 6, ..., 16) and a nonce of 7 to 13 bytes. The instance over a block cipher (~K, ~key, ~enc): ~K, ~key, ~CrCcm.seal(~K, ~enc, ~tlen), ~CrCcm.open(~K, ~enc, ~tlen) for example AES-CCM with a 16-byte tag: ~X.CmAesKey, ~CrAes.key, ~CrCcm.seal(~X.CmAesKey, ~X.CmAes.encrypt, ~16n), ~CrCcm.open(~X.CmAesKey, ~X.CmAes.encrypt, ~16n)
6 imports
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/ccm.bend as CC import ./crypto.bend as Cr import ./inst_cm.bend as CM
Templates
template CrCcm.seal source · line 16 · raw
@-K:Data -> @-enc:(@_:K -> @_:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock) -> @-tlen:Nat -> @k:K -> @nonce:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @aad:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @p:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>
the ciphertext of p, then the tlen-byte tag
template CrCcm.open source · line 20 · raw
@-K:Data -> @-enc:(@_:K -> @_:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock) -> @-tlen:Nat -> @k:K -> @nonce:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @aad:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @c:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>
the plaintext of c (the ciphertext, then the tag), or CrTagMismatch