1
$\begingroup$

I've just read about CBC encryption and decryption and was wondering how you can change every plaintext block?

Let's say you have an initialization vector, 3 ciphertext blocks, know each block-cipher-decryption and you know each plaintext block too. Then you have some string that you want to change these given plaintexts to. Edit: Assume there is a padding oracle available as well.

If I understood correctly, it will be quite easy to change the very first plaintext block: You take each byte of the initialization vector XORed with each byte of the first plaintext block XORed with the character of the string you want to change these plaintexts to. Putting all these new bytes together, this is now the new initialization vector and XORing this new initialization vector with the first ciphertext block, we will get another plaintext; that one we wanted.

The change of the iv has no effect on the plaintext of the next ciphertext block. But now in order to change the next, namely the second plaintext, we would have to do changes on the first ciphertext block which will sadly destroy the first plaintext block... And the same will happen if we move to the next ciphertext block and try to change its plaintext. So, in the end, there will just be junk plaintext or nothing at all, bad format. But I don't see any other way where you could change all plaintext blocks correctly? : /

I've mainly oriented myself on this nice diagram here from Wikipedia:

enter image description here

$\endgroup$
4
$\begingroup$

If this is all you have, then I think you can't. You can easily get 1st and 3rd block. Change the 2nd ciphertext to get the desired result of 3rd block and change IV to get the desired result for first. But changing a cipher text block means you no longer have the results of the block cipher decryption.

If you have however limited access to a decryption oracle then you will just need to make trial decryption of two blocks. The ciphertext of block 2 which makes the 3rd block what you want. And then given it, you choose the ciphertext for block 1 which you send to decryption in order to calculate required IV.

$\endgroup$
  • $\begingroup$ Great answer, thank you very much! Will see if I find such oracle somewhere and see if I can play with it but I got your idea for sure :) $\endgroup$ – tenepolis May 26 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.