Algorithm Search⌘K

Proofs: Meet-in-the-middle attack

These are the human proofs of Meet-in-the-middle attack, at full length.

The meet-in-the-middle attack returns exactly the consistent key pairs full

This proof shows: correctness, termination.

We use the pseudocode of the page. The keys are K={0,1,…,K−1}\mathcal{K} = \{0, 1, \ldots, K-1\} and the blocks are B={0,1,…,N−1}\mathcal{B} = \{0, 1, \ldots, N-1\}. For each key kk, Ek:B→BE_k : \mathcal{B} \to \mathcal{B} is a bijection and DkD_k is its inverse. There are t≥1t \ge 1 known pairs (Pi,Ci)(P_i, C_i). The target set is

R∗={(k1,k2)∈K2:Ek2(Ek1(Pi))=Ci for i=1,…,t}.R^* = \{(k_1, k_2) \in \mathcal{K}^2 : E_{k_2}(E_{k_1}(P_i)) = C_i \text{ for } i = 1, \ldots, t\}.

Claim. MEET-IN-THE-MIDDLE stops after 2K+2c(t−1)2K + 2c(t-1) cipher calls, where cc is the number of pairs (k1,k2)(k_1, k_2) with Ek2(Ek1(P1))=C1E_{k_2}(E_{k_1}(P_1)) = C_1. The list RR that it returns holds each element of R∗R^* exactly once and holds nothing else.

Step 1 (the table). We show this invariant of the loop of line L2:

(T) Before the iteration with k1=jk_1 = j, for each block xx, the list T[x]T[x] holds the keys k∈{0,…,j−1}k \in \{0, \ldots, j-1\} with Ek(P1)=xE_k(P_1) = x, each one exactly once, in increasing order.

Initialization. For j=0j = 0 the set of keys is empty, and line L1 makes each list empty.

Maintenance. The iteration with k1=jk_1 = j appends jj to the list T[Ej(P1)]T[E_j(P_1)] and changes no other list. So the list of the block x=Ej(P1)x = E_j(P_1) gains the key jj, which is larger than each key in it, and the other lists still hold the right keys. This is (T) for j+1j + 1.

Termination. The loop stops after j=K−1j = K - 1. Then (T) with j=Kj = K says: for each block xx, T[x]={k∈K:Ek(P1)=x}T[x] = \{k \in \mathcal{K} : E_k(P_1) = x\}, each key once.

Step 2 (the candidates). Fix k2∈Kk_2 \in \mathcal{K} and let X=Dk2(C1)X = D_{k_2}(C_1) (line L6). For a key k1k_1, Step 1 gives: k1∈T[X]k_1 \in T[X] if and only if Ek1(P1)=Dk2(C1)E_{k_1}(P_1) = D_{k_2}(C_1). Apply the bijection Ek2E_{k_2} to both sides. Since Ek2(Dk2(C1))=C1E_{k_2}(D_{k_2}(C_1)) = C_1, and since Ek2E_{k_2} is one-to-one, this holds if and only if Ek2(Ek1(P1))=C1E_{k_2}(E_{k_1}(P_1)) = C_1. So the loop of line L7 visits exactly the keys k1k_1 such that (k1,k2)(k_1, k_2) is consistent with the first pair, each one once.

Step 3 (the filter). For such a candidate, line L8 appends (k1,k2)(k_1, k_2) to RR if and only if it is also consistent with the pairs 2,…,t2, \ldots, t. With Step 2, the iteration of line L5 for k2k_2 appends exactly the elements of R∗R^* whose second key is k2k_2, each one once.

Step 4 (the result). The loop of line L5 takes each k2∈Kk_2 \in \mathcal{K} once. Different values of k2k_2 append different pairs. So at line L10, RR holds each element of R∗R^* exactly once and nothing else.

Termination and cost. The loops of lines L2 and L5 have KK iterations each, with one cipher call each. By Step 2, the loop of line L7 runs cc times in total. Each run of line L8 makes at most two cipher calls for each of the pairs 2,…,t2, \ldots, t. Each loop runs over a finite range or a finite list, so the procedure stops, after at most 2K+2c(t−1)2K + 2c(t-1) cipher calls. ■\blacksquare

Order. Line L5 takes k2k_2 in increasing order, and by Step 1 each list T[X]T[X] is in increasing order. So RR is sorted by k2k_2, and by k1k_1 for equal k2k_2.

Back to Meet-in-the-middle attack