A MAC (message authentication code) is a cryptographic value that guarantees the authenticity of a message
A message authentication code (MAC) is a cryptographic primitive that calculates an authentication tag from a secret key and a message. The tag guarantees the authenticity of the message: only a party that has the secret key can compute a valid tag.
There are two common types of MAC functions:
- hmac functions are based on a cryptographic-hash-function, e.g. HMAC-SHA-256, HMAC-SHA-512, HMAC-SHA-1, etc.
- There are several ways to build a MAC out of a block-cipher, such as cmac and cbc-mac.
In public-key cryptography, authentication can be performed with signatures: generating the signature of a message requires the private key, but the signature can be verified with just the public key. This is in contrast with MAC where the same key is used to generate or verify the tag. MAC are sometimes called “signatures”, while other authors reserve the word “signature” for asymmetric cryptography.