Newbie question here but can I get the IV if I know the Key, plain text and chiper text ?

(I thought that if I encrypt 16 first bytes of clear with the key and 16 first bytes of cipher text as IV it would work to get original IV but it seems that it doesn't)


  • $\begingroup$ What's the equation relating the $i^\mathit{th}$ plaintext block $P_i$, the $i^\mathit{th}$ ciphertext block $C_i$, and cipher $E_k$ in CBC mode? Where does the initialization vector figure into it? $\endgroup$ Nov 15, 2017 at 16:08
  • $\begingroup$ You mean that C0 = IV ? $\endgroup$
    – katze
    Nov 15, 2017 at 16:11
  • $\begingroup$ That's part of it. How is $P_i$ related to $C_i$ for $i > 0$? $\endgroup$ Nov 17, 2017 at 4:05

1 Answer 1


The IV is XOR'ed with the plaintext before encrypting the first block. You can get the input of the block cipher by decrypting the first block of ciphertext using the block cipher directly.

After that it is a simple operation to get the IV, of course, considering you know the plaintext and - hopefully - the mathematical properties of XOR.

  • $\begingroup$ @zaph Maarten is talking about a straight decryption of the first block w/o involving any modes, so you don't need an IV, BTW Maarten, you may want to add some mathy formulas to your answer for illustration $\endgroup$
    – SEJPM
    Nov 15, 2017 at 19:50
  • $\begingroup$ OK, I finally see. Thx! $\endgroup$
    – zaph
    Nov 15, 2017 at 19:58
  • $\begingroup$ @SEJPM This is commonly a question in crypto courses to test if the student understands the mode. This is why I left out the actual calculations and schematics. Usually there is not much use for retrieving the IV, especially if the plaintext is already known anyway. $\endgroup$
    – Maarten Bodewes
    Nov 15, 2017 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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