CBC (Cipher Block Chaining)
CBC mode XORs the previous ciphertext block with the current plaintext before encrypting, so identical plaintext blocks yield different ciphertexts; it requires a random IV but provides no integrity authentication.
Purpose
It eliminates the identical-block patterns of ECB and provides confidentiality, but needs an additional MAC for integrity.
Mechanism
Encryption: C_i = E_K(P_i ⊕ C_{i-1}), with C_0 = IV. Decryption: P_i = D_K(C_i) ⊕ C_{i-1}. The IV must be unpredictable (random). Error propagation affects only the current and next blocks. It is unauthenticated and must be paired with an HMAC (Encrypt-then-MAC).
Use cases
- File encryption (e.g., OpenSSL defaults)
- Database field encryption
- IPsec ESP (historical)
- Disk encryption (partially)
Examples
- Input
IV + P1 P2 P3OutputC1 C2 C3Each block depends on the previous one
Common errors
- A predictable IV enables chosen-plaintext attacks
- Use a random IV and transmit it with the ciphertext
- Lack of authentication invites padding attacks (e.g., POODLE)
- Use an AEAD mode or Encrypt-then-MAC
Related terms
ECB (Electronic Codebook)
ECB mode encrypts each block independently, so identical plaintext blocks produce identical ciphertext blocks; it is insecure and suitable only for single-block or random data. GLOSSARY
CTR (Counter Mode)
CTR mode turns a block cipher into a stream cipher: it encrypts an incrementing counter to generate a keystream that is XORed with the plaintext, supporting parallelism and random access, but provides no integrity. GLOSSARY
GCM (Galois/Counter Mode)
GCM is an AEAD mode that combines CTR encryption with GHASH authentication, providing confidentiality and integrity at once, and is the preferred mode of TLS 1.2/1.3. GLOSSARY
Mode of Operation
A mode of operation is a scheme that lets a block cipher handle arbitrary-length data, defining how multiple plaintext blocks are chained during encryption; common ones include ECB, CBC, CTR, and GCM. GLOSSARY
IV (Initialization Vector)
An initialization vector (IV) is an input that injects randomness into block-cipher modes so that the same plaintext produces different ciphertexts across encryptions. GLOSSARY