# Are there equivalent IVs in DES/CBC?

I'm playing around with the CryptoPP library with DES/CBC and I've noticed that for some sets of data, if I decrypt the ciphertext with Key1, IV1, I get a good cleartext result -- but if I decrypt the same ciphertext with Key1, IV2, I get the identical good cleartext result.

I find this very surprising. So much so, that I think I'm doing something wrong.

I want to check my assumptions: I've been under the impression that changing even 1 bit of the IV will alter the decryption result. Is this not true?

Is there such a thing as an "equivalent" IV?

• The first block (8 bytes) should differ if you use another IV. – CodesInChaos Apr 14 '15 at 18:49

During CBC mode decryption, each ciphertext block is first decrypted with the block cipher, and then the first decrypted block is XORed with the IV, while later blocks are XORed with the previous ciphertext block:

Thus, the first block of plaintext is computed as: $$P_1 = IV \oplus D_K(C_1).$$

Equivalently, we may solve this equation for $IV$ to obtain: $$IV = P_1 \oplus D_K(C_1).$$

This means that, for any ciphertext and key, it's always possible to choose the IV so that the first block will decrypt to any plaintext we want.

This also implies that CBC mode is trivially malleable: an attacker who can modify the encrypted message can flip arbitrary bits in the first block of the plaintext simply by flipping the corresponding bits of the IV. In particular, if the attacker can guess the original first block of plaintext, they can rewrite it to say whatever they want without knowing the key. (A similar attack is possible for later blocks, but it tends to randomly scramble the previous block of plaintext.)

Such malleability is a general feature of CBC and all other non-authenticating cipher modes. To protect against it, it is necessary to verify the integrity of the ciphertext using a MAC, or to use a combined authenticated encryption mode.

• "This means that, for any ciphertext and key, it's always possible to choose the IV so that the first block will decrypt to any plaintext we want." Presumably there is a "true" plaintext. My question is, does an IV2 exist such that Decrypt(IV1, Key, CipherText) == True Plaintext == Decrypt(IV2, Key, CipherText) – Runcible Apr 14 '15 at 18:28
• If the key and the ciphertext are fixed, then no. If $P_1 = IV_1 \oplus D_K(C)$ and $P_2 = IV_2 \oplus D_K(C)$, then $P_1 \oplus P_2 = IV_1 \oplus D_K(C) \oplus IV_2 \oplus D_K(C) = IV_1 \oplus IV_2$. Thus, $P_1 = P_2$ if and only if $IV_1 = IV_2$. – Ilmari Karonen Apr 14 '15 at 18:36