Department of Electrical Engineering, IIT Bombay
August 23, 2024
Encryption schemes achieve secrecy
But an active adversary can modify the ciphertext or inject new ciphertexts
We need mechanisms to ensure that
All the schemes we have seen so far do not provide message integrity
A message authentication code (MAC) consists of three PPT algorithms (\textsf{Gen}, \textsf{Mac}, \textsf{Vrfy}) such that:
\textsf{Gen} takes as input the security parameter 1^n and outputs a key k with |k| \ge n.
The tag-generation algorithm \textsf{Mac} takes as input a key k and a message m \in \{0,1\}^*, and outputs a tag t. We write t \leftarrow \textsf{Mac}_k(m).
The deterministic verification algorithm \textsf{Vrfy} takes as input a key k, a message m, and a tag t. It outputs a bit b with b=1 meaning valid and b=0 meaning invalid. We write this as b \coloneqq \textsf{Vrfy}_k(m,t).
It is required that for every n, every key k output by \textsf{Gen}(1^n), and every m \in \{0,1\}^*, it holds that \textsf{Vrfy}_k(m, \textsf{Mac}_k(m))=1.
For deterministic message authentication codes, the canonical way to perform verification is to simply re-compute the tag and check for equality
\textsf{Vrfy}_k(m,t) computes \tilde{t} \coloneqq \textsf{Mac}_k(m) and then outputs 1 if and only if \tilde{t} = t
A MAC is secure if no efficient adversary can succeed in the above experiment with non-negligible probability
A message authentication code \Pi = (\textsf{Gen}, \textsf{Mac}, \textsf{Vrfy}) is existentially unforgeable under an adaptive chosen-message attack, or just secure, if for all PPT adversaries \mathcal{A}, there is a negligible function such that \Pr\left[ \textsf{Mac-forge}_{\mathcal{A}, \Pi}(n) = 1\right] \le \textsf{negl}(n).
MACs which satisfy previous security definition offer no protection against replay attacks
In current setting, verification is stateless
Protection against replay attacks must be handled by some higher-level application
Theorem: If F is a pseudorandom function, then the above construction is a secure fixed-length MAC for messages of length n.
Proof strategy
D is given 1^n and access to an oracle \mathcal{O}: \{0,1\}^n \rightarrow \{0,1\}^n. It uses \mathcal{A} as a subroutine
Whenever \mathcal{A} queries its MAC oracle on message m\in \{0,1\}^n, answer as follows
When \mathcal{A} outputs (m,t):
Block reordering attacks can be prevented by authenticating the block index
After reducing the size of the blocks, we can compute t_i= \textsf{Mac}'_k( i \| m_i)
But this does not prevent a truncation attack
An attacker can simply drop blocks from the end of the message
Truncation attacks can be prevented by authenticating the message length
After further reducing the size of the blocks, we compute t_i = \textsf{Mac}'_k(l \| i \| m_i) and output \langle t_1,\ldots,t_d\rangle as the tag for m
This is still vulnerable to a mix-and-match attack
The following is a secure MAC if \Pi' is a secure MAC.
Lemma: Fix a positive integer N, and let q \le \sqrt{2N}. IF y_1, y_2, \ldots, y_q are chosen uniformly and independently from a set of size N. Then \frac{q(q-1)}{4N} \le \textsf{coll}(q, N) \le \frac{q(q-1)}{2N}.
See section A.4 of Katz & Lindell for the proof
Let F be a length-preserving pseudorandom function with length n bits
Let m \in \{0,1\}^{dn} be a message for a fixed d > 0.
\textsf{Mac}:
Parse the message m in to d blocks m_1,\dots,m_d of length n bits each.
Set t_0 = 0^n. For i=1,\dots,d, set t_i = F_k(t_{i-1} \oplus m_i).
Output t_d as the tag.
\textsf{Vrfy}: For a message-tag pair (m,t) output 0, if the message is not of length dn.
Otherwise, output 1 if and only if t = \textsf{Mac}_k(m).