Message authentication code
A Message Authentication Code (MAC) allows a user holding a secret key to authenticate messages by attaching a short tag. Anyone with the same key can verify the tag’s authenticity; no efficient adversary without the key, given tags on messages of its choice, can produce a valid tag on a new message except with negligible probability.
Syntax
A MAC is a triple of efficient algorithms with respect to keyspace , message space , and tag space :
- is a randomized algorithm that samples a key
- is a (possibly randomized) algorithm that takes a key and message , outputting a tag
- is a deterministic algorithm that takes a key , message , and tag , outputting a bit indicating whether the tag is valid.
Every MAC on this page is -correct, as defined under Correctness, for a negligible function ; for a nonce-based MAC this means for every nonce and every . Without correctness, meets every unforgeability notion below.
As an object, a MAC denotes a -correct, UF-CMA-secure scheme, and a strongly unforgeable MAC a -correct, SUF-CMA-secure one.
TODO: quantify the message space of the base notion: with polynomial in , a key that is a table of independent uniform tags in , one per message, with the entry for and canonical verification, is a UF-CMA-secure MAC unconditionally.
Properties
Correctness
A MAC is -correct if for all and ,
over the choice of and the randomness of . When , is perfectly correct.
Unforgeability
The following is the unforgeability under chosen message attacks (UF-CMA) game. gets a tagging oracle and wins by outputting a valid tag on a message it never queried.
\begin{algorithm}
\algname{Game}
\caption{$\Game^{\ufcma}_{\MAC,\calA}(\secpar)$}
\begin{algorithmic}
\State $k \gets \KeyGen(1^\secpar)$
\State $\calQ \gets \{\}$
\State $(\hat{m}, \hat{t}) \gets \calA^{\calO}(1^\secpar)$
\If{$\hat{m} \in \calQ$}
\Comment{$\hat{m}$ cannot repeat}
\Return $0$
\EndIf
\Return $[\Vrfy(k, \hat{m}, \hat{t}) = 1]$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\algname{Oracle}
\caption{$\calO(m)$}
\begin{algorithmic}
\State $\calQ \gets \calQ \cup \{m\}$
\State $t \gets \Tag(k, m)$
\Return $t$
\end{algorithmic}
\end{algorithm}
A MAC is UF-CMA secure if for all efficient ,
is negligible.
Strong unforgeability
The strong unforgeability under chosen message attacks (SUF-CMA) game strengthens UF-CMA: records message-tag pairs, and wins with any valid pair that did not return, including a new tag on a queried message.
\begin{algorithm}
\algname{Game}
\caption{$\Game^{\sufcma}_{\MAC,\calA}(\secpar)$}
\begin{algorithmic}
\State $k \gets \KeyGen(1^\secpar)$
\State $\calQ \gets \{\}$
\State $(\hat{m}, \hat{t}) \gets \calA^{\calO}(1^\secpar)$
\If{$(\hat{m}, \hat{t}) \in \calQ$}
\Comment{$(\hat{m}, \hat{t})$ cannot repeat}
\Return $0$
\EndIf
\Return $[\Vrfy(k, \hat{m}, \hat{t}) = 1]$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\algname{Oracle}
\caption{$\calO(m)$}
\begin{algorithmic}
\State $t \gets \Tag(k, m)$
\State $\calQ \gets \calQ \cup \{(m, t)\}$
\Return $t$
\end{algorithmic}
\end{algorithm}
A MAC is SUF-CMA secure if for all efficient ,
is negligible.
Variations
Strongly unforgeable MACs for arbitrary-length messages
A MAC with message space that is -correct for a negligible function , with the bound holding for every , and SUF-CMA-secure; an efficient adversary queries and forges only on messages of polynomial length. It is a strongly unforgeable MAC (Arbitrary-length SUF-CMA MAC ⇒ SUF-CMA MAC) — folklore. Composing it with an encryption scheme whose ciphertexts are bit strings needs no condition linking the two message spaces, which Encrypt-then-MAC requires (CPA-secure SKE + arbitrary-length SUF-CMA MAC ⇒ AE (Encrypt-then-MAC)): a MAC on , a key of two independent uniform tags in with canonical verification, is correct and SUF-CMA-secure unconditionally, yet cannot tag a -bit ciphertext — standard.
Deterministic MACs
A MAC is deterministic if is deterministic. Under canonical verification each message has exactly one valid tag, so a valid pair with queried is an oracle answer, and a deterministic UF-CMA-secure MAC with canonical verification is SUF-CMA-secure — standard.
One-time MACs
A MAC is an -secure one-time MAC if every adversary, of unbounded running time, that makes at most one query to in the UF-CMA game wins with probability at most . A one-time MAC is a MAC that is -secure one-time for a negligible function .
For a strongly universal family of functions , the key and give a -secure one-time MAC, since is uniform given for — WC81. With , a one-time pad and from an -almost XOR-universal family, is -secure one-time: the tag is independent of , and a forgery needs — Kra94. One hash function serves many messages when each gets a fresh pad, the th message being tagged , so the key grows by bits per message rather than by a fresh hash function — WC81.
Nonce-based MACs
A nonce-based MAC has and take a nonce as well, from a nonce space of size superpolynomial in , for example with . In its UF-CMA game, supplies to , never repeats a nonce across queries, and wins with any such that and was not a query to . The restriction lets a construction use a nonce-indexed value, such as in the Wegman–Carter MAC below, as a one-time pad. Since is superpolynomial, the restriction does not bound the number of queries of an efficient adversary; with polynomial, the Wegman–Carter MAC with a uniformly random function , stored as a table, in place of would be secure unconditionally for a negligible .
The Wegman–Carter MAC replaces the pads above by PRF outputs. For a PRF with domain and range , , and an -almost XOR-universal family of functions , the key is with and
Other results
- PRF ⇒ MAC, and PRF ⇒ MAC (CBC-MAC) on messages of a fixed number of blocks.
- PRF ⇒ nonce-based MAC (Wegman–Carter).
- Arbitrary-length SUF-CMA MAC + CPA-secure SKE ⇒ CCA-secure SKE (encrypt-then-MAC).
- NMAC and HMAC. For a compression function , let with and be its iteration keyed by the initial chaining value. Then , for a fixed string of bits, is a UF-CMA-secure MAC if , keyed by its chaining input, is a secure MAC on one-block messages and is weakly collision resistant, that is, collision resistant against an adversary that sees only through an oracle — BCK96. is NMAC with and derived from a single key — BCK96.
- Non-uniform compression-function PRF ⇒ MAC (NMAC): NMAC is a PRF against non-uniform adversaries if , keyed by its chaining input, is a compression-function PRF against non-uniform adversaries, with no collision-resistance assumption; HMAC is a PRF if in addition , keyed through its data input, is a PRF under the two related keys and — Bel06. The same holds for uniform adversaries by a uniform reduction (Compression-function PRF ⇒ MAC (NMAC, uniform proof)) — GPR14.
Participates in
Builds on Message authentication code
- Arbitrary-length SUF-CMA MAC ⇒ SUF-CMA MAC (via Strongly unforgeable MACs for arbitrary-length messages)
- CPA-secure SKE + arbitrary-length SUF-CMA MAC ⇒ AE (Encrypt-then-MAC) (via Strongly unforgeable MACs for arbitrary-length messages)
- Arbitrary-length SUF-CMA MAC + CPA-secure SKE ⇒ CCA-secure SKE (via Strongly unforgeable MACs for arbitrary-length messages)
- SUF-CMA MAC ⇒ MAC (via Strong unforgeability)
Produces Message authentication code