Block Ciphers

Work in progress. This note is still being written and incomplete.

6 min read Last updated Tue Aug 04 2026 03:56:01 GMT+0000 (Coordinated Universal Time)

A block cipher operates on a fixed-length block of plaintext mm of nn bits, mapping it to a ciphertext block cc of the same length under a secret key kk, both drawn from {0,1}n\{0,1\}^n.

For a fixed key kk, the encryption function eke_k is a bijection on {0,1}n\{0,1\}^n, so it is invertible via dkd_k.

Block Cipher as a PRP

A block cipher’s key design objective is to behave like a family of pseudorandom permutations (PRP) indexed by kk.

Large messages are divided into blocks and encrypted independently per block:

ciek(mi),midk(ci)c_i \leftarrow e_k(m_i), \quad m_i \leftarrow d_k(c_i)

Per Kerckhoffs’s principle, ee and dd are public. Only kk is secret.

Attacking a Block Cipher

  • Ciphertext only
    Attacker has only cc and searches the key space exhaustively for a kk giving a meaningful dk(c)d_k(c). Requires K>264|K| > 2^{64} to make this infeasible.
  • Chosen plaintext (IND-CPA)
    Attacker submits chosen plaintexts to an encryption oracle and must not be able to distinguish encryptions of chosen messages better than a coin toss.
  • Chosen ciphertext (IND-CCA)
    Attacker has access to an encryption oracle, a decryption oracle (except for the challenge ciphertext), and a left-right oracle producing c=ek(mb)c^* = e_k(m_b) for b{0,1}b \in \{0,1\}. Wins by guessing bb. A secure scheme limits this to probability 0.5.

A block cipher encrypts a set of bits or characters at a time, whereas a stream cipher encrypts a single bit or character at a time. A stream cipher is used directly as an encryption scheme, but a block cipher is only a building block. The specific design combining a block cipher into a usable encryption scheme is its mode of operation.

Iterated Block Cipher Design

Security comes from repeated application of a round function to the block, over rr rounds. Increasing rr increases security up to a stable level.

Feistel Cipher

Named after Horst Feistel. Splits the plaintext block into halves (L0,R0)(L_0, R_0) and iterates a round function FF, keyed by kik_i, over rr rounds, swapping the final halves to produce the ciphertext.

Each encryption round:

LiRi1,RiLi1F(ki,Ri1)L_i \leftarrow R_{i-1}, \quad R_i \leftarrow L_{i-1} \oplus F(k_i, R_{i-1})

Each decryption round, using the round keys in reverse order:

Ri1Li,Li1RiF(ki,Li)R_{i-1} \leftarrow L_i, \quad L_{i-1} \leftarrow R_i \oplus F(k_i, L_i)

Design parameters of a Feistel cipher:

  • Block length nn.
  • Number of rounds rr.
  • Definition of the round function FF.
  • Key schedule generating each round key kik_i from kk.
  • Length of the secret key kk.

SP-Network

Proposed by Claude Shannon in 1945: a series of linked permutation and substitution operations. AES, the successor to DES, is based on this design, rather than the Feistel structure.

  • Diffusion
    Permutations disperse the statistical characteristics of each input bit among all output bits.
  • Confusion
    Substitutions create a complex relationship between the input and key with the output, providing the cipher’s non-linearity.

Modes of Operation

A mode of operation combines a block cipher into a usable block encryption scheme. DES was standardized with 4 modes:

  • ECB, useful for encrypting short secrets such as session keys.
  • CBC, useful for bulk data encryption.
  • OFB, useful for real-time streamed content.
  • CFB, useful for streamed content.

CTR mode, enabling parallel block encryption, was developed later.

ECB

Electronic Code Book: each plaintext block is encrypted independently.

ciek(mi),midk(ci)c_i \leftarrow e_k(m_i), \quad m_i \leftarrow d_k(c_i)

CBC

Cipher Block Chaining: chains each ciphertext block into the encryption of the next, giving every block context.

c1ek(m1IV),ciek(mici1) for i>1c_1 \leftarrow e_k(m_1 \oplus IV), \quad c_i \leftarrow e_k(m_i \oplus c_{i-1}) \text{ for } i > 1 m1dk(c1)IV,midk(ci)ci1 for i>1m_1 \leftarrow d_k(c_1) \oplus IV, \quad m_i \leftarrow d_k(c_i) \oplus c_{i-1} \text{ for } i > 1
  • A single ciphertext bit error corrupts its own plaintext block fully, plus a single bit in the next block, giving 1-block error propagation.
  • A fixed public IV (e.g. all-0) need not be transmitted. A random nonce IV must be sent alongside the ciphertext.

OFB

Output Feedback: runs the block cipher as a keystream generator, turning it into a stream cipher.

Yiek(Yi1),cimiYi,miciYiY_i \leftarrow e_k(Y_{i-1}), \quad c_i \leftarrow m_i \oplus Y_i, \quad m_i \leftarrow c_i \oplus Y_i

with Y0IVY_0 \leftarrow IV. Both encryption and decryption use eke_k, never dkd_k.

CFB

Cipher Feedback: also produces a keystream, but feeds the ciphertext itself back into the cipher input.

Ziek(Yi1),cimiZi,YiYi1ciZ_i \leftarrow e_k(Y_{i-1}), \quad c_i \leftarrow m_i \oplus Z_i^*, \quad Y_i \leftarrow Y_{i-1} \ll c_i

with Y0IVY_0 \leftarrow IV and ZiZ_i^* the leading bb bits of ZiZ_i. Decryption mirrors this using cic_i in place of mim_i.

CTR

Counter mode: like ECB, but XORs plaintext with the encryption of a counter rather than encrypting the plaintext directly.

cimiek(IVib),miciek(IVib)c_i \leftarrow m_i \oplus e_k(IV \oplus \langle i \rangle_b), \quad m_i \leftarrow c_i \oplus e_k(IV \oplus \langle i \rangle_b)

where ib\langle i \rangle_b is the bb-bit binary representation of ii.

  • Blocks can be encrypted in parallel, like ECB, since each block is independent.
  • The counter provides context, preventing the cut-and-paste and rearrangement attacks possible against ECB.
Was this helpful?