Concepts / Cryptography at work

Cryptography at work

Message authentication code

Also called authentication tag, mac tag

A keyed hash: a tag computed from a message and a secret key, so only a holder of the key can produce or check it.

No key, no valid tag
No key, no valid tag

The tag is computed from the message and a shared secret key. Someone who changes the message cannot make a matching tag without the key, so the receiver rejects it.

A message authentication code (MAC) is a tag computed from a message and a secret key. Anyone can compute a [[cryptographic-hash|hash]], but only a holder of the key can make or check the tag, so a changed message is caught. HMAC is the standard: openssl dgst -sha256 -hmac KEY file. Do not build hash(key + message): with SHA-256 a length-extension attack appends data and fixes the tag without the key.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab