Message Authentication Code
With a standard Cryptographic Hash Function, an adversary can simply send m’ || H(m’) because the hashing algorithm is public.
A MAC solves this by incorporating a Shared Secret Key (k) into the generation of the tag. It transforms the goal from just “Integrity” to “Integrity + Authenticity.”
How It Works
Unlike a standard hash function which takes one input (message), a MAC algorithm takes two inputs:
- Message (m)
- Secret Key (k)
The output is a short string of bits called the Tag (or authentication tag).
t=MAC(k,m)
Process
- Generation (Sender):
- The sender and receiver share a secret key
kin advance. - The sender computes
t=MAC(k,m). - The sender transmits the pair:
(m,t).
- The sender and receiver share a secret key
- Verification (Receiver):
- The receiver gets the message
m′and the tagt′. - Using their copy of the secret key
k, they compute their own tag:t=MAC(k,m′). - Comparison:
- If
t=t′, the message is authentic (came from someone with the key) and has integrity (was not modified). - If they do not match, the packet is discarded.
- If
- The receiver gets the message
Why This Defeats the Adversary
If an attacker intercepts the message and modifies it to m’, they need to calculate a new tag t’ for it to be accepted.
- Standard Hash: Easy, just run
H(m′). - MAC: Impossible. The attacker does not know
k, so they cannot computeMAC(k,m’). They cannot forge a valid tag.
Relevant Note(s):