Triple-Flavor
2 files available
Description
Why settle for just one mode of operation when you can have 3?
Solution
The challenge presents a server with an encryption function that uses AES with 3 different modes of operation concatenated together: ECB and OFB in encryption mode and CBC in decryption mode. It can be observed that the server generates the keys for the different mode in a vulnerable way: a secret token made up of lowercase letters and digits is randomly created and split in 3 substrings of 5 characters each; these substrings are then hashed using SHA256; the 3 digests are then truncated to 16 bytes and used as keys for the respective ciphers.
The server returns the ciphertext corresponding to a plaintext submitted by the user and then asks for a guess of the secret token. If the guess is correct the server returns the flag.
To retrieve the second and the third parts of the secret token the AAA-attack can be carried out. The following image presents a scheme of the encryption process for two equal plaintext blocks.
From this it can be seen that the following equalities hold
The first one can be rewritten in the following way
And then it is possible to XOR it with the expression for to eliminate the outer
Finally, by encrypting both sides with key and XOR-ing with the expression for it is possible to get the following expression
As it can be seen this expression depends only on information provided to the user: the ciphertext blocks, the ivs and the tweaks (which can be computed from the ). Therefore this can be used as the condition to test for a meet-in-the-middle attack to recover the second and the third parts of the secret token and, in turn the keys and . Once these are known, the last two layers of the encryption process can be reversed to get the intermediate ciphertext and use it to bruteforce the last part of the secret token.