Block ciphers: DES, 3DES and AES
Concise study notes on block ciphers DES, 3DES and AES: their structure, key schedules, formulas, worked examples, common exam mistakes and practice questions.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Block ciphers are the core building blocks that engineers use to provide confidentiality for fixed-size blocks of data in real-world systems (disk encryption, TLS, VPNs). DES, 3DES and AES are historically and practically important: DES and 3DES appear in legacy systems and standards; AES is the modern standard used in almost every secure channel today.
Key ideas
Start with definitions you must know.
- Block cipher: a deterministic algorithm that maps an n-bit input block and a k-bit key to an n-bit output block, i.e. E_K : {0,1}^n → {0,1}^n, invertible for each key K. Assumes keys are secret and chosen uniformly from key space.
- Feistel network: a structure to build invertible block ciphers from a non-invertible round function. For each round i, split the state into left and right halves L_i, R_i. The round transforms as: L_i = R_{i-1}, R_i = L_{i-1} XOR f(R_{i-1}, K_i). Repeating any number of rounds gives an invertible permutation irrespective of whether f is invertible.
DES (Data Encryption Standard).
- DES is a block cipher with block size 64 bits and a 56-bit effective key (stored as 64 bits with 8 parity bits). DES uses a 16-round Feistel network. Each round applies a round function f that expands R (32 bits) to 48 bits, XORs with a round subkey (48 bits), passes result through eight S-boxes (each maps 6→4 bits nonlinearly), then a fixed permutation (P-box) to produce 32 bits.
- Important components in DES: Initial Permutation (IP) and Final Permutation (IP^{-1}) (bit reordering before and after rounds), Expansion (E) function (32→48), S-boxes S1..S8 (nonlinear substitution tables), P permutation (32-bit permutation), and key schedule: key is permuted (PC-1) to 56 bits, split to C and D (28 bits each), rotated left by 1 or 2 bits depending on round (rotation schedule r_i = [1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1]), then permuted (PC-2) to produce 48-bit round subkeys.
- DES is vulnerable to exhaustive search (56-bit keys) and to various cryptanalytic attacks; therefore retired for many purposes.
3DES (Triple DES).
- 3DES applies DES three times to increase effective security. Common modes: EDE (Encrypt with K1, Decrypt with K2, Encrypt with K3) and EEE. With keying options:
- Keying option 1: K1, K2, K3 all independent → nominal 168-bit key (but see meet-in-the-middle caveat).
- Keying option 2: K1 and K3 equal, K2 different → 112-bit security nominal.
- Keying option 3: all keys equal → equivalent to single DES.
- Practical effective security due to meet-in-the-middle attack: 3DES with three independent keys provides about 112 bits of security against known-plaintext attacks, not 168. It retains DES's 64-bit block size, so birthday-bound limits apply (≈2^32 blocks per key), and modern standards deprecate 3DES/TDEA for new encryption use.
AES (Advanced Encryption Standard, Rijndael variant chosen).
- AES is a substitution–permutation network (not Feistel) with block size 128 bits and key sizes 128, 192 or 256 bits. Number of rounds depends on key length: 10, 12, 14 respectively.
- AES represents the 128-bit block as a 4×4 byte matrix called the state. Each round (except last) performs: SubBytes, ShiftRows, MixColumns, AddRoundKey.
- SubBytes: apply an 8-bit S-box defined by multiplicative inverse in GF(2^8) (treating bytes as polynomials modulo m(x)=x^8 + x^4 + x^3 + x + 1), followed by an affine transformation.
- ShiftRows: cyclic left shifts of rows by offsets (row r shifted by r bytes).
- MixColumns: treat each column as a 4-byte polynomial over GF(2^8) and multiply by a fixed polynomial a(x)=03·x^3 + 01·x^2 + 01·x + 02 modulo x^4 + 1 (equivalently multiply by a fixed 4×4 matrix over GF(2^8)).
- AddRoundKey: XOR the state with the round subkey (128 bits).
- AES key expansion (KeySchedule): derive Nb×(Nr+1) round keys (Nb=4 words, Nr rounds) from cipher key using word operations and Rcon constants.
Describe what to draw for exam diagrams:
- For DES: draw a 64-bit input box, arrow to IP, then 16 rounds shown as pairs L_i | R_i boxes with arrows showing L_i ← R_{i-1}, R_i ← L_{i-1} XOR f(R_{i-1}, K_i). On right, show each f expanding R (32→48), XOR with K_i, S-boxes (label S1..S8), P permutation, back to 32-bit output. Label PC-1 and PC-2 on key schedule diagram and show left rotations per round.
- For AES: draw a 4×4 byte matrix labeled State, arrows showing SubBytes, ShiftRows, MixColumns (matrix multiply), AddRoundKey, repeat Nr times, and final round without MixColumns.
Formulas
Feistel round: L_i = R_{i-1}; R_i = L_{i-1} XOR f(R_{i-1}, K_i) — L_i, R_i: n/2-bit halves (bits), f: round function, K_i: subkey for round i. Unit: bits. Applies to Feistel ciphers (DES uses this with n=64, 16 rounds).
DES: block size = 64 bits — block size measured in bits; applies to DES.
DES: effective key length = 56 bits (stored as 64 bits with 8 parity bits) — key bits, unit: bits.
3DES (EDE): C = E_{K3}(D_{K2}(E_{K1}(P))) — where E_K and D_K are DES encryption/decryption under key K; P: plaintext block (64 bits); C: ciphertext block (64 bits).
AES: Nb = 4 (columns), block size = Nb·32 = 128 bits — Nb number of 32-bit words in state.
AES rounds: Nr = {10 if Nk=4; 12 if Nk=6; 14 if Nk=8} — Nk = number of 32-bit words in key (Nk = key size / 32).
MixColumns (one column): [s'0 s'1 s'2 s'3]^T = M · [s0 s1 s2 s3]^T — where M = [[02,03,01,01],[01,02,03,01],[01,01,02,03],[03,01,01,02]] and multiplication is in GF(2^8) modulo m(x)=x^8 + x^4 + x^3 + x + 1. s_i are bytes (unit: 8-bit values). Applies in AES MixColumns step.
S-box: S(b) = A · b^{-1} XOR c — where b^{-1} is multiplicative inverse in GF(2^8) (define 0^{-1}=0), A is an 8×8 binary matrix, c is an 8-bit constant vector. Applies in AES SubBytes.
Key schedule rotation in DES: C_i = ROTL(C_{i-1}, r_i), D_i = ROTL(D_{i-1}, r_i) — r_i is 1 or 2 depending on round i.
Worked examples
Example 1 — DES parity bits (extract 56-bit key). Given 64-bit key (hex): 0x133457799BBCDFF1 (a classic example). Steps:
- Write bits and partition into 8 bytes. Each byte's least-significant bit is parity (odd parity in DES): each byte must have odd number of 1s. To get effective 56-bit key, drop each parity bit (one per byte). Formula: K_56 = PC-1(K_64) which selects 56 bits.
- After applying PC-1 (a fixed table), you obtain two 28-bit halves C0 and D0. (Do not attempt manual bit extraction here in exam; state that PC-1 drops parity bits and permutes.) Final: effective key length = 56 bits.
Example 2 — 3DES (EDE) symbolic trace (two-key mode K1,K2 with K3=K1): Encrypt P:
- First DES encryption: X1 = E_{K1}(P).
- DES decryption with K2: X2 = D_{K2}(X1).
- DES encryption with K1: C = E_{K1}(X2). Conclude: With K3=K1 this gives compatibility with single DES when K1=K2; security roughly 112 bits against known-plaintext due to meet-in-the-middle.
Example 3 — Toy Feistel cipher (demonstrates DES structure): Parameters: 8-bit block, split into 4-bit L and R. Two rounds. Define f(R,K) = (R + K) mod 16 (4-bit addition). Keys K1=3, K2=7. Plaintext P = 0xA7 (binary 1010 0111) → L0=0xA (1010 = 10), R0=0x7 (0111=7). Round 1:
- L1 = R0 = 7.
- R1 = L0 XOR f(R0,K1) = 10 XOR (7+3 mod16 = 10) = 10 XOR 10 = 0. Round 2:
- L2 = R1 = 0.
- R2 = L1 XOR f(R1,K2) = 7 XOR (0+7=7) = 7 XOR 7 = 0. Ciphertext (combine L2||R2) = 0x00 (0000 0000). Show how decryption uses same structure with subkeys in reverse order; verify invertibility. Final ciphertext: 0x00.
Note: this toy example shows the Feistel property: decryption uses same f and round keys reversed.
Common mistakes
- Saying 3DES with three keys gives 168-bit effective security without mentioning meet-in-the-middle — practical attack reduces security.
- Mixing up AES rounds: for AES-128 use 10 rounds, AES-192 use 12, AES-256 use 14.
- Thinking AES is a Feistel cipher — it is not; it uses a byte-oriented substitution–permutation network.
- In MixColumns, treating multiplication as integer multiply rather than GF(2^8) polynomial multiply modulo the AES polynomial.
For your exam
Question types you will see: definitions (e.g., define S-box, Feistel network), short notes (components of DES, AES round functions), derivations (show why Feistel is invertible), diagrams (draw DES round and key schedule), algorithm traces (trace toy Feistel/DES round on small input), and numeric/cryptanalytic reasoning (compute key lengths, explain meet-in-the-middle attack conceptually). What full-marks answers include:
- Precise definitions (bold the term once), assumptions, and the exact round equations.
- For DES/AES: name exact block/key sizes, number of rounds, and describe the steps and transformations in order.
- For diagrams: label bit widths (e.g., 64→32|32), show PC-1/PC-2 on key schedule, show AES state as 4×4 bytes and indicate which bytes move in ShiftRows.
- For derivations: if asked why Feistel is invertible, show algebraic inversion using the round equations.
Quick check
- What is the DES block size and effective key size?
- How many rounds does AES-256 use?
- Write the Feistel round equations. Answers: 1) DES block size = 64 bits, effective key size = 56 bits. 2) AES-256 uses 14 rounds. 3) L_i = R_{i-1}; R_i = L_{i-1} XOR f(R_{i-1}, K_i).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?