# Difference between AES CMAC and AES HMAC?

Can someone elaborate on how 'signing' is done using AES- CMAC and AES-HMAC?

HMAC Signing as I understand: Compute the HMAC( Hash the key and the input concatenated in a special way) Verification: Verify if for the given input and secret key the calculated HMAC(signature) is the same as that is computed. But how is AES used in conjunction with this? is it HMAC(AES(Data)) then what is CMAC?

CMAC signing as I understand: is to encrypt the input using the key by applying AES algorithm and then calculating a MAC by applying a special concatenation step of the key and resulting encrypted data??. For verification, the signature should be compared with the newly computed CMAC of input and key at the receiving end.

Thanks.

Also, does openSSL libs support AES CMAC and AES HMAC?

• Where did you read about AES HMAC? Perhaps you misunderstood and the source was talking about authenticated encryption that encrypts using AES (e.g. in CTR mode) and adds HMAC-SHA-* for integrity? – CodesInChaos Jan 13 '16 at 8:43
• Read about Message Authentication Codes in general. HMAC and CMAC are MACs. – Z.T. Jan 13 '16 at 9:38

A similar question as been asked before: Use cases for CMAC vs. HMAC?

To resume it, AES-CMAC is a MAC function. It can be seen as a special case of One-Key CBC MAC1 (OMAC1) which also a MAC function that relies on a block cipher (so AES in the present case).

HMAC is also a MAC function but which relies on a hash function (SHA256 for HMAC-SHA256 for example).

So the term AES-HMAC isn't really appropriate. If you read it somewhere, it could signify the process of computing a HMAC on the message you want to encrypt to ensure the integrity property (AES$[message ||$ HMAC$(message)]$ for example).

Note that there exists authenticated ciphers that simultaneously ensure confidentiality, integrity and authenticity.

Also, does openSSL libs support AES CMAC and AES HMAC?

OpenSSL supports HMAC primitive and also the AES-CMAC one (see How to calculate AES CMAC using OpenSSL?)

• AES-HMAC might also refer to cipher=AES(Ke,message), and then transmit cipher||HMAC(Kh,cipher) (in other words, encrypt-then-mac) – Martin Bonner supports Monica Aug 19 at 14:18