AspectHMACCBC-MACCMAC
Full FormHash-based Message Authentication CodeCipher Block Chaining Message Auth. CodeCipher-based Message Authentication Code
Underlying PrimitiveCryptographic Hash Function (e.g., SHA-1, SHA-256)Block Cipher (e.g., AES, DES)Block Cipher (e.g., AES)
Key InputSingle secret keySingle secret keySingle secret key
Security DependencyDepends on the security of the hash functionDepends on block cipher and proper implementationMore secure variant of CBC-MAC
Variable-Length MessagesSecure for all message lengthsInsecure for variable-length messagesSecure for variable-length messages
Padding RequirementUses inner/outer padding for hash inputRequires message padding to full blocksRequires message padding and subkey derivation
StandardizationRFC 2104ISO/IEC 9797-1NIST SP 800-38B
PerformanceHigh efficiency with hash functionsEfficient, but limited to fixed-length messagesEfficient and secure for all lengths
Use CasesTLS, IPsec, digital signaturesLegacy systems, embedded systemsReplacement for CBC-MAC in secure systems

Summary

  • HMAC is widely used, versatile, and secure for all message lengths using hash functions.

  • CBC-MAC is simple and efficient but insecure for variable-length messages unless precautions are taken.

  • CMAC improves upon CBC-MAC by being secure for messages of any length and is based on block ciphers like AES.

For modern cryptographic applications, CMAC is preferred over CBC-MAC, and HMAC remains a popular choice due to its simplicity and strength based on hash functions.