REFERENCE GUIDE

ECB, CBC, and CTR: recognizing mode-specific structure

Block-cipher modes define how fixed-size transformations process longer messages.

Also known as: ECB · CBC · CTR

block-modescrypto

Mechanism

Block-cipher modes define how fixed-size transformations process longer messages. ECB encrypts equal plaintext blocks equally under the same key. CBC chains each block with the previous ciphertext or IV. CTR produces an XOR keystream from counter inputs. The useful attack surface depends on mode, nonce/IV handling, authentication, and the application oracle.

Practical method

Collect messages of controlled lengths and locate block boundaries. Change one input byte and inspect which output blocks change. Repeat identical messages to observe IV or nonce behavior. Separate deterministic format prefixes from encrypted content and identify any authentication tag.

ECB: C_i = E_K(P_i)
CBC: C_i = E_K(P_i XOR C_(i-1)); C_0 = IV
CTR: C_i = P_i XOR E_K(counter_i)

Interpreting evidence

Repeated ciphertext blocks strongly suggest deterministic block behavior but require known alignment. Error behavior after modifying a ciphertext can reveal whether integrity is checked before decryption or parsing.

Pitfalls and limits

An IV need not be secret, but its required randomness or uniqueness depends on mode. CBC bit manipulation generally corrupts an adjacent block. Authenticated encryption prevents accepting arbitrary modified ciphertext when correctly verified.

Sources & further reading

  1. SP 800-38A ↗nist

Content license: CC-BY-4.0. Source-derived sections retain their cited licenses and redistribution notices. How this reference is compiled →