Skip to content
uencoder

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 P3
    Output
    C1 C2 C3

    Each 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

Related tools

References