/ɛm æk/
n. “Trust the message — not the path it traveled.”
MAC, short for Message Authentication Code, is a cryptographic construct designed to answer a deceptively simple question: has this message been altered, and did it come from someone who knows the secret? A MAC provides integrity and authenticity, but not secrecy. The contents of the message may be visible — what matters is that any tampering is detectable.
At its core, a MAC is generated by combining a message with a shared secret key using a deterministic algorithm. The result is a fixed-length tag that accompanies the message. When the message is received, the same computation is performed using the same key. If the tags match, the message is accepted. If they differ, the message is rejected outright.
Unlike digital signatures, MACs rely on symmetric trust. Both sender and receiver possess the same secret key. This makes MACs fast and efficient, but it also means they do not provide non-repudiation. Any party with the key could have generated the message. MACs prove membership in a trusted circle — not individual identity.
Many modern MAC constructions are built on top of other cryptographic primitives. HMAC combines a cryptographic hash function such as SHA256 with a secret key in a structure designed to resist collision and length-extension attacks. CMAC derives authentication from block ciphers like AES. Poly1305 uses polynomial math and is optimized for speed, provided each key is used only once.
In practice, MACs are rarely used in isolation anymore. They are most often embedded inside AEAD constructions, where encryption and authentication are inseparable. Algorithms like ChaCha20-Poly1305 and AES-GCM integrate a MAC directly into the encryption process, ensuring that ciphertext cannot be modified without detection.
Correct verification is as important as correct generation. MAC comparisons must be performed in constant time to avoid leaking information through timing side channels. A mathematically sound MAC can still fail catastrophically if implemented carelessly.
A MAC does not hide data. It does not decide who should be trusted. It does not forgive errors. It performs one role with brutal clarity: ensure that a message arrives exactly as it was sent, from someone who knows the secret.
In modern cryptography, MACs are foundational — quiet, efficient, and unforgiving. When they fail, it is rarely subtle.