# Cryptography/Meet In The Middle Attack

An extremely specialized attack, meet in the middle is a known plaintext attack that only affects a specific class of encryption methods - those which achieve increased security by using one or more "rounds" of an otherwise normal symmetrical encryption algorithm. An example of such a compound system is 3DES.

However, to explain this attack let us begin with a simpler system defined as follows: Two cryptographic systems denoted ${\displaystyle encrypt_{\alpha }}$ and ${\displaystyle encrypt_{\beta }}$ (with inverse functions ${\displaystyle decrypt_{\alpha }}$ and ${\displaystyle decrypt_{\beta }}$ respectively) are combined simply (by applying one then the other) to give a composite cryptosystem. each accepts a 64 bit key (for values from 0 to 18446744073709551615) which we can call ${\displaystyle key_{\alpha }}$ or ${\displaystyle key_{\beta }}$ as appropriate.

So for a given plaintext, we can calculate a cryptotext as

${\displaystyle cryptotext=encrypt_{\beta }(key_{\beta },encrypt_{\alpha }(key_{\alpha },plaintext))}$

and correspondingly

${\displaystyle plaintext=decrypt_{\alpha }(key_{\alpha },decrypt_{\beta }(key_{\beta },cryptotext))}$

Now, given that each has a 64 bit key, the amount of key needed to encrypt or decrypt is 128 bits, so a simple analysis would assume this is the same as a 128 bit cypher.

However, given sufficient storage, you can reduce the effective key strength of this to a few bits larger than the largest of the two keys employed, as follows.

1. Given a plaintext/cyphertext pair, apply ${\displaystyle encrypt_{\alpha }}$ to the plaintext with each possible key in turn, generating ${\displaystyle 2^{64}}$ intermediate cryptotexts ${\displaystyle cryptotext_{1}}$${\displaystyle \rightarrow }$${\displaystyle cryptotext_{n}}$ where ${\displaystyle n=2^{64}}$
2. Store each of the ${\displaystyle n}$ cryptotexts in a hash table so that each can be referenced by its cryptotext, and give the key used to generate that cryptotext
3. Apply ${\displaystyle decrypt_{\beta }}$ to the ciphertext for each possible key in turn, comparing the intermediate plaintext to the hash table calculated earlier. this gives a pair of keys (one for each of the two algorithms employed, ${\displaystyle \alpha }$ and ${\displaystyle \beta }$)
4. Taking the two keys from stage 3, test each against a second plaintext/cryptotext pair. if this also matches, odds are extremely high you have a valid keypair for the message - not in ${\displaystyle 2^{128}}$ operations, but a "mere" ${\displaystyle 2x2^{64}}$ operations (which nonetheless are significantly longer due to the hash table operations, but not so much as to add more than a couple of extra bits worth of time to the complexity of the task)

The downside to this approach is storage. Assuming you have a 64 bit key, then you will need at least ${\displaystyle 2^{64}}$ units of storage - where each unit is the amount of space used by a single hash record. Even given a minimal implementation (say, 64 bits for the key plus four bits hash collision overhead), if you implemented such a system using 160GB hard drives, you would need close to one billion of them to store the hash table alone.