A block cipher operates on a fixed-length block of plaintext of bits, mapping it to a ciphertext block of the same length under a secret key , both drawn from .
For a fixed key , the encryption function is a bijection on , so it is invertible via .
Block Cipher as a PRP
A block cipher’s key design objective is to behave like a family of pseudorandom permutations (PRP) indexed by .
Large messages are divided into blocks and encrypted independently per block:
Per Kerckhoffs’s principle, and are public. Only is secret.
Attacking a Block Cipher
- Ciphertext only
Attacker has only and searches the key space exhaustively for a giving a meaningful . Requires 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 for . Wins by guessing . 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 rounds. Increasing increases security up to a stable level.
Feistel Cipher
Named after Horst Feistel. Splits the plaintext block into halves and iterates a round function , keyed by , over rounds, swapping the final halves to produce the ciphertext.
Each encryption round:
Each decryption round, using the round keys in reverse order:
Design parameters of a Feistel cipher:
- Block length .
- Number of rounds .
- Definition of the round function .
- Key schedule generating each round key from .
- Length of the secret key .
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.
CBC
Cipher Block Chaining: chains each ciphertext block into the encryption of the next, giving every block context.
- 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.
with . Both encryption and decryption use , never .
CFB
Cipher Feedback: also produces a keystream, but feeds the ciphertext itself back into the cipher input.
with and the leading bits of . Decryption mirrors this using in place of .
CTR
Counter mode: like ECB, but XORs plaintext with the encryption of a counter rather than encrypting the plaintext directly.
where is the -bit binary representation of .
- 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.