Integrity AND authenticity
A simple hash is not enough
Cryptographic hashing provides integrity: the slightest change to the message completely changes the fingerprint. But this guarantee has a limit that is often forgotten.
What hashing really protects
A hash function like SHA-256 is public. Anyone can apply it to any message. That is precisely its strength for verifying a download: you compare the fingerprint shown on the website to the one you compute at home.
But this openness is also its weakness as soon as an active attacker enters the picture, that is, someone able not only to eavesdrop on the channel, but to modify what travels through it.
The attack on "message + fingerprint"
Suppose Alice sends Bob her message together with its fingerprint, without any secret:
Alice ---> [ message M ] [ H(M) ] ---> Bob
Mallory intercepts in the middle
and replaces everything with M' :
Alice ---> Mallory ---> [ M' ] [ H(M') ] ---> Bob
Mallory forges a fake message M', recomputes H(M') herself with the same public function, and passes the pair to Bob. Bob checks: the received fingerprint does match the received message. Everything looks intact. Yet the message has been entirely replaced.
Hashing alone failed not because it is broken, but because nothing ties the fingerprint to Alice's identity. Everyone knows how to compute H.
A key is missing
The solution is to introduce a shared secret between Alice and Bob, a key that Mallory does not know. If the fingerprint can be computed only with this key, then Mallory can no longer forge it.
We thus distinguish two properties:
| Property | Question asked | Ensured by |
|---|---|---|
| Integrity | Has the message been modified? | hashing |
| Authenticity | Does it really come from the right sender? | secret key |
A simple hash gives integrity against accidents (transmission errors, corrupted disk), but not against a determined adversary. To withstand an active attacker, you need both properties at once, and that requires a key shared between the two correspondents.
In other words, hashing answers the question "is this message consistent?", but not the question "does this message really come from Alice?". Only a secret known to her alone (and to Bob) can answer the second.
In summary
A fingerprint alone proves nothing about the origin of the message: since the hash function is public, an active attacker who modifies the message can recompute the matching fingerprint. You must distinguish integrity (message unmodified) from authenticity (right sender). Guaranteeing both against an adversary requires a shared secret: this is the purpose of the MAC.

