# Decrypt simple CBC message with known IV using XOR encryption

I've been given a ciphertext message, encrypted using CBC. I know that the block size is 12 bytes and I know the plaintext value of the first block.

I also know that the encryption function is a simple XOR:

$$C_i = K \oplus (M_i \oplus C_{i-1})$$

where $C_0 = IV$.

Now I supposedly should be able to deduce the complete plain text message, but I'm lost. What sort of XOR'ing magic should I perform here to get hold of the plain text?

• If you're doing this for a university assignment (removed that part from the question) then I would strongly recommend you to learn some $\TeX$ so you can format your formulas. It will come in handy later. Hit the edit button above to see the changes I made. – Maarten Bodewes Dec 11 '16 at 13:41
• Yes of course, you are right. I was in a bit of hurry when typing the question and intended on cleaning it up as soon as I had the chance. Thanks for doing it for me. – mimos Dec 11 '16 at 13:50

That's easy: $C_1 = K \oplus (M_1 \oplus C_0)$. You know $C_1$, $M_1$ and of course $C_0$, the IV. You can easily rewrite this as $K = C_0 \oplus C_1 \oplus M_1$.
What is left is simply decryption with $K$. In case of XOR encryption, decryption is the same as encryption, so $M_i = (K \oplus C_i) \oplus C_{i-1}$.
• this will obviously not work with secure block ciphers since retrieving $K$ is not supposed to be possible, even when given a known plaintext / ciphertext pair.