CBC block cipher mode
CBC bitflipping attack
Setup
Attack
Get block size
Craft the input to the oracle
Flip ciphertext bits
Code
Conclusion
Today, we will learn about the CBC block cipher mode, how it works, and the bitflipping attack. This post is related to https://cryptopals.com/sets/2/challenges/16 .
CBC block cipher mode
Cipher Block Chaining (CBC) is a block cipher mode of operation. Data is encrypted in blocks of fixed size and with the same key. Also, some bytes are added when the plaintext doesn't have a length that is a multiple of the block size, known as padding .
Let p be the plaintext, c the ciphertext, k the key, IV the
initialization vector (later explained), ^ the XOR operation, E any encryption algorithm and D its decryption counterpart. Assume that the ciphertext can be divided into blocks of length equal to l , without any leftover bytes. For the first block, the encrypted version is computed as c[0] = E(IV ^ p[0], k) .…