Apex › Cryptography

The length-extension attack

Why H(secret ‖ message) is a broken MAC — and why HMAC exists. Because a Merkle–Damgård digest is the hash's internal state, an attacker who never learns the secret can resume from a published tag, append the message's padding plus their own bytes, and forge a valid tag. Play the attacker, watch the forgery get accepted, then flip to HMAC and watch it fail.

More in Cryptography