CMM7XX
Symmetric Cryptography
Session 3: Stream and Block Ciphers, DES
Learning Objectives
- Differentiate the architectures of Stream and Block Ciphers.
- Analyze vulnerabilities of legacy stream ciphers (RC4) and architecture of modern equivalents (ChaCha20).
- Deconstruct the Feistel Network structure used in DES.
- Evaluate fundamental Block Cipher Modes of Operation (ECB, CBC, GCM).
- Understand attack vectors like Padding Oracles.
Task 1: Feistel Network Simulation
Timing: 45 minutes
Using Python or pen-and-paper for small 8-bit blocks:
- Define an 8-bit plaintext block and split it into $L_0$ (4 bits) and $R_0$ (4 bits).
- Define a dummy, completely non-invertible, lossy function for $f$. (e.g., $f(x) = 0$ or $f(x) = x \land K$).
- Execute one encryption round to find $L_1$ and $R_1$.
- Execute the decryption round using $L_1$ and $R_1$.
- Prove mathematically and programmatically that $L_0, R_0$ are recovered perfectly, demonstrating the power of the XOR swap mechanism.
15 Minute Break
Please return promptly for Part 2.
Part 2: Modes of Operation & Cryptanalysis
Duration: 1.5 Hours
Advanced Cryptanalysis against Block Ciphers
DES S-Boxes were designed by IBM to specifically resist these attacks:
- Differential Cryptanalysis: Analyzes how differences in input plaintexts affect differences at the output. Requires Chosen-Plaintext.
- Linear Cryptanalysis: Finds affine approximations to the action of a cipher. Developed in 1993, breaking DES faster than brute force ($2^{43}$ known plaintexts).
Modes of Operation (1)
How do we encrypt data larger than a single block?
- ECB (Electronic Codebook): Identical plaintext blocks produce identical ciphertext blocks. Preserves structural patterns. Never use.
- CBC (Cipher Block Chaining): Introduces an IV. $C_i = E_K(P_i \oplus C_{i-1})$. Provides randomization. Must be sequential.
Modes of Operation (2)
- CTR (Counter Mode): Turns a block cipher into a stream cipher. Encrypts a counter value to generate a keystream. Highly parallelizable.
- GCM (Galois/Counter Mode): Authenticated Encryption. Provides confidentiality (CTR) and integrity (universal hashing over a Galois field). Modern standard in TLS 1.3.
Introduction to Task 2
Visualizing cryptographic failure is the best way to understand modes of operation. ECB mode fails to provide "Diffusion" across multiple blocks.
We will generate the famous "ECB Penguin" to see what happens when structural data is encrypted without block chaining.
Task 2: ECB vs CBC & Padding Oracles
Timing: 50 minutes
- Download the provided uncompressed
.bmp image of the Linux Tux penguin.
- Use the OpenSSL CLI to encrypt the image using
aes-128-ecb.
- Manipulate the ciphertext file header (copy the first 54 bytes from the original) so it renders as a valid image. Observe the ciphertext visually.
- Repeat the process using
aes-128-cbc. Compare the outputs.
- Discussion: Discuss how CBC mode requires padding (PKCS#7) and how this padding can lead to a Padding Oracle Attack (Chosen-Ciphertext Attack).
Summary & Next Steps
- Block ciphers require secure Modes of Operation to handle arbitrary data lengths safely.
- Authenticated Encryption (GCM) is essential to prevent malleability attacks against modes like CBC and CTR.
Next Week: Asymmetric Cryptography (RSA and Key Management)