~/bend-docscommunity

inst_cmac.bend checks

raw source on the hub · import bend-osdev-crypto@0.1.0.0/inst_cmac.bend as Inst_cmac

CMAC as a MAC: cipher-modes' CMAC (NIST SP 800-38B, RFC 4493) over any 128-bit block cipher (~K, ~key, ~enc). The instance: ~K, ~key, ~CrCmac.mac(~K, ~enc), ~CrCmac.verify(~K, ~enc) for example AES-CMAC: ~X.CmAesKey, ~CrAes.key, ~CrCmac.mac(~X.CmAesKey, ~X.CmAes.encrypt), ~CrCmac.verify(~X.CmAesKey, ~X.CmAes.encrypt) verify is the interface's named default (mac.bend: CrMac.verify_tag), so its laws hold for CMAC by the generic proof; cipher-modes' own Cmac.verify does the same comparison, but no law of cipher-modes ties it to Cmac.mac.

5 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/cmac.bend as CMc
import ./mac.bend as Mc

Templates

template CrCmac.mac source · line 18 · raw

@-K:Data -> @-enc:(@_:K -> @_:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock) -> @k:K -> @m:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

the 16-byte tag of m

template CrCmac.verify source · line 22 · raw

@-K:Data -> @-enc:(@_:K -> @_:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock) -> @k:K -> @m:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @t:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Bool

whether t is m's tag (every byte compared)