Assume someone wants to attack an encryption scheme with the following characteristics for a given plaintext
P and ciphertext
C: :\begin{align} C &= \mathit{ENC}_{k_2}(\mathit{ENC}_{k_1}(P)) \\ P &= \mathit{DEC}_{k_1}(\mathit{DEC}_{k_2}(C)) \\ \end{align} where
ENC is the encryption function,
DEC the decryption function defined as
ENC−1 (inverse mapping) and
k1 and
k2 are two keys. The naive approach at brute-forcing this encryption scheme is to decrypt the ciphertext with every possible
k2, and decrypt each of the intermediate outputs with every possible
k1, for a total of 2|
k1| × 2|
k2| (or 2|
k1|+|
k2|) operations. The meet-in-the-middle attack uses a more efficient approach. By decrypting
C with
k2, one obtains the following equivalence: :\begin{align} C &= \mathit{ENC}_{k_2}(\mathit{ENC}_{k_1}(P)) \\ \mathit{DEC}_{k_2}(C) &= \mathit{DEC}_{k_2}(\mathit{ENC}_{k_2}[\mathit{ENC}_{k_1}(P)]) \\ \mathit{DEC}_{k_2}(C) &= \mathit{ENC}_{k_1}(P) \\ \end{align} The attacker can compute
ENCk1(
P) for all values of
k1 and
DECk2(
C) for all possible values of
k2, for a total of 2|
k1| + 2|
k2| (or 2|
k1|+1, if
k1 and
k2 have the same size) operations. If the result from any of the
ENCk1(
P) operations matches a result from the
DECk2(
C) operations, the pair of
k1 and
k2 is possibly the correct key. This potentially-correct key is called a
candidate key. The attacker can determine which candidate key is correct by testing it with a second test-set of plaintext and ciphertext. The MITM attack is one of the reasons why
Data Encryption Standard (DES) was replaced with
Triple DES and not Double DES. An attacker can use a MITM attack to bruteforce Double DES with 257 operations and 256 space, making it only a small improvement over DES.
MITM algorithm Compute the following: • \mathit{SubCipher}_1=\mathit{ENC}_{f_1}(k_{f_1},P),\; \forall k_{f_1} \in K : • : and save each \mathit{SubCipher}_{1} together with corresponding k_{f_1} in a set A • \mathit{SubCipher}_1=\mathit{DEC}_{b_1}(k_{b_1},C),\; \forall k_{b_1} \in K : • : and compare each new \mathit{SubCipher}_1 with the set A When a match is found, keep k_{f_1},k_{b_1} as candidate key-pair in a table
T. Test pairs in
T on a new pair of to confirm validity. If the key-pair does not work on this new pair, do MITM again on a new pair of .
MITM complexity If the keysize is
k, this attack uses only 2
k+1 encryptions (and decryptions) and
O(2
k) memory to store the results of the forward computations in a
lookup table, in contrast to the naive attack, which needs 22·
k encryptions but
O(1) space. == Multidimensional MITM (MD-MITM) ==