Miscellaneous rewordings and fixings.
[doc/ips] / enc-symm.tex
1 \xcalways\section{Symmetric encryption}\x
2
3 \xcalways\subsection{Syntax}\x
4
5 \begin{slide}
6 \head{Symmetric encryption syntax}
7
8 A \emph{symmetric encryption scheme} $\mathcal{E} = (E, D)$ is a set of
9 keys $\keys\mathcal{E}$ (usually $\{0, 1\}^k$ for some integer $k$) and
10 pair of algorithms:
11 \begin{itemize}
12 \item an \emph{encryption} algorithm $E\colon \keys\mathcal{E} \times \{0,
13 1\}^* \to \{0, 1\}^*$; and
14 \item a \emph{decryption} algorithm $D\colon \keys\mathcal{E} \times \{0,
15 1\}^* \to \{0, 1\}^*$.
16 \end{itemize}
17 We also have a \emph{correctness} requirement: for any $K \in
18 \keys\mathcal{E}$, and any plaintext $x$, if $E(K, x)$ returns $y$ then
19 $D(K, y)$ returns $x$.
20
21 We write $E_K(\cdot)$ rather than $E(K, \cdot)$, and $D_K(\cdot)$ rather
22 than $D(K, \cdot)$.
23 \end{slide}
24
25 \xcalways\subsection{Security notions}\x
26
27 \begin{slide}
28 \head{Symmetric encryption security notions}
29
30 In symmetric scheme, an adversary who doesn't know the key can't encrypt
31 data for itself. To modify our security notions by providing the adversary
32 with an encryption oracle.
33
34 We consider semantic security, indistinguishability and non-malleability,
35 against chosen-plaintext and chosen-ciphertext attacks. To make life more
36 complicated, we have three different indistinguishability notions.
37
38 We use the same notation to describe the decryption oracles provided in
39 various types of attacks:
40 \begin{tabular}[C]{l Mc Mc }
41 \hlx*{hv}
42 Attack & D_0(c) & D_1(c) \\ \hlx{vhv}
43 CPA & \bot & \bot \\
44 CCA1 & D_K(c) & \bot \\
45 CCA2 & D_K(c) & D_K(c) \\ \hlx*{vh}
46 \end{tabular}
47 \end{slide}
48
49 \begin{slide}
50 \topic{semantic security}
51 \head{Semantic security}
52
53 The semantic security game is as for the asymmetric case, except for the
54 presence of encryption oracles.
55
56 \begin{program}
57 Experiment $\Expt{sem-\id{atk}-$b$}{\mathcal{E}}(A)$: \+ \\
58 $K \getsr \keys\mathcal{E}$; \\
59 $(\mathcal{M}, s) \gets A^{E_K(\cdot), D_0(\cdot)}
60 (\cookie{select})$; \\
61 $x_0 \getsr \mathcal{M}$; $x_1 \getsr \mathcal{M}$; \\
62 $y \gets E_K(x_1)$; \\
63 $(f, \alpha) \gets A^{E_K(\cdot), D_1(\cdot)}
64 (\cookie{predict}, y, s)$; \\
65 \IF $f(x_b) = \alpha$ \THEN \RETURN $1$; \\
66 \ELSE \RETURN $0$;
67 \end{program}
68 The distribution $\mathcal{M}$ must be \emph{valid}: all strings in
69 $\supp\mathcal{M}$ must have the same length.
70 \end{slide}
71
72 \begin{slide}
73 \topic{find-then-guess}
74 \head{Find-then-guess indistinguishability}
75
76 The `find-then-guess' (FTG) game corresponds to the standard public-key
77 indistinguishability notion.
78 \begin{program}
79 Experiment $\Expt{ftg-\id{atk}-$b$}{\mathcal{E}}(A)$: \+ \\
80 $K \getsr \keys\mathcal{E}$; \\
81 $(x_0, x_1, s) \gets A^{E_K(\cdot), D_0(\cdot)}(\cookie{find})$; \\
82 \IF $|x_0| \ne |x_1|$ \THEN \RETURN $0$; \\
83 $y \gets E_K(x_b)$; \\
84 $b' \gets A^{E_K(\cdot), D_1(\cdot)}(\cookie{guess}, y, s)$; \\
85 \RETURN $b'$;
86 \end{program}
87 \end{slide}
88
89 \begin{slide}
90 \topic{left-or-right}
91 \head{Left-or-right indistinguishability}
92
93 The `left-or-right' (LOR) notion is a natural extension of find-then-guess.
94 Rather than having to guess the hidden bit using a single challenge
95 ciphertext, the adversary is allowed to request more as it likes. It is
96 given an encryption oracle which accepts two arguments: it selects either
97 the left or the right plaintext, according to the hidden bit, and returns
98 the ciphertext.
99 \begin{program}
100 Experiment $\Expt{lor-\id{atk}-$b$}{\mathcal{E}}(A)$; \+ \\
101 $K \getsr \keys\mathcal{E}$; \\
102 $b' \gets A^{E_K(\id{lr}_b(\cdot, \cdot)), D_1(\cdot)}$; \\
103 \RETURN $b'$; \- \\[\smallskipamount]
104 Function $\id{lr}_b(x_0, x_1)$: \+ \\
105 \RETURN $x_b$;
106 \end{program}
107 Note that, because the adversary only runs in one stage, we can only
108 consider chosen-plaintext and adaptive chosen-ciphertext attacks.
109 \end{slide}
110
111 \begin{slide}
112 \topic{real-or-random}
113 \head{Real-or-random indistinguishability}
114
115 The `real-or-random' (ROR) notion is somewhat less natural, but turns out
116 to be useful for analysing block cipher encryption modes.
117
118 The adversary is given an oracle which, when given a plaintext $x$, either
119 returns an encryption of $x$ or an encryption of a random string with the
120 same length as $x$.
121 \begin{program}
122 Experiment $\Expt{ror-\id{atk}-$0$}{\mathcal{E}}(A)$; \+ \\
123 $K \getsr \keys\mathcal{E}$; \\
124 $b' \gets A^{E_K(\id{rand}(\cdot)), D_1(\cdot)}$; \\
125 \RETURN $b'$; \- \\[\smallskipamount]
126 Function $\id{rand}(x)$: \+ \\
127 $x' \getsr \{0, 1\}^{|x|}$; \\
128 \RETURN $x'$;
129 \next
130 Experiment $\Expt{ror-\id{atk}-$1$}{\mathcal{E}}(A)$; \+ \\
131 $K \getsr \keys\mathcal{E}$; \\
132 $b' \gets A^{E_K(\cdot), D_1(\cdot)}$; \\
133 \RETURN $b'$;
134 \end{program}
135 Again, only chosen-plaintext and adaptive chosen-ciphertext attacks are
136 applicable.
137 \end{slide}
138
139 \begin{slide}
140 \topic{relations between notions}
141 \head{Relations between notions \cite{Bellare:2000:CST}}
142
143 \[ \xymatrix @=2cm {
144 \txt{LOR} \ar@<0.5ex>[r]^1 \ar@<-0.5ex>[d]_3 &
145 \txt{ROR} \ar@<0.5ex>[l]^2 \\
146 \txt{FTG} \ar@{-->}@<-0.5ex>[u]_4 \ar@<0.5ex>[r] &
147 \txt{SEM} \ar@<0.5ex>[l]
148 } \]
149 \begin{list}{}{
150 \settowidth{\labelwidth}{\textbf{Key}}
151 \leftmargin\labelwidth\advance\leftmargin\labelsep
152 \itemindent0pt\let\makelabel\textbf}
153 \item[Key] \begin{itemize}
154 \item A solid arrow $\xy\ar*+{A};<1.5cm, 0cm>*+{B}\endxy$ indicates an
155 \emph{security-preserving} reduction: if a scheme is secure in notion
156 $A$ then it is as secure in notion $B$, to within a small constant
157 factor.
158 \item A broken arrow $\xy\ar@{-->}*+{A};<1.5cm, 0cm>*+{B}\endxy$
159 indicates a non-security-preserving reduction.
160 \item The numbers refer to sections of the proof provided in the notes.
161 \end{itemize}
162 \end{list}
163 \end{slide}
164
165 \begin{proof}
166 We deal with the propositions one at a time. Most of them are pretty easy,
167 with the exception of the security-losing reduction from FTG to LOR.
168 \begin{enumerate}
169
170 \item We show that $\text{LOR-\id{atk}} \implies \text{ROR-\id{atk}}$.
171 Suppose $A'$ attacks $\mathcal{E}$ in the real-or-random sense.
172 \begin{program}
173 Adversary $A^{E(\cdot, \cdot), D(\cdot)}$: \+ \\
174 \RETURN $A'^{\id{ror-hack}(\cdot), D(\cdot)}$; \-\\[\smallskipamount]
175 Oracle $\id{ror-hack}(x)$: \+ \\
176 $x' \getsr \{0, 1\}^{|x|}$; \\
177 \RETURN $E(x', x)$;
178 \end{program}
179 Since this provides a perfect simulation of the ROR game,
180 \[ \Adv{lor-\id{atk}}{\mathcal{E}}(A) =
181 \Adv{ror-\id{atk}}{\mathcal{E}}(A'), \]%
182 and hence
183 \[ \InSec{ror-\id{atk}}(\mathcal{E}; t, q_E, q_D) \le
184 \InSec{lor-\id{atk}}(\mathcal{E}; t, q_E, q_D). \]%
185
186 \item We show that $\text{ROR-\id{atk}} \implies \text{LOR-\id{atk}}$.
187 Suppose $A'$ attacks $\mathcal{E}$ in the left-or-right sense.
188 \begin{program}
189 Adversary $A^{E(\cdot), D(\cdot)}$: \+ \\
190 $\hat{b} \gets \{0, 1\}$; \\
191 $b' \gets A'^{\id{lor-hack}(\cdot, \cdot), D(\cdot)}$; \\
192 \IF $b' = \hat{b}$ \THEN \RETURN $1$; \\
193 \ELSE \RETURN $0$; \- \\[\smallskipamount]
194 Oracle $\id{lor-hack}(x_0, x_1)$: \+ \\
195 \RETURN $E(x_{\hat{b}})$;
196 \end{program}
197 If the ROR oracle is returning correct encryptions, then $A'$ will return
198 the correct bit $\hat{b}$ with probability
199 \[ \frac{\Adv{lor-\id{atk}}{\mathcal{E}}(A')}{2} + \frac{1}{2}; \]
200 if the ROR oracle is returning ciphertexts for random plaintexts, then
201 $A'$ is being given no information about $\hat{b}$, and hence guesses
202 correctly with probability exactly $\frac{1}{2}$. We conclude that
203 \[ \Adv{ror-\id{atk}}{\mathcal{E}}(A) =
204 \frac{1}{2}\Adv{lor-\id{atk}}{\mathcal{E}}(A'), \]%
205 and hence
206 \[ \InSec{lor-\id{atk}}(\mathcal{E}; t, q_E, q_D) \le
207 2 \cdot \InSec{ror-\id{atk}}(\mathcal{E}; t, q_E, q_D). \]%
208
209 \item We show that $\text{LOR-\id{atk}} \implies \text{FTG-\id{atk}}$.
210 Suppose $A'$ attacks $\mathcal{E}$ in the find-then-guess sense. We
211 assume, without loss of generality, that $A'$ never queries its
212 decryption oracle on ciphertexts it obtained from its encryption oracle.
213 \begin{program}
214 Adversary $A^{E(\cdot, \cdot), D(\cdot)}$: \+ \\
215 $(x_0, x_1, s) \gets A'^{\id{encrypt}(\cdot), D(\cdot)}
216 (\cookie{find})$; \\
217 $y \gets E(x_0, x_1)$; \\
218 $b' \gets A'^{\id{encrypt}(\cdot), D(\cdot)}
219 (\cookie{guess}, y, s);$ \\
220 \RETURN $b'$; \- \\[\smallskipamount]
221 Oracle $\id{encrypt}(x)$: \+ \\
222 \RETURN $E(x, x)$;
223 \end{program}
224 Since this provides a perfect simulation of the FTG game,
225 \[ \Adv{lor-\id{atk}}{\mathcal{E}}(A) =
226 \Adv{ftg-\id{atk}}{\mathcal{E}}(A'), \]%
227 and hence
228 \[ \InSec{ftg-\id{atk}}(\mathcal{E}; t, q_E, q_D) \le
229 \InSec{lor-\id{atk}}(\mathcal{E}; t, q_E + 1, q_D). \]%
230
231 \item We show that $\text{FTG-\id{atk}} \implies \text{LOR-\id{atk}}$,
232 though with a factor of $q_E$ loss of security.
233
234 This proof is slightly more tricky than the others. Consider the
235 following `hybrid' games, defined for $0 \le i \le q_E$:
236 \begin{program}
237 Experiment $\Expt{hyb-$i$-\id{atk}-$b$}{\mathcal{E}}$: \+ \\
238 $K \getsr \keys\mathcal{E}$; \\
239 $j \gets 0$; \\
240 $b' \gets A^{E(\id{lr-hack}_b(\cdot, \cdot)), D_1(\cdot)}$; \\
241 \RETURN $b'$; \- \\[\smallskipamount]
242 \next
243 Function $\id{lr-hack}_b(x_0, x_1)$: \+ \\
244 \IF $j < i$ \THEN $x \gets x_0$; \\
245 \ELSE \IF $j > i$ \THEN $x \gets x_1$; \\
246 \ELSE $x \gets x_b$; \\
247 $j \gets j + 1$; \\
248 \RETURN $E_K(x_b)$;
249 \end{program}
250 As usual, we define
251 \[ \Adv{hyb-$i$-\id{atk}}{\mathcal{E}}(A) =
252 \Pr[\Expt{hyb-$i$-\id{atk}-$1$}{\mathcal{E}} = 1] -
253 \Pr[\Expt{hyb-$i$-\id{atk}-$0$}{\mathcal{E}} = 1]. \]%
254
255 Observe that we have the identities
256 \begin{eqnarray*}[rl]
257 \Expt{lor-\id{atk}-$0$}{\mathcal{E}} &\equiv
258 \Expt{hyb-$(q_E{-}1)$-\id{atk}-$0$}{\mathcal{E}}
259 \\
260 \Expt{lor-\id{atk}-$1$}{\mathcal{E}} &\equiv
261 \Expt{hyb-$0$-\id{atk}-$1$}{\mathcal{E}}
262 \\
263 \tabpause{and, for $0 \le i < q_E$,}
264 \Expt{hyb-$i$-\id{atk}-$0$}{\mathcal{E}} &\equiv
265 \Expt{hyb-$(i{+}1)$-\id{atk}-$1$}{\mathcal{E}}.
266 \end{eqnarray*}
267 Thus,
268 \begin{eqnarray*}[rclclc]
269 \Adv{lor-\id{atk}}{\mathcal{E}}(A)
270 &=& \Pr[\Expt{lor-\id{atk}-$1$}{\mathcal{E}}(A) = 1] &-&
271 \Pr[\Expt{lor-\id{atk}-$0$}{\mathcal{E}}(A) = 1]
272 \\*
273 &=& \Pr[\Expt{hyb-$0$-\id{atk}-$1$}{\mathcal{E}}(A) = 1] &-&
274 \Pr[\Expt{hyb-$(q_E{-}1)$-\id{atk}-$0$}{\mathcal{E}}(A) = 1]
275 \\
276 &=& \Pr[\Expt{hyb-$0$-\id{atk}-$1$}{\mathcal{E}}(A) = 1] &-&
277 \Pr[\Expt{hyb-$0$-\id{atk}-$0$}{\mathcal{E}}(A) = 1] &+ \\*
278 & & \Pr[\Expt{hyb-$1$-\id{atk}-$1$}{\mathcal{E}}(A) = 1] &-&
279 \Pr[\Expt{hyb-$1$-\id{atk}-$0$}{\mathcal{E}}(A) = 1] &+ \\*
280 & & \multicolumn{1}{c}{\smash\vdots} &-&
281 \multicolumn{1}{c}{\smash\vdots} &+ \\*
282 & & \Pr[\Expt{hyb-$(q_E{-}1)$-\id{atk}-$1$}{\mathcal{E}}(A) = 1] &-&
283 \Pr[\Expt{hyb-$(q_E{-}1)$-\id{atk}-$0$}{\mathcal{E}}(A) = 1]
284 \\*
285 &=& \sum_{0\le i<q_E} \Adv{hyb-$i$-\id{atk}}{\mathcal{E}}(A)
286 \end{eqnarray*}
287 Now, there must be at least one $i$ for which
288 \[ \Adv{hyb-$i$-\id{atk}}{\mathcal{E}}(A) \ge
289 \frac{1}{q_E} \Adv{lor-\id{atk}}{\mathcal{E}}(A). \]%
290
291 Suppose that $A'$ is an adversary attacking $\mathcal{E}$ in the LOR
292 sense. We can construct an FTG adversary $A$ for which
293 \[ \Adv{ftg-\id{atk}}{\mathcal{E}}(A) \ge
294 \frac{1}{q_E} \Adv{lor-\id{atk}}{\mathcal{E}}(A') \]%
295 as follows:\footnote{%
296 The expression of the FTG adversary requires control flow operations
297 which aren't easily expressed in the pseudocode language we've used so
298 far, hence the cop-out into English.}
299 \begin{enumerate}
300 \item When invoked in the $\cookie{find}$ stage, run the LOR adversary,
301 passing it $A$'s decryption oracle.
302 \item Respond to its first $i$ left-or-right queries $(x_0, x_1)$ with
303 $E(x_0)$.
304 \item On the $(i + 1)$-th left-or-right query, $(x_0, x_1)$, package up
305 all of $A'$'s state, and return that, together with the pair $(x_0,
306 x_1)$ as the result of $A$'s $\cookie{find}$ stage.
307 \item When reinvoked in the $\cookie{guess}$ stage, return the challenge
308 ciphertext $y$ as the result of $A'$'s $(i + 1)$-th query.
309 \item Respond to the remaining $q_E - i - 1$ left-or-right queries
310 $(x_0, x_1)$ with $E(x_1)$.
311 \item Return the bit output by $A'$.
312 \end{enumerate}
313 This evidently simulates the environment of
314 $\Expt{hyb-$i$-\id{atk}-$b$}{\mathcal{E}}(A')$; hence $A$ achieves the
315 claimed advantage. Thus,
316 \[ \InSec{lor-\id{atk}}(\mathcal{E}; t, q_E, q_D) \le
317 q_E \cdot \InSec{ftg-\id{atk}}(\mathcal{E}; t, q_E - 1, q_D). \]%
318
319 Now we show that we can't obtain a better reduction. Suppose that
320 $\mathcal{E} = (E, D)$ is $(t, q_E, q_D, \epsilon)$-secure in the FTG
321 sense. We construct a \emph{$p$-leaky} version, $\mathcal{E}' = (E',
322 D')$. Let $\id{maybe}(p)$ denote a function which returns $1$ with
323 probability $p$.
324 \begin{program}
325 Algorithm $E'_K(x)$: \+ \\
326 \IF $\id{maybe}(p) = 1$ \THEN \RETURN $1 \cat x$; \\
327 \RETURN $0 \cat E_K(x)$;
328 \next
329 Algorithm $D'_K(y')$: \+ \\
330 \PARSE $y'$ \AS $1\colon b, y$; \\
331 \IF $b = 1$ \THEN \RETURN $y$; \\
332 \RETURN $D_K(y)$;
333 \end{program}
334 A simple simulation argument shows that this scheme is still secure,
335 except for an additional term $p$, handling the case where the challenge
336 ciphertext $y^* = 1 \cat x^*$. It is easy to see that
337 \[ \InSec{lor-\id{atk}}(\mathcal{E}'; t, q_E, 0) \ge q_E p, \]
338 concluding the proof.
339 \end{enumerate}
340
341 The proofs that $\text{FTG-\id{atk}} \implies \text{SEM-\id{atk}}$ and
342 $\text{SEM-\id{atk}} \implies \text{FTG-\id{atk}}$ are just as in the
343 public-key case (page~\pageref{pf:pub-ind-eq-sem}), except for the presence
344 of encryption oracles (which are passed on unmolested). And that's all we
345 need.
346 \end{proof}
347
348 \begin{exercise}
349 Consider the following `ciphertext-or-random-string' security notion.
350 \begin{program}
351 Experiment $\Expt{cor-\id{atk}-$0$}{\mathcal{E}}(A)$: \+ \\
352 $b' \gets A^{\id{rand}(E_K(\cdot)), D_1(\cdot)}$; \\
353 \RETURN $b'$; \- \\[\smallskipamount]
354 Function $\id{rand}(x)$: \+ \\
355 $x' \getsr \{0, 1\}^{|x|}$; \\
356 \RETURN $x'$;
357 \next
358 Experiment $\Expt{cor-\id{atk}-$1$}{\mathcal{E}}(A)$; \+ \\
359 $K \getsr \keys\mathcal{E}$; \\
360 $b' \gets A^{E_K(\cdot), D_1(\cdot)}$; \\
361 \RETURN $b'$;
362 \end{program}
363 Relate this notion to the others we've already seen.
364 \answer%
365 It's not hard to see that $\text{COR} \implies \text{LOR}$; the proof is
366 similar to $\text{ROR} \implies \text{LOR}$, and we have
367 $\InSec{cor-\id{atk}}(\mathcal{E}; t, q_E, q_D) \le 2\cdot
368 \InSec{lor-\id{atk}}(\mathcal{E}; t, q_E, q_D)$. On the other hand,
369 $\text{LOR} \not\implies \text{COR}$. To see this, let $\mathcal{E} = (E,
370 D)$ be an encryption scheme secure in the LOR-\id{atk} sense, and define
371 $\mathcal{E}' = (E', D')$ by $E'_K(x) = 0^n \cat E_K(x)$ and $D'_K(y') =
372 D_K(y)$ if $y' = 0^n \cat y$ for some $y$, or $\bot$ otherwise. Because
373 the fixed padding is independent of the plaintext,
374 $\InSec{lor-\id{atk}}(\mathcal{E}'; t, q_E, q_D) \le
375 \InSec{lor-\id{atk}}(\mathcal{E}; t, q_E, q_D)$. But $\mathcal{E}'$ is not
376 COR-CPA secure because an adversary can check for the fixed padding; hence
377 $\InSec{cor-cpa}(\mathcal{E}'; t, q_E, q_D) \ge 1 - q_E 2^{-n}$.
378 \end{exercise}
379
380 \begin{exercise}
381 Let $F\colon \{0, 1\}^k \times \{0, 1\}^l \to \{0, 1\}^l$ be a PRF, and let
382 $g\colon \{0, 1\}^l \to \{0, 1\}^{2l}$ be a length-doubling PRG. Recall
383 from Exercise~\ref{ex:dbl-prg} the construction $g^(i)$, defined by
384 \[ g^{(1)}(x) = g(x); \qquad
385 g^{(i+1)}(x) = g_0(x) \cat g^{(i)}(g_1(x)). \]%
386 We define an encryption scheme $\mathcal{E} = (E, D)$ as follows:
387 \begin{program}
388 Algorithm $E_K(x)$: \\
389 $i \getsr \{0, 1\}^l$; \\
390 $n \gets \bigl\lceil \frac{|x|}{L} \bigr\rceil - 1$; \\
391 $s \gets F_K(i)$; \\
392 $p \gets g^{(n)}(s)$; \\
393 $y \gets i \cat (x \xor p)$; \\
394 \RETURN $y$;
395 \next
396 Algorithm $D_K(y)$: \\
397 \PARSE $y$ \AS $l\colon i, y'$; \\
398 $n \gets \bigl\lceil \frac{|x|}{L} \bigr\rceil - 1$; \\
399 $s \gets F_K(i)$; \\
400 $p \gets g^{(n)}(s)$; \\
401 $x \gets y' \xor p$; \\
402 \RETURN $x$;
403 \end{program}
404 Prove that
405 \[ \InSec{lor-cpa}(\mathcal{E}; t, q, \mu) \le
406 2 \cdot \InSec{prf}(F; t, q) +
407 2 q \mu \cdot \InSec{prg}(g; t) + q(q - 1), \]%
408 where $\mu$ is the maximum value of $n$, as computed by $E_K(\cdot)$, for
409 any encryption query.
410 Hints:
411 \begin{parenum}
412 \item use a sequence of games, ending with one in which the `ciphertext'
413 are random strings of the right length;
414 \item attack the PRF first;
415 \item use a hybrid argument to attack the PRG, as was used in the proof
416 that $\text{FTG} \implies \text{LOR}$.
417 \end{parenum}
418 \answer%
419 For each game~$\G{i}$, $S_i$~is the event that the adversary guesses
420 correctly. Game~$\G0$ is the original attack game (with the hidden bit~$b$
421 selected uniformly). Game~$\G1$ is the same, except that if, for any pair
422 of ciphertexts, the $i$-values are equal, the game ends immediately: the
423 standard collision bound shows that $|{\Pr[S_1]} - \Pr[S_0]| \le q(q -
424 1)/2$. In game~$\G2$, rather than using $F_K$ to compute the seeds~$s$, we
425 just choose $s \in \{0, 1\}^l$ at random each time. Note that the
426 $i$-values are distinct; hence considering an adversary attacking $F$ as a
427 PRF, which simulates either $\G1$ or $\G2$ depending on whether its oracle
428 is an instance of~$F$ or a random function respectively, shows that
429 $|{\Pr[S_2]} - \Pr[S_1]| \le \InSec{prf}(F; t, q)$.
430
431 In game~$\G3$, rather than using the PRG~$g^{(n)}$, we generate the strings
432 $p$ uniformly at random from $\{0, 1\}^{l(n+1)}$, and claim that
433 $|{\Pr[S_3]} - \Pr[S_2]| \le q \mu \cdot \InSec{prg}(g; t)$ (proven below).
434 Finally, in game~$\G4$, rather than computing the ciphertext as $i \cat (x
435 \xor p)$, we just generate a random string $\{0, 1\}^{l(n+2)}$. Since $i$
436 and $p$ are uniform and random anyway, this doesn't affect the
437 distribution; it does show that the result is independent of the
438 adversary's ciphertext, however, so $\Pr[S_4] = \Pr[S_3] = \frac{1}{2}$.
439 Tying all of this together, $(\Adv{lor-cpa}{\mathcal{E}}(A) + 1)/2 \le
440 \frac{1}{2} + \InSec{prf}(F; t, q) + q\mu \cdot \InSec{prg}(g; t) + q(q -
441 1)/2$. Multiplying through by~2 and rearranging yields the required
442 result.
443
444 \def\H#1{\G[H]{#1}}%
445 We finally turn to the claim made earlier. In $\G2$, we use the PRG; in
446 $\G3$ we don't. We construct a number of hybrid games~$\H{i}$ for $0 \le i
447 \le q$ in which encryption query~$j$ (for $0 \le j < q$) is handled as
448 follows: if $0 \le j < i$ then the query is handled as in $\G3$; if $i \le
449 j < q$ then the query is handed as in $\G2$. Let $T_i$ be the event that
450 the adversary wins in game $\H{i}$. Clearly, $\H0 \equiv \G2$, and $\H{q}
451 \equiv \G3$. For each adjacent pair of hybrid games $\H{i}, \H{i+1}$ (for
452 $0 \le i < q$), we can bound $|{\Pr[T_{i+1}} - \Pr[T_i]|$ by considering an
453 adversary attacking~$g^{(n)}$ by running~$A$ and using its input as the XOR
454 mask~$p$ for query~$i$, and following the rules of game~$\H{i}$ for the
455 other queries: then if $y$~is random, it simulates $\H{i+1}$, whereas if
456 $y$ is the output of $g^{(n)}$ then it simulates $\H{i}$. Thus
457 $|{\Pr[T_{i+1}} - \Pr[T_i]| \le \mu \cdot \InSec{prg}(g; t)$ (by the answer
458 to \ref{ex:dbl-prg}), and $|{\Pr[S_3]} - \Pr[S_2]| = |{\Pr[T_{q-1}]} -
459 \Pr[T_0]| \le q \mu \cdot \InSec{prg}(g; t)$ as claimed.
460 \end{exercise}
461
462 \xcalways\subsection{Block cipher modes}\x
463
464 \begin{slide}
465 \head{Block cipher modes}
466
467 Block ciphers (which we model as PRPs) are readily available components,
468 and we have good tools for analysing their (heuristic) security. It'd be
469 good if we could use them to construct secure encryption schemes.
470
471 We analyse three standard \emph{modes of operation}:
472 \begin{description}
473 \item[Electronic Code Book (ECB)] Each plaintext block is encrypted
474 independently of the others, using the block cipher.
475 \item[Counter (CTR)] Choose a random starting point $i$. The plaintext
476 blocks are XORed with the result of encrypting the counter values $i$,
477 $i + 1$, \ldots
478 \item[Ciphertext Block Chaining (CBC)] The first plaintext block is XORed
479 with a random \emph{initialization vector} and encrypted using the block
480 cipher; thereafter, each plaintext block are XORed with the previous
481 ciphertext block and then encrypted with the block cipher.
482 \end{description}
483 \end{slide}
484
485 \begin{slide}
486 \head{General notation}
487
488 We consider pseudorandom permutations $E\colon \{0, 1\}^k \times \{0, 1\}^l
489 \to \{0, 1\}^l$ operating on $l$-bit blocks. We write $E_K(\cdot)$ rather
490 than $E(K, \cdot)$.
491
492 For the sake of simplicity, we assume that plaintexts are a multiple of $l$
493 bits in length. We shall consider chosen-plaintext attacks, and we shall
494 be quantifying our results in terms of:
495 \begin{itemize}
496 \item the running time $t$ of adversaries;
497 \item the number $q$ of queries made to the encryption oracle; and
498 \item the maximum size in bits $\mu$ of any individual encryption query.
499 \end{itemize}
500
501 We shall write `\FOREACH $l\colon z$ \FROM $x$ \DO \ldots' to denote
502 iteration over each $l$-bit block $z$ of $x$ in turn.
503
504 We use $\emptystring$ to denote the empty string.
505 \end{slide}
506
507 \begin{slide}
508 \topic{ECB}
509 \resetseq
510 \head{Electronic Code Book (ECB), \seq: description}
511
512 We define the scheme $\Xid{\mathcal{E}}{ECB}^E = (\Xid{E}{ECB}^E,
513 \Xid{D}{ECB}^E))$ by setting $\keys\Xid{\mathcal{E}}{ECB}^E = \{0, 1\}^k$
514 and
515 \begin{program}
516 Algorithm $\Xid{E}{ECB}^E_K(x)$: \+ \\
517 $y \gets \emptystring$; \\
518 \FOREACH $l\colon z$ \FROM $x$ \DO \\
519 \quad $y \gets y \cat E_K(z)$; \\
520 \RETURN $y$;
521 \next
522 Algorithm $\Xid{D}{ECB}^E_K(y)$: \+ \\
523 $x \gets \emptystring$; \\
524 \FOREACH $l\colon z$ \FROM $y$ \DO \\
525 \quad $x \gets x \cat E_K^{-1}(z)$; \\
526 \RETURN $x$;
527 \end{program}
528 \end{slide}
529
530 \begin{slide}
531 \head{Electronic Code Book (ECB), \seq: analysis}
532
533 ECB fails to disguise equality of message blocks. Hence, it is insecure in
534 the left-or-right sense.
535 \begin{program}
536 Adversary $A^{E(\cdot, \cdot)}$: \+ \\
537 $y \gets E(0^l \cat 1^l, 0^l \cat 0^l)$; \\
538 \PARSE $y$ \AS $l\colon y_0, l\colon y_1$; \\
539 \IF $y_0 = y_1$ \THEN \RETURN $1$; \\
540 \ELSE \RETURN $0$;
541 \end{program}
542 Since $\Xid{\mathcal{E}}{ECB}^E$ always encrypts blocks independently, and
543 the block cipher $E$ is deterministic, $A$ always succeeds. Hence,
544 \[ \InSec{lor-cpa}(\Xid{\mathcal{E}}{ECB}^E; t, 1, 2 l) = 1 \]
545 for some small $t$ describing the running-time of the adversary $A$.
546
547 According to our formal definitions, then, ECB mode is \emph{completely
548 insecure}.
549 \end{slide}
550
551 \begin{slide}
552 \topic{stateful counter mode}
553 \resetseq
554 \head{Counter (CTR), \seq: a stateful mode}
555
556 We define two schemes. Firstly, a stateful-sender scheme
557 $\Xid{\mathcal{E}}{CTRS}^E = (\Xid{E}{CTRS}^E, \Xid{D}{CTRS}^E))$. We set
558 $\keys\Xid{\mathcal{E}}{ECB}^E = \{0, 1\}^k$, initialize $i \gets 0$, and
559 define
560 \begin{program}
561 Algorithm $\Xid{E}{CTRS}^E_K(x)$: \+ \\
562 $y \gets i$; \\
563 \FOREACH $l\colon z$ \FROM $x$ \DO \\ \quad \= \+ \kill
564 $y \gets y \cat (z \xor E_K(i))$; \\
565 $i \gets i + 1$; \- \\
566 \RETURN $y$;
567 \next
568 Algorithm $\Xid{D}{CTRS}^E_K(y)$: \+ \\
569 \PARSE $y$ \AS $l\colon i, y$; \\
570 $x \gets \emptystring$; \\
571 \FOREACH $l\colon z$ \FROM $y$ \DO \\ \quad \= \+ \kill
572 $x \gets x \cat (z \xor E_K(i))$; \\
573 $i \gets i + 1$; \- \\
574 \RETURN $x$;
575 \end{program}
576 \end{slide}
577
578 \begin{slide}
579 \head{Counter (CTR), \seq: analysis of the stateful version}
580
581 We write $q' = q\mu/l$ for the total number of blocks queried by the
582 adversary, and we restrict our attention to the case $n \le 2^l$.
583
584 Firstly, suppose that, rather than a block cipher, we use a completely
585 random function $R \in \Func{l}{l}$. Then $E(0) \cat E(1) \cat \cdots$ is
586 a string of uniformly distributed and independent bits. Hence
587 \[ \InSec{lor-cpa}(\Xid{\mathcal{E}}{CTRS}^{\Func{l}{l}}; t, q, \mu) = 0 \]
588 for arbitrary $t$, and for $q \mu/l \le 2^l$.
589
590 A simple reduction shows that, for a pseudorandom function $F$, we have
591 \[ \InSec{ror-cpa}(\Xid{\mathcal{E}}{CTRS}^F; t, q, \mu) \le
592 \InSec{prf}(F; t, q'), \]%
593 and hence, for a pseudorandom permutation $E$,
594 \[ \InSec{ror-cpa}(\Xid{\mathcal{E}}{CTRS}^E; t, q, \mu) \le
595 \InSec{prp}(E; t, q') + \frac{q'(q' - 1)}{2^{l+1}}. \]%
596 \end{slide}
597
598 \begin{exercise}
599 Fill in the gaps in the above proof.
600 \answer%
601 The reduction from the PRF distinguisher to the counter-with-PRF scheme
602 works as follows. Let $A$ attack $\Xid{\mathcal{E}}{CTRS}^F$ in the ROR
603 sense; consider adversary $B^{F(\cdot)}$: \{ $b \gets
604 A^{\Xid{E}{CTRS}^F(\cdot)}$; \RETURN $b$;~\}. If $F(\cdot)$ is an instance
605 of the PRF then $B$ encrypts messages chosen by $A$ faithfully; if
606 $F(\cdot)$ is a random function then the ciphertexts $B$ returns consists
607 of a counter followed by a random string, which is therefore distributed
608 identically to a ciphertext of a \emph{random} plaintext. Thus, $B$
609 simulates the real-or-random game perfectly. The result for a PRP follows
610 because $\InSec{prf}(F; t, q) \le \InSec{prp}(F; t, q) + q(q - 1)
611 2^{-L-1}$.
612 \end{exercise}
613
614 \begin{slide}
615 \topic{randomized counter mode}
616 \head{Counter (CTR), \seq: a randomized mode}
617
618 The randomized scheme $\Xid{\mathcal{E}}{CTR$\$$}^E = (\Xid{E}{CTR$\$$}^E,
619 \Xid{D}{CTR$\$$}^E))$ differs from the stateful scheme in the encryption
620 algorithm only. We simply choose the starting value for the counter at
621 random, rather than remembering it.
622 \begin{program}
623 Algorithm $\Xid{E}{CTR$\$$}^E_K(x)$: \+ \\
624 $i \getsr \{0, 1\}^l$; \\
625 $y \gets i$; \\
626 \FOREACH $l\colon z$ \FROM $x$ \DO \\ \quad \= \+ \kill
627 $y \gets y \cat (z \xor E_K(i))$; \\
628 $i \gets i + 1$; \- \\
629 \RETURN $y$;
630 \next
631 Algorithm $\Xid{D}{CTR$\$$}^E_K(y)$: \+ \\
632 \PARSE $y$ \AS $l\colon i, y$; \\
633 $x \gets \emptystring$; \\
634 \FOREACH $l\colon z$ \FROM $y$ \DO \\ \quad \= \+ \kill
635 $x \gets x \cat (z \xor E_K(i))$; \\
636 $i \gets i + 1$; \- \\
637 \RETURN $x$;
638 \end{program}
639 \end{slide}
640
641 \begin{slide}
642 \head{Counter (CTR), \seq: analysis of the randomized version}
643
644 The randomized mode remains secure so long as a counter is never repeated.
645 This occurs with probability no greater than
646 \[ \frac{q\mu(q - 1)}{2^{l+1}}. \]
647 Hence, we have, for a pseudorandom function $F$,
648 \[ \InSec{ror-cpa}(\Xid{\mathcal{E}}{CTR$\$$}^F; t, q, \mu) \le
649 \InSec{prf}(F; t, q') + \frac{q\mu(q - 1)}{2^{l+1}}, \]%
650 and, for a pseudorandom permutation $E$,
651 \[ \InSec{ror-cpa}(\Xid{\mathcal{E}}{CTR$\$$}^E; t, q, \mu) \le
652 \InSec{prp}(E; t, q') + \frac{q'(q' - 1 + l(q - 1))}{2^{l+1}}. \]%
653 \end{slide}
654
655 \begin{proof}[Proof of the collision bound]
656 Suppose all of the queries are maximum length. Then the probability that
657 two randomly started counter sequences overlap is $\mu\cdot 2^{-l}$.
658 Hence, an upper bound on the collision probability is given by
659 \begin{eqnarray*}[rl]
660 \Pr[\text{no collision}] &\le \frac{\mu}{2^l}(1 + 2 + \cdots + q - 1) \\
661 &= \frac{\mu}{2^l} \frac{q(q - 1)}{2} \\
662 &= \frac{q\mu(q - 1)}{2^{l+1}}
663 \end{eqnarray*}
664 as required.
665 \end{proof}
666
667 \begin{slide}
668 \topic{CBC}
669 \resetseq
670 \head{Ciphertext Block Chaining (CBC), \seq: description}
671
672 We define the scheme $\Xid{\mathcal{E}}{CBC}^E = (\Xid{E}{CBC}^E,
673 \Xid{D}{CBC}^E))$ by setting $\keys\Xid{\mathcal{E}}{CBC}^E = \{0, 1\}^k$
674 and
675 \begin{program}
676 Algorithm $\Xid{E}{CBC}^E_K(x)$: \+ \\
677 $i \getsr \{0, 1\}^l$; \\
678 $y \gets i$; \\
679 \FOREACH $l\colon z$ \FROM $x$ \DO \\ \quad \= \+ \kill
680 $i \gets E_K(z \xor i)$; \\
681 $y \gets y \cat i$; \- \\
682 \RETURN $y$;
683 \next
684 Algorithm $\Xid{D}{CBC}^E_K(y)$: \+ \\
685 \PARSE $y$ \AS $l\colon i, y$; \\
686 $x \gets \emptystring$; \\
687 \FOREACH $l\colon z$ \FROM $y$ \DO \\ \quad \= \+ \kill
688 $x \gets x \cat (i \xor E_K^{-1}(z))$; \\
689 $i \gets z$; \- \\
690 \RETURN $x$;
691 \end{program}
692 \end{slide}
693
694 \begin{slide}
695 \head{Ciphertext Block Chaining (CBC), \seq: analysis}
696
697 As before, we set $q' = q\mu/l$ as the number of blocks queried by an
698 adversary attacking the encryption scheme.
699
700 As if by magic,\footnote{%
701 The proof of this result is omitted. The interested reader is directed
702 towards \cite{Bellare:2000:CST}.} %
703 we have the result
704 \[ \InSec{ror-cpa}(\Xid{\mathcal{E}}{CBC}^E; t, q, \mu) \le
705 \frac{q'(q' - 1)}{2^l}. \]%
706 \end{slide}
707
708 \begin{slide}
709 \topic{requirement for random IVs in CBC mode}
710 \head{Ciphertext Block Chaining (CBC), \seq: on randomness of IVs}
711
712 The initialization vector used in CBC encryption must be \emph{a priori}
713 unpredictable to the adversary. Suppose that $P(i)$, given an IV for a
714 ciphertext, can predict the IV which will be used with the next ciphertext
715 with probability $\epsilon$. Then we construct this adversary, attacking
716 $\Xid{\mathcal{E}}{CBC}$ in the ROR-CPA sense:
717 \begin{program}
718 Adversary $A^{E(\cdot)}$: \+ \\
719 $y \gets E(0^l)$; \PARSE $y$ \AS $l\colon i, z$; \\
720 $j \gets P(y)$; $y' \gets E(j)$; \PARSE $y'$ \AS $l\colon i', z'$; \\
721 \IF $i' = j \land y = y'$ \THEN \RETURN $1$; \\
722 \ELSE \RETURN $0$;
723 \end{program}
724 The adversary succeeds when it guesses the IV correctly, \emph{except} when
725 the random encryption oracle happens to choose the same plaintext as we
726 wanted to encrypt anyway. So, therefore,
727 \[ \Adv{ror-cpa}{\Xid{\mathcal{E}}{CBC}^E} \ge \epsilon - 2^{-l}. \]
728 \end{slide}
729
730 \xcalways\subsection{Chosen-ciphertext security for symmetric encryption}\x
731
732 \begin{exercise}
733 Show that CTR and CBC modes are not secure against adaptive
734 chosen-ciphertext attacks.
735 \answer%
736 We use the FTG-CCA2 notion. For CTR mode: \cookie{find}: \RETURN $(0, 1,
737 \bot)$; \cookie{guess}: $y' \gets D(y \xor 0^L1)$; \RETURN $y' \xor 1$;
738 For CBC mode: same find stage, $y' \gets D(y \xor 1)$; \RETURN $y' \xor 1$;
739 \end{exercise}
740
741 \begin{slide}
742 \topic{integrity of ciphertexts}
743 \head{Integrity of ciphertexts \cite{Bellare:2000:AER}}
744
745 Informally, we say that an encryption scheme $\mathcal{E} = (E, D)$ has
746 \emph{integrity of ciphertexts} (whose confusing short name is INT-CTXT) if
747 it's hard for an adversary equipped with an encryption oracle to come with
748 a new \emph{valid} ciphertext, i.e., one for which the decryption function
749 $D_K$ does not return the symbol $\bot$.
750
751 We shall see later that integrity of ciphertexts \emph{and}
752 indistinguishability under chosen-plaintext attacks together imply
753 chosen-ciphertext security. This is intuitively clear, but it's worth
754 proving anyway.
755 \end{slide}
756
757 \begin{slide}
758 \head{Integrity of ciphertexts (cont.)}
759
760 Consider the following game played by an adversary $A$:
761 \begin{program}
762 Experiment $\Expt{int-ctxt}{\mathcal{E}}(A)$: \+ \\
763 $K \getsr \keys\mathcal{E}$; $\Xid{y}{list} \gets \emptyset$;
764 $y \gets A^{\id{encrypt}(\cdot), D_K(\cdot)}$; \\
765 \IF $y \notin \Xid{y}{list} \land D_K(y) \ne \bot$
766 \THEN \RETURN $1$; \\
767 \ELSE \RETURN $0$;
768 \next
769 Oracle $\id{encrypt}(x)$: \+ \\
770 $y \gets E_K(x)$; \\
771 $\Xid{y}{list} \gets \Xid{y}{list} \cup \{y\}$; \\
772 \RETURN $y$;
773 \end{program}
774 We define $A$'s success probability in this game by
775 \[ \Succ{int-ctxt}{\mathcal{E}}(A) =
776 \Pr[\Expt{int-ctxt}{\mathcal{E}}(A) = 1] \]%
777 and write that
778 \[ \InSec{int-ctxt}(\mathcal{E}; t, q_E, q_D) =
779 \max_A \Succ{int-ctxt}{\mathcal{E}}(A), \]%
780 where the maximum is over all adversaries running in time $t$ and issuing
781 $q_E$ encryption and $q_D$ decryption queries.
782 \end{slide}
783
784 \begin{slide}
785 \topic{INT-CTXT and LOR-CPA imply LOR-CCA}
786 \head{INT-CTXT and LOR-CPA together imply LOR-CCA}
787
788 We now prove the claim made earlier. Suppose that the adversary $A$
789 attacks $\mathcal{E}$ in the LOR-CCA sense. We consider these two
790 adversaries, attacking the chosen-plaintext security and ciphertext
791 integrity of $\mathcal{E}$ respectively.
792 \begin{program}
793 Adversary $B^{E(\cdot, \cdot)}$: \+ \\
794 $b \gets A^{E(\cdot, \cdot), \Xid{D}{sim}(\cdot)}$; \\
795 \RETURN $b$; \- \\[\smallskipamount]
796 Oracle $\Xid{D}{sim}(y)$; \+ \\
797 \RETURN $\bot$;
798 \next
799 Adversary $C^{E(\cdot), D(\cdot)}$: \+ \\
800 $b \getsr \{0, 1\}$; $y^* \gets \bot$; \\
801 $b' \gets A^{E(\id{lr}_b(\cdot, \cdot)), \Xid{D}{sim}(\cdot)}$; \\
802 \RETURN $y^*$; \- \\[\smallskipamount]
803 Function $\id{lr}_b(x_0, x_1)$: \+ \\
804 \RETURN $x_b$; \- \\[\smallskipamount]
805 Oracle $\Xid{D}{sim}(y)$: \+ \\
806 $x \gets D(y)$; \\
807 \IF $x \ne \bot$ \THEN $y^* \gets y$; \\
808 \RETURN $x$;
809 \end{program}
810 \end{slide}
811
812 \begin{slide}
813 \head{INT-CTXT and LOR-CPA together imply LOR-CCA2 (cont.)}
814
815 We analyse the advantage of $B$, attacking $\mathcal{E}$ in the LOR-CPA
816 sense. Obviously, $B$ is lying through its teeth in its simulation of
817 $A$'s decryption oracle. If in fact all of $A$'s decryption queries were
818 for invalid ciphertexts, $B$ can't notice. So let $V$ be the event that at
819 least one of $A$'s ciphertexts was valid. Then
820 \[ \Adv{lor-cpa}{\mathcal{E}}(A) \ge
821 \Adv{lor-cca}{\mathcal{E}}(A) - 2\Pr[V]. \]%
822 To bound $\Pr[V]$, we consider adversary $C$, which simply records any of
823 $A$'s decryption queries which returns a valid ciphertext. Since $A$ is
824 forbidden from passing any ciphertexts obtained from its encryption oracle
825 to its decryption oracle, $C$'s returned ciphertext $y^*$ is not one it
826 obtained from \emph{its} encryption oracle. So
827 \[ \Succ{int-ctxt}{\mathcal{E}}(A) = \Pr[V]. \]
828 Concluding, then,
829 \[ \InSec{lor-cca}(\mathcal{E}; t, q_E, q_D) \le
830 \InSec{lor-cpa}(\mathcal{E}; t, q_E) +
831 2 \cdot \InSec{int-ctxt}(\mathcal{E}; t, q_E, q_D). \]%
832 \end{slide}
833
834 \begin{slide}
835 \topic{strong MACs provide INT-CTXT}
836 \head{A strong MAC provides integrity of ciphertexts}
837
838 That's a very nice result, but how do we achieve INT-CTXT? Well, the
839 game in the definition looks very much like the forgery games we played
840 when we were thinking about MACs.
841
842 Suppose that $\mathcal{E} = (E, D)$ is an encryption scheme secure in the
843 LOR-CPA sense, and $\mathcal{M} = (T, V)$ is a strong MAC (in the SUF-CMA
844 sense). Then we can define $\Xid{\mathcal{E}}{auth}^{\mathcal{M}} =
845 (\Xid{E}{auth}^{\mathcal{E}, \mathcal{M}}, \Xid{D}{auth}^{\mathcal{E},
846 \mathcal{M}})$ by
847 \[ \keys\Xid{\mathcal{E}}{auth}^{\mathcal{E}, \mathcal{M}} =
848 \keys\mathcal{E} \times \keys\mathcal{M} \]%
849 and
850 \begin{program}
851 Algorithm
852 $\Xid{E}{auth}^{\mathcal{E}, \mathcal{M}}_{K_E, K_T}(x)$: \+ \\
853 $y \gets E_{K_E}(x)$; \\
854 $\tau \gets T_{K_T}(y)$; \\
855 \RETURN $\tau \cat y$;
856 \next
857 Algorithm
858 $\Xid{D}{auth}^{\mathcal{E}, \mathcal{M}}_{K_E, K_T}(y')$: \+ \\
859 \PARSE $y'$ \AS $\tau, y$; \\
860 \IF $V_{K_T}(y, \tau) = 0$ \THEN \RETURN $\bot$; \\
861 \ELSE \RETURN $D_{K_E}(y)$;
862 \end{program}
863 \end{slide}
864
865 \begin{slide}
866 \head{A strong MAC provides integrity of ciphertexts (cont.)}
867
868 The security proof for $\Xid{\mathcal{E}}{auth}^{\mathcal{E}, \mathcal{M}}$
869 is left as a trivial exercise. We end up with the result that
870 \[ \InSec{int-ctxt}(\Xid{\mathcal{E}}{auth}^{\mathcal{E}, \mathcal{M}};
871 t, q_E, q_D) \le
872 \InSec{suf-cma}(\mathcal{M}; t, q_E, q_D) \]%
873 and hence
874 \begin{eqnarray*}[Ll]
875 \InSec{lor-cca}(\Xid{\mathcal{E}}{auth}^{\mathcal{E}, \mathcal{M}};
876 t, q_E, q_D) \\
877 & \le \InSec{lor-cpa}(\mathcal{E}; t, q_E) +
878 2 \cdot \InSec{suf-cma}(\mathcal{M}; t, q_E, q_D).
879 \end{eqnarray*}
880 A MAC, therefore, can help us to attain a strong notion of secrecy, even if
881 no actual integrity appears to be required. This is an important lesson.
882 \end{slide}
883
884 \begin{exercise}
885 Prove the above result.
886 \answer%
887 Let $A$ attack INT-CTXT. Construct adversary $B^{T(\cdot), V(\cdot)}$: \{
888 $K \getsr \keys\mathcal{E}$; $(y, \tau) \gets A^{\id{encrypt}(\cdot),
889 \id{decrypt}(\cdot)}$; \RETURN $(y, \tau)$;~\} Oracle $\id{encrypt}(x)$:
890 \{ $y \gets E_K(x)$; $\tau \gets T(y)$; \RETURN $(y, \tau)$;~\} Oracle
891 $\id{decrypt}(y, \tau)$: \{ \IF $V(y, \tau) = 1$ \THEN \RETURN $D_K(y)$;
892 \ELSE \RETURN $\bot$;~\}. The simulation of the INT-CTXT game is perfect.
893 \end{exercise}
894
895 \begin{slide}
896 \topic{mixing encryption and MACs}
897 \head{Notes on mixing encryption and MACs}
898
899 To construct $\Xid{\mathcal{E}}{auth}^{\mathcal{E}, \mathcal{M}}$, we
900 applied a MAC to the \emph{ciphertext}. This isn't perhaps the most
901 intuitive way to combine an encryption scheme with a MAC.
902
903 There are three constructions which look plausible.
904 \begin{description}
905 \item[Encrypt-then-MAC:]
906 %
907 $y \gets E_{K_E}(x)$; $\tau \gets T_{K_T}(y)$; \RETURN $\tau \cat y$;
908 \\
909 Encrypt the plaintext, and MAC the ciphertext; used in IPsec and nCipher
910 Impath; we've proven its generic security, using the notion of integrity
911 of ciphertexts.
912 %
913 \item[MAC-then-encrypt:]
914 %
915 $\tau \gets T_{K_T}(x)$; $y \gets E_{K_E}(\tau \cat x)$; \RETURN $y$;
916 \\
917 MAC the plaintext, and encrypt both the plaintext and tag; used in SSL
918 and TLS; not \emph{generically} secure against chosen-ciphertext attacks.
919 %
920 \item[Encrypt-and-MAC:]
921 %
922 $y \gets E_{K_E}(x)$; $\tau \gets T_{K_T}(x)$; \RETURN $\tau \cat y$;
923 \\
924 Separately MAC and encrypt the plaintext; used in SSH; \emph{never}
925 secure against chosen-ciphertext, not generically secure against
926 chosen-plaintext!
927 \end{description}
928 \end{slide}
929
930 \begin{proof}
931 We begin with a few words on our approach, before we embark on the proof
932 proper.
933
934 To demonstrate the generic insecurity of a scheme, we assume the existence
935 of an encryption scheme and MAC (since if they don't exist, the result is
936 vacuously true) and construct modified schemes whose individual security
937 relates tightly to the originals, but the combined scheme is weak.
938
939 We demonstrate \emph{universal} insecurity by showing an attack which works
940 given \emph{any} component encryption and MAC schemes.
941
942 We prove security relationships using the LOR-CPA notion because this is
943 strongest, and bounds for other notions can be derived readily from the
944 left-or-right analysis. We prove insecurity using the FTG-CCA or FTG-CPA
945 notions, because they are weakest and show the strength of our results
946 best.
947
948 We've dealt with the generic security of encrypt-then-MAC already. We turn
949 our attention first first to the generic insecurity of the MAC-then-encrypt
950 scheme.
951
952 Let $\mathcal{E} = (E, D)$ be a symmetric encryption scheme, and let
953 $\mathcal{M} = (T, V)$ be a MAC. We define the MAC-then-encrypt scheme
954 $\Xid{\mathcal{E}}{MtE}^{\mathcal{E}, \mathcal{M}} =
955 (\Xid{E}{MtE}^{\mathcal{E}, \mathcal{M}}, \Xid{D}{MtE}^{\mathcal{E},
956 \mathcal{M}})$ as follows:
957 \[ \keys\Xid{\mathcal{E}}{MtE}^{\mathcal{E}, \mathcal{M}} =
958 \keys\mathcal{E} \times \keys\mathcal{M} \]%
959 and
960 \begin{program}
961 Algorithm
962 $\Xid{E}{MtE}^{\mathcal{E}, \mathcal{M}}_{K_E, K_T}(x)$: \+ \\
963 $\tau \gets T_{K_T}(x)$; \\
964 $\RETURN E_{K_E}(\tau \cat x)$;
965 \next
966 Algorithm
967 $\Xid{D}{MtE}^{\mathcal{E}, \mathcal{M}}_{K_E, K_T}(y)$: \+ \\
968 $x' \gets D_{K_E}(y)$; \\
969 \PARSE $x'$ \AS $\tau, x$; \\
970 \IF $V_{K_T}(x, \tau) = 0$ \THEN \RETURN $\bot$; \\
971 \ELSE \RETURN $x$;
972 \end{program}
973 We construct a new encryption scheme $\mathcal{E}' = (E', D')$ in terms of
974 $\mathcal{E}$, such that the combined scheme
975 $\Xid{\mathcal{E}}{MtE}^{\mathcal{E}', \mathcal{M}}$ is insecure in the
976 FTG-CCA sense. Our modified encryption scheme has $\keys\mathcal{E}' =
977 \keys\mathcal{E}$, and works as follows:
978 \begin{program}
979 Algorithm $E'_K(x)$: \+ \\
980 \RETURN $0 \cat E_K(x)$;
981 \next
982 Algorithm $D'_K(y')$: \+ \\
983 \PARSE $y'$ \AS $1\colon b, y$; \\
984 \RETURN $D_K(y)$;
985 \end{program}
986 That is, the encryption scheme prepends a single bit to the ciphertext, and
987 doesn't check its value during decryption. Intuitively, this makes the
988 scheme malleable: we can change the ciphertext by flipping the first bit,
989 but the MAC tag remains valid because the plaintext is unaffected.
990
991 Firstly, we prove that $\mathcal{E}'$ is LOR-CPA if $\mathcal{E}$ is.
992 Suppose $A'$ attacks $\mathcal{E}'$ in the LOR-CPA sense: then
993 \begin{program}
994 Adversary $A^{E(\cdot, \cdot)}$: \+ \\
995 \RETURN $A'^{0 \cat E(\cdot, \cdot)}$;
996 \end{program}
997 has the same advantage.
998
999 Secondly, we show that the combined MAC-then-encrypt scheme
1000 $\Xid{\mathcal{E}}{MtE}^{\mathcal{E}', \mathcal{M}}$ is insecure in the
1001 FTG-CCA sense. Consider this adversary:
1002 \begin{program}
1003 Adversary $B^{E(\cdot), D(\cdot)}(\cookie{find})$: \+ \\
1004 \RETURN $(0, 1, \bot)$;
1005 \next
1006 Adversary $B^{E(\cdot), D(\cdot)}(\cookie{guess}, y', s)$: \+ \\
1007 \PARSE $y'$ \AS $1\colon b, y$; \\
1008 \RETURN $D(1 \cat y)$;
1009 \end{program}
1010 The ciphertext $1 \cat y$ was never returned by the encryption oracle
1011 (because it always returns the first bit zero); but the plaintext of $1
1012 \cat y$ is the challenge plaintext. Hence, $B$ wins always, and
1013 \[ \InSec{ftg-cca}(\Xid{\mathcal{E}}{MtE}^{\mathcal{E}', \mathcal{M}};
1014 t, 0, 1) = 1, \]%
1015 where $t$ is the running time of the adversary $B$ above.
1016
1017 We now address the separate encrypt-and-MAC scheme, which we define
1018 formally. Let $\mathcal{E} = (E, D)$ be a symmetric encryption scheme, and
1019 let $\mathcal{M} = (T, V)$ be a MAC. Then the the encrypt-and-MAC scheme
1020 $\Xid{\mathcal{E}}{E\&M}^{\mathcal{E}, \mathcal{M}} =
1021 (\Xid{E}{E\&M}^{\mathcal{E}, \mathcal{M}}, \Xid{D}{E\&M}^{\mathcal{E},
1022 \mathcal{M}})$ is defined by:
1023 \[ \keys\Xid{\mathcal{E}}{E\&M}^{\mathcal{E}, \mathcal{M}} =
1024 \keys\mathcal{E} \times \keys\mathcal{M} \]%
1025 and
1026 \begin{program}
1027 Algorithm
1028 $\Xid{E}{E\&M}^{\mathcal{E}, \mathcal{M}}_{K_E, K_T}(x)$: \+ \\
1029 $y \gets E_{K_E}(x)$; \\
1030 $\tau \gets T_{K_T}(x)$; \\
1031 $\RETURN \tau \cat y$;
1032 \next
1033 Algorithm
1034 $\Xid{D}{E\&M}^{\mathcal{E}, \mathcal{M}}_{K_E, K_T}(y')$: \+ \\
1035 \PARSE $y'$ \AS $\tau, y$; \\
1036 $x \gets D_{K_E}(y)$; \\
1037 \IF $V_{K_T}(x, \tau) = 0$ \THEN \RETURN $\bot$; \\
1038 \ELSE \RETURN $x$;
1039 \end{program}
1040
1041 We first show that this scheme is \emph{universally} insecure against
1042 chosen-ciphertext attack. Let $\mathcal{E}$ and $\mathcal{M}$ be an
1043 arbitrary symmetric encryption scheme and MAC, respectively. The attack
1044 works because the MACs can be detached and used in chosen-ciphertext
1045 queries to test for equality of messages.
1046 \begin{program}
1047 Adversary $B^{E(\cdot), D(\cdot)}(\cookie{find})$: \+ \\
1048 \RETURN $(0, 1, \bot)$;
1049 \next
1050 Adversary $B^{E(\cdot), D(\cdot)}$(\cookie{guess}, y', s): \+ \\
1051 $y_1' \gets E(1)$; \\
1052 \PARSE $y'$ \AS $\tau, y$; \\
1053 \PARSE $y_1'$ \AS $\tau_1, y_1$; \\
1054 \IF $\tau = \tau_1 \lor D(\tau \cat y_1) \ne \bot$
1055 \THEN \RETURN $1$; \\
1056 \ELSE \RETURN $0$;
1057 \end{program}
1058 After receiving the challenge ciphertext, the adversary requests an
1059 additional encryption of the plaintext $1$. If the tags are equal on the
1060 two ciphertexts then we announce that the hidden bit is $1$. Otherwise, we
1061 attempt a decryption of the new ciphertext, using the tag from the
1062 challenge. If it decrypts successfully, we announce that the bit is $1$;
1063 otherwise we claim it is zero.
1064
1065 Certainly, this strategy is always correct when the hidden bit is indeed
1066 $1$. However, there is a possibility that the MACs are equal or verify
1067 correctly even when the hidden bit is $0$. To bound this probability, we
1068 construct the following simple adversary against the MAC:
1069 \begin{program}
1070 Adversary $B'^{T(\cdot), V(\cdot)}$: \+ \\
1071 $\tau \gets T(1)$; \\
1072 \RETURN $(0, \tau)$;
1073 \end{program}
1074 We see readily that
1075 \[ \InSec{ftg-cca}(\Xid{\mathcal{E}}{E\&M}^{\mathcal{E}, \mathcal{M}};
1076 t, 1, 1) \ge
1077 1 - \InSec{suf-cma}(\mathcal{M}; t', 1, 0), \]%
1078 where $t$ and $t'$ are the running times of adversaries $B$ and $B'$
1079 respectively.
1080
1081 Finally, we show that the encrypt-and-MAC scheme is generically insecure
1082 against chosen-plaintext attacks only. There are two strategies we could
1083 use. Since both offer useful insights into the properties of MACs, we
1084 present both here.
1085 \begin{itemize}
1086
1087 \item \emph{Deterministic MACs.} In the proof of the universal weakness of
1088 the encrypt-and-MAC scheme, we used the check on the MAC to decide on the
1089 equality of two plaintexts given the ciphertexts. If the MAC is
1090 deterministic (e.g., a PRF) then we don't need a decryption query.
1091
1092 Let $\mathcal{E} = (E, D)$ be a symmetric cipher, and let $\mathcal{M} =
1093 (T, V)$ be a deterministic MAC, e.g., a PRF, or HMAC. Then consider this
1094 adversary:
1095 \begin{program}
1096 Adversary $B^{E(\cdot)}(\cookie{find})$: \+ \\
1097 \RETURN $(0, 1, \bot)$;
1098 \next
1099 Adversary $B^{E(\cdot)}(\cookie{guess}, y', s)$: \+ \\
1100 $y_1' \gets E(1)$; \\
1101 \PARSE $y'$ \AS $\tau, y$; \\
1102 \PARSE $y_1'$ \AS $\tau_1, y_1$; \\
1103 \IF $\tau = \tau_1$ \THEN \RETURN $1$; \\
1104 \ELSE \RETURN $0$;
1105 \end{program}
1106 Since the MAC is deterministic, the tag attached to a ciphertext $1$ is
1107 always the same. We bound the probability that $T_K(0) = T_K(1)$ using
1108 the adversary $B'$ above, and conclude that
1109 \[ \InSec{ftg-cpa}(\Xid{\mathcal{E}}{E\&M}^{\mathcal{E}, \mathcal{M}};
1110 t, 1) \ge
1111 1 - \InSec{suf-cma}(\mathcal{M}; t', 1, 0), \]%
1112 where $t$ and $t'$ are the running times of adversaries $B$ and $B'$
1113 respectively.
1114
1115 \item \emph{Leaky MACs.} A MAC doesn't have to conceal information about
1116 messages. Suppose $\mathcal{M} = (T, V)$ is a secure MAC. We define the
1117 leaky MAC $\mathcal{M}' = (T', V')$ by stating that $\keys\mathcal{M}' =
1118 \keys\mathcal{M}''$ and
1119 \begin{program}
1120 Algorithm $T'_K(x)$: \+ \\
1121 \PARSE $x$ \AS $1\colon x_0, z$; \\
1122 \RETURN $x_0 \cat T_K(x)$;
1123 \next
1124 Algorithm $V'_K(x, \tau')$: \+ \\
1125 \PARSE $\tau'$ \AS $1\colon \tau_0, \tau$; \\
1126 \PARSE $x$ \AS $1\colon x_0, z$; \\
1127 \IF $x_0 \ne \tau_0$ \THEN \RETURN $0$; \\
1128 \ELSE \RETURN $V_K(x, \tau)$;
1129 \end{program}
1130 We must first prove that $\mathcal{M}'$ remains secure. To do this,
1131 consider an adversary $A'$ attacking $\mathcal{M}'$. We construct $A$
1132 attacking $\mathcal{M}$ in the obvious way:
1133 \begin{program}
1134 Algorithm $A^{T(\cdot), V(\cdot)}$: \\
1135 $(x', \tau') \gets
1136 A'^{\Xid{T'}{sim}(\cdot), \Xid{V'}{sim}(\cdot)}$; \\
1137 \PARSE $\tau'$ \AS $1\colon \tau_0, \tau$; \\
1138 \RETURN $(x, \tau)$;
1139 \next
1140 Oracle $\Xid{T'}{sim}(x)$: \+ \\
1141 \PARSE $x$ \AS $1\colon x_0, z'$; \\
1142 \RETURN $x_0 \cat T(x)$; \- \\[\smallskipamount]
1143 Oracle $\Xid{V'}{sim}(x, \tau')$: \+ \\
1144 \PARSE $\tau'$ \AS $1\colon \tau_0, \tau$; \\
1145 \PARSE $x$ \AS $1\colon x_0, z$; \\
1146 \IF $x_0 \ne \tau_0$ \THEN \RETURN $0$; \\
1147 \ELSE \RETURN $V(x, \tau)$;
1148 \end{program}
1149 Here, $A$ simply simulates the environment expected by $A'$. It is clear
1150 that $A$ succeeds whenever $A'$ returns a valid tag for a \emph{new}
1151 message. However, suppose that $A'$ returns a new tag $\tau'$ for some
1152 old message $x$, for which the tag $\tau$ was returned by the tagging
1153 oracle. Let $x_0$, $\tau_0$ and $\tau'_0$ be the first bits of $x$,
1154 $\tau$ and $\tau'$ respectively, and let $\tau^*$ be the remaining bits
1155 of $\tau'$. If the pair $(x, \tau')$ is to be a valid
1156 $\mathcal{M}'$-forgery, we must have $x_0 = \tau_0 = \tau'_0$. Hence,
1157 $\tau$ and $\tau'$ must differ in at least one other bit, and $(x,
1158 \tau^*)$ is a valid $\mathcal{M}$-forgery. We conclude that
1159 \[ \InSec{suf-cma}(\mathcal{M}'; t, q_T, q_V) \le
1160 \InSec{suf-cma}(\mathcal{M}; t, q_T, q_V) \]%
1161 as required.
1162
1163 Now we show that the combined encrypt-and-MAC scheme is weak in the
1164 FTG-CPA sense. Consider this adversary attacking the scheme:
1165 \begin{program}
1166 Adversary $B^{E(\cdot), D(\cdot)}(\cookie{find})$: \+ \\
1167 \RETURN $(0, 1, \bot)$;
1168 \next
1169 Adversary $B^{E(\cdot), D(\cdot)}$(\cookie{guess}, y', s): \+ \\
1170 \PARSE $y'$ \AS $\tau, y$; \\
1171 \PARSE $\tau$ \AS $1\colon b, \tau^*$; \\
1172 \RETURN $b$;
1173 \end{program}
1174 The leaky MAC simply tells us the right answer. So
1175 \[ \InSec{ftg-cpa}(\Xid{\mathcal{E}}{E\&M}^{\mathcal{E}, \mathcal{M}'};
1176 t, 0) = 1, \]%
1177 where $t$ is the running time of adversary $B$ above.
1178
1179 \end{itemize}
1180
1181 This concludes the proof.
1182 \end{proof}
1183
1184 %% TO DO: Include stuff about integrity-aware encryption modes some day.
1185
1186 \endinput
1187
1188 %%% Local Variables:
1189 %%% mode: latex
1190 %%% TeX-master: "ips"
1191 %%% End: