# Alter CBC plaintext by altering IV [duplicate]

I am building on this answer. Essentially I have an initialisation vector $$iv$$, a ciphetext $$c$$ and a plaintext $$p$$. The plaintext was encrypted using AES CBC. The aim is to modify the first 4 characters of the plaintext so that it becomes $$p_{target}$$.

Ex:

$$p$$ = 'SEND_DOGGOS_LOVE'

$$c$$ = 0x63fd039cc488dd7d937677b322a7763c

$$iv$$ = 0xa9e459b1a2e68cd7db06cf24b7e0bde8

$$p_{target}$$ = 'CATS_DOGGOS_LOVE'

My understanding was that to achieve that, I can change the $$iv$$ by simply xoring the first 4 chars of $$iv$$ with the result of $$xor($$'CATS','SEND'$$)$$. This however doesn't seem to work as I get a nonsensical plaintext. What am I missing?

• You are talking about bit-flipping attack. See also this Bit Flipping Attack on CBC Mode. Also, your error might be on your code, which is not a related question here – kelalaka Jul 12 '19 at 8:43
• OK thanks, meaning my understanding of the attack is correct, based on the answer in the link? – S. L. Jul 12 '19 at 8:53
• Yes, we can also see from this; normally $C_1 \oplus IV = P_1$ if you modify the $IV_{new} = IV \oplus P_x \oplus P_1$ then you can see that $C_1 \oplus IV \oplus P_x \oplus P_1 = P_x$ . – kelalaka Jul 12 '19 at 9:09
• OK yes, makes sense. I rewrote it from scratch and I found the issue, it was indeed code-related. Thank you! – S. L. Jul 12 '19 at 11:10
• Also, Possible duplicate of Alter plaintext in block cipher AES in CBC mode – kelalaka Jul 12 '19 at 19:02