X-Git-Url: https://git.distorted.org.uk/~mdw/doc/ips/blobdiff_plain/e09a183984ad92729c40b1ed51d2e9f6388ca9ba..754df4fbcb15f30cfa7bb5a0a1e72384568ef743:/auth-mac.tex diff --git a/auth-mac.tex b/auth-mac.tex index cd3defa..7fc2724 100644 --- a/auth-mac.tex +++ b/auth-mac.tex @@ -105,11 +105,13 @@ \resetseq \head{PRFs are MACs, \seq} - If $F_K\colon \{0, 1\}^* \to \{0, 1\}^L$ is a $(t, q, \epsilon)$-secure - PRF, then it's also a $(t', q_T, q_V, \epsilon')$-secure MAC, with $q = q_T - + q_V + 1$, $t = t' + O(q)$, and $\epsilon' \le \epsilon + (q_V + 1) - 2^{-L}$. The constant hidden by the $O(\cdot)$ is small and depends on the - model of computation. + If $F_K\colon \{0, 1\}^* \to \{0, 1\}^L$ is a PRF then it's also a MAC. + Quantitatively: + \[ \InSec{suf-cma}(F; t, q_T, q_V) \le + \InSec{prf}(F; t + O(q), q_T + q_V) + + \frac(q_V + 1}{2^L}. \] + The constant hidden by the $O(\cdot)$ is small and depends on the model of + computation. Suppose $A$ can break $F$ used as a MAC in time $t$ and with $q_T$ and $q_V$ queries to its tagging and verification oracles respectively. @@ -384,8 +386,8 @@ for any adversary $A$ constrained to run in time $t$ and permitted $q$ oracle queries, \[ \Pr[K \getsr \{0, 1\}^k; - (x, y) \gets A^{F_K(\cdot)}] \le \epsilon : - x \ne y \land F_K(x) = F_K(y) \]% + (x, y) \gets A^{F_K(\cdot)} : + x \ne y \land F_K(x) = F_K(y)] \le \epsilon \]% If $H_K$ is a $(t, q_T, q_V, \epsilon)$-secure MAC on $k$-bit messages, and moreover $(t, q_T + q_V, \epsilon')$-weakly collision resistant, then @@ -397,8 +399,8 @@ Let $A$ be an adversary which forges a $\Xid{T}{NMAC}^H$ tag in time $t$, using $q_T$ tagging queries and $q_V$ verification queries with probability - $\epsilon$. We construct an adversary $A'$ which forces a $H$ tag for a - $k$-bit in essentially the same time. + $\epsilon$. We construct an adversary $A'$ which forges an $H$-tag for a + $k$-bit message in essentially the same time. \begin{program} Adversary $A'^{T(\cdot), V(\cdot, \cdot)}$ \+ \\ $K \getsr \{0, 1\}^k$; \\ @@ -485,47 +487,47 @@ function $F$. For the sake of simplicity, we allow the adversary $A$ to query on \emph{padded} messages, rather than the raw unpadded messages. We count the number $q'$ of individual message blocks. - - As the game with $A$ progresses, we can construct a directed - \emph{graph} of the query results so far. We start with a node - labelled $I$. When processing an $H$-query, each time we compute $t' - = F(t \cat x_i)$, we add a node $t'$, and an edge $x_i$ from $t$ to - $t'$. The `bad' event occurs whenever we add an edge to a previously - existing node. We must show, firstly, that the - adversary cannot distinguish $H$ from a random function unless the bad - event occurs; and, secondly, that the bad event doesn't occur very - often. + + As the game with $A$ progresses, we can construct a directed \emph{graph} + of the query results so far. We start with a node labelled $I$. When + processing an $H$-query, each time we compute $t' = F(t \cat x_i)$, we add + a node $t'$, and an edge $x_i$ from $t$ to $t'$. The `bad' event occurs + whenever we add an edge to a previously existing node. We must show, + firstly, that the adversary cannot distinguish $H$ from a random function + unless the bad event occurs; and, secondly, that the bad event doesn't + occur very often. The latter is easier: our standard collision bound shows that the bad - event occurs during the game with probability at most $q'(q' - 1)/2$. - + event occurs during the game with probability at most $q'(q' - 1)/2^{t+1}$. + The former is trickier. This needs a lot more work to make it really rigorous, but we show the idea. Assume that the bad event has not - occurred. Consider a query $x_0, x_1, \ldots, x_{n-1}$. If it's the - same as an earlier query, then $A$ learns nothing (because it could - have remembered the answer from last time). If it's \emph{not} a - prefix of some previous query, then we must add a new edge to our - graph; then either the bad event occurs or we create a new node for - the result, and because $F$ is a random function, the answer is - uniformly random. Finally, we consider the case where the query is a - prefix of some earlier query, or queries. But these were computed at - random at the time. + occurred. Consider a query $x_0, x_1, \ldots, x_{n-1}$. If it's the same + as an earlier query, then $A$ learns nothing (because it could have + remembered the answer from last time). If it's a \emph{prefix} of some + earlier query, then the answer is the value of some internal node which + hasn't been revealed before; however, the value of that internal node was + chosen uniformly at random (we claim). Finally, if the query is not a + prefix of any previous query, then we add a new edge to our graph. If the + bad event doesn't occur, we must add a new node for the result, and the + value at that node will be uniformly random, because $F$ is a random + function being evaluated at a new point -- this is the only time we add new + nodes to the graph, justifying the claim made earlier. At the end of all of this, we see that \[ \InSec{prf}(T^0; t, q) \le - \InSec{prf}(F; t, q') + \frac{q'(q' - 1)}{2} \]% + \InSec{prf}(F; t, q') + \frac{q'(q' - 1)}{2^{t+1}} \]% and hence \[ \InSec{suf-cma}(\mathcal{M}^0; t, q) \le - \InSec{prf}(F; t, q') + \frac{q'(q' - 1)}{2} + \frac{1}{2^t}. \]% + \InSec{prf}(F; t, q') + \frac{2 q'(q' - 1) + 1}{2^{t+1}}. \]% Now we turn our attention to $T^1$. It's clear that we can't simulate $T^1$ very easily using an oracle for $F$, since we don't know $K$ (and indeed there might not be a key $K$). The intuitive reason why - $T^1$ is insecure is that $F$ might have leak useful information if - its input matches its key. This doesn't affect the strength of $F$ as - a PRF because you have to know the key before you can exploit this - leakage; but $T^1$ already knows the key, and this can be exploited to - break the MAC. + $T^1$ is insecure is that $F$ might leak useful information if its input + matches its key. This doesn't affect the strength of $F$ as a PRF + because you have to know the key before you can exploit this leakage; but + $T^1$ already knows the key, and this can be exploited to break the MAC. To show that this is insecure formally, let $F'$ be defined as follows: @@ -591,6 +593,9 @@ If $\InSec{uh}(H) \le \epsilon$ then we say that $H$ is \emph{$\epsilon$-almost universal}. Note that the concept of almost-universality is not quantified by running times. + + Such families definitely exist: we don't need to make intractability + assumptions. We'll see some examples later. If $H$ is $1/|{\ran H}|$-almost universal, then we say that $H$ is \emph{universal}. Sometimes it's said that this is the best possible @@ -673,107 +678,55 @@ \end{slide} \begin{slide} - \topic{the collision game} - \head{Universal hashing, \seq: the collision game} - - Suppose that, instead of merely a pair $(x, y)$, our adversary was allowed - to return a \emph{set} $Y$ of $q$ elements, and measure the probability - that $H_K(x) = H_K(y)$ for some $x \ne y$ with $x, y \in Y$, and for $K - \inr \keys H$. - - Let $\InSec{uh-set}(H; q)$ be maximum probability achievable for sets $Y$ - with $|Y| \le q$. Then - \[ \InSec{uh-set}(H; q) \le \frac{q(q - 1)}{2} \cdot \InSec{uh}(H) .\] + \topic{domain and range extension of a PRF} + \head{Universal hashing, \seq: PRF domain extension} + + Suppose that $F\colon \keys F \times \{0, 1\}^L \to \{0, 1\}^l$ is a PRF. + We'd like to have a PRF for a bigger domain $\{0, 1\}^n$. + + If $H\colon \{0, 1\}^k \times \{0, 1\}^n \to \{0, 1\}^L$ is an + almost-universal hash function. Then we can define $F'$ by + \[ F'_{K, h}(x) = F_K(H_h(x)). \] + Now we can prove that + \[ \InSec{prf}(F'; t, q) \le + \InSec{prf}(F; t, q) + + \frac{q(q - 1)}{2} \InSec{ah}(H). \] + Immediately this tells us that $F'$ is a MAC for $n$-bit messages. \end{slide} \begin{proof} - This is rather tedious. We use the dynamic view. Suppose $A$ returns $(x, - Y)$ with $|Y| = q$, and succeeds with probability $\epsilon$. Consider + Suppose $A$ attacks $F'$. Consider the distinguisher $B$ which attacks + $F$: \begin{program} - Adversary $A'$: \+ \\ - $(x, Y) \gets A$; \\ - $y \getsr Y$; \\ - \RETURN $(x, Y \setminus \{y\})$; + Distinguisher $B^{F(\cdot)}$: \+ \\ + $h \getsr \{0, 1\}^k$; \\ + \RETURN $A^{F(H_h(\cdot))}()$; \end{program} - The worst that can happen is that $A'$ accidentally removes the one - colliding element from $Y$. This occurs with probability $2/q$. So - \[ \Succ{uh-set}{H}(A') \ge \frac{q - 2}{q} \Succ{uh-set}{H}(A). \] - Rearranging and maximizing gives - \[ \InSec{uh-set}(H; q) \le - \frac{q}{q - 2} \cdot \InSec{uh-set}(H; q - 1). \] - Note that $\InSec{uh-set}(H; 2) = \InSec{uh}(H)$ is our initial notion. A - simple inductive argument completes the proof. + Suppose $F$ is an oracle for $F_K(\cdot)$. Then $A$ plays its standard + attack game and all is well. Conversely, suppose $F$ is a random + function. Then the only way $A$ can distinguish its oracle $F(H_h(\cdot))$ + from a random function is if it issues two queries $x_i \ne x_j$ such that + $H_h(x_i) = H_h(x_j)$. But for each pair $(i, j)$ this happens with + probability at most $\InSec{ah}(H)$. The stated bound follows. \end{proof} -\begin{slide} - \topic{a MAC} - \head{Universal hashing, \seq: a MAC} - - Suppose that $H\colon \{0, 1\}^k \times \{0, 1\}^* \to \{0, 1\}^l$ is an - almost universal hash function, and $F\colon \{0, 1\}^{k'} \times \{0, - 1\}^l \to \{0, 1\}^L$ is a PRF\@. Define a MAC $\Xid{\mathcal{M}}{UH}^{H, - F} = (\Xid{T}{UH}^{H, F}, \Xid{V}{UH}^{H, F})$ where: - \begin{eqnarray*}[rl] - \Xid{T}{UH}^{H, F}_{K, K'}(m) &= F_{K'}(H_K(m)) \\ - \Xid{V}{UH}^{H, F}_{K, K'}(m, \tau) &= \begin{cases} - 1 & if $\tau = F_{K'}(H_K(m))$ \\ - 0 & otherwise - \end{cases}. - \end{eqnarray*} - We have - \begin{eqnarray*}[Ll] - \InSec{suf-cma}(\Xid{\mathcal{M}}{UH}^{H, F}; t, q_T, q_V) \\ - & \le - (q_V + 1) \biggl(\InSec{prf}(F; t, q_T + 1) + \frac{1}{2^L} + - \frac{q_T(q_T - 1)}{2} \cdot \InSec{uh}(H)\biggr). - \end{eqnarray*} -\end{slide} - -\begin{proof} - We shall prove the result for $q_V = 0$ and $q_T = q$, and appeal to the - earlier result on verification oracles. - - Suppose $A$ attacks the scheme $\Xid{\mathcal{M}}{UH}^{H, F}$ in time $t$, - issuing $q$ tagging queries. Consider a distinguisher $D$, constructed - from a forger $A$: - \begin{program} - Distinguisher $D^{F(\cdot)}$: \+ \\ - $K \getsr \{0, 1\}^k$; \\ - $\Xid{T}{list} \gets \emptyset$; \\ - $(m, \tau) \gets A^{\id{tag}(K, \cdot)}$; \\ - \IF $m \notin \Xid{T}{list} \land \tau = F(H_K(m))$ - \THEN \RETURN $1$; \\ - \ELSE \RETURN $0$; \- \\[\smallskipamount] - Oracle $\id{tag}(K, m)$: \+ \\ - $\Xid{T}{list} \gets \Xid{T}{list} \cup \{m\}$; \\ - \RETURN $F(H_K(m))$; \- \\[\smallskipamount] - \end{program} - Note that $A$ isn't provided with a verification oracle: that's because we - didn't allow it any verification queries. - - We can see immediately that - \[ \Pr[K \getsr \{0, 1\}^{k'} : D^{F_K(\cdot)} = 1] = - \Succ{suf-cma}{\Xid{\mathcal{M}}{UH}^{H, F}}(A). \]% - - We must now find an upper bound for $\Pr[F \getsr \Func{l}{L} : - D^{F(\cdot)}]$. Suppose that the adversary returns the pair $(m^*, - \tau^*)$, and that its tagging oracle queries and their answers are $(m_i, - \tau_i)$ for $0 \le i < q$. Consider the event $C$ that $H_K(m) = - H_K(m')$ for some $m \ne m'$, with $m, m' \in \{m^*\} \cup \{\,m_i \mid 0 - \le i < q\,\}$. - - If $C$ doesn't occur, then $F$ has not been queried before at $H_K(m)$, but - there's a $2^{-L}$ probability that the adversary guesses right anyway. If - $C$ does occur, then we just assume that the adversary wins, even though it - might not have guessed the right tag. - - By our result on the collision game, $\Pr[C] \le q \cdot \InSec{uh}(H)$. - Then - \[ \Succ{prf}{F}(D) \ge - \Succ{suf-cma}{\Xid{\mathcal{M}}{UH}^{H, F}}(A) - - \frac{1}{2^L} - \frac{q(q - 1)}{2} \cdot \InSec{uh}(H). \]% - The result follows. -\end{proof} +\begin{exercise} + Show how to extend the \emph{range} of a PRF. Specifically, suppose you're + given a PRF $F\colon \keys{F} \times \{0, 1\}^L \to \{0, 1\}^t$, but want + an $l$-bit output. Show how to achieve this. +\answer + There are two obvious techniques. + \begin{enumerate} + \item Suppose we have a PRG $G\colon \{0, 1\}^t \to \{0, 1\}^l$. Then we + can easily use $G \compose F$; it's easy to see how this is secure. + Indeed, we can use $F$ itself as a PRG, by defining $G(x) = F_x(0) \cat + F_x(1) \cat \cdots$. + \item Let $m = \lceil \log_2 (l/t) \rceil$. Use the construction from the + slide to build a PRF $F'$ with domain $\{0, 1\}^{L+m}$. Then we define + $F''_K(x) = F'_K(x \cat 0) \cat F'_K(x \cat 1) \cat \cdots \cat F'_K(x + \cat m - 1)$. + \end{enumerate} +\end{exercise} \begin{slide} \topic{almost XOR-universality} @@ -833,6 +786,60 @@ \end{slide} \begin{slide} + \head{Almost XOR-universality, \seq: examples of AXU hash functions} + + Let $\F = \gf{2^l}$ be a finite field. Given a message $m = (m_0, \ldots, + m_{n-1} \in \F^n$, we can hash it in several ways. + \begin{itemize} + \item Inner-product: choose $k = (k_0, \ldots, k_{n-1}) \in \F^n$. + \[ \Xid{H}{ip}_{k}(m) = m \cdot k = \sum_{0\le i