An embarrassing challenge for me. The solution to this challenge is quite simple. The symmetry of the xor
operation enables us to decrypt the message/plaintext $P$ from the $IV$ and ciphertext $C$. Denote the output after running block cipher encryption with key k $E_k$ to be $O$, then we have:
xor
both sides of the above equation, we have:
Therefore:
$$ C \oplus O = P $$Hence, the simpler solution just involves sending the $IV$ and $C$ to the encryption oracle given.
My approach is similar to ECB-Oracle, and much slower. I take advantage of the fact that we can indeed guess character by character the plaintext, as the plaintext is used in xor
-ing the output $O$ to obtain the ciphertext $C$. Encryption is deterministic, so with the same $IV$, the output of the encryption using the same key is the same. Hence, a correct guess of the character of the plaintext in position i
will lead to the corresponding position i
in the resulting ciphertext to have the same value as the position i
of the flag’s ciphertext. This is similar to the guessing character-by-character technique seen in ECB CPA attack.
Python Implementation of the attack:
|
|