0

I'm learning how CBC works but i don't understand when altering the first 2 bytes of the ciphered text why the 1rst block and ONLY the first 2 bytes of the second block are altered. The first 2 bytes of the cypher text are altered using a xor operation with random values. Each block is made of 16 bytes.

Those are the random bytes to encrypt:

D6 D7 17 2B D8 1B 73 DF AA D4 D0 DC 94 D1 C2 B2 EE 0D 3B DA 74 58 62 F9 F9 D1 30 59 F5 FE 7D 54 14 79 42 14 B6 1D 34 C7 19 B0 68 67 36 25 D9 FA D0 1C 61 CB 40 A2 CD 77 6A 7D D3 D4 A2 23 9B 4F AF

This is the cypher text:

D2 CD F5 92 8D 1D 4E BC A1 9A CE 50 07 8C 13 FE 33 4B FE BD A0 6B 6C 7B F4 38 90 F4 36 A6 9A 15 A3 D8 41 F4 04 5D C0 9C A3 B6 A6 A8 4A B5 B2 F9 3C E3 0B 93 5E E1 42 26 66 58 16 39 A4 9C 14 5D 69 E9 EE C8 7D 0F AC 85 E7 EC 9C 0B C4 E4 74 22

This is the altered cypher text by xoring the previous text with 80 80:

52 4D F5 92 8D 1D 4E BC A1 9A CE 50 07 8C 13 FE 33 4B FE BD A0 6B 6C 7B F4 38 90 F4 36 A6 9A 15 A3 D8 41 F4 04 5D C0 9C A3 B6 A6 A8 4A B5 B2 F9 3C E3 0B 93 5E E1 42 26 66 58 16 39 A4 9C 14 5D 69 E9 EE C8 7D 0F AC 85 E7 EC 9C 0B C4 E4 74 22

And finally the decrypted altered text:

D6 1E 4E A5 5A 8D 3B 4A E6 2F E2 0A 41 21 68 51 6E 8D 3B DA 74 58 62 F9 F9 D1 30 59 F5 FE 7D 54 14 79 42 14 B6 1D 34 C7 19 B0 68 67 36 25 D9 FA D0 1C 61 CB 40 A2 CD 77 6A 7D D3 D4 A2 23 9B 4F AF

  • It helps but my question is: after flipping a byte in a cyphertext block, why the byte in the same position in the following block will be affected and not the rest. Let's say I flipped the first byte of the first block, why only the first byte of the next block will be affected and not the entire second block. – Nadim Hajj Feb 20 '22 at 20:46
  • Did you see the red case? Modification in the first 16 bytes ( It is actually the IV) only affects the first block of the plaintext. – kelalaka Feb 20 '22 at 20:52
  • I found the solution it's actually about the xor and it's properties. Thanks for pointing me to this article it helped a lot. – Nadim Hajj Feb 20 '22 at 21:01

0 Answers0