Advanced Encryption Standard (AES)
Modes of Operation

Because block ciphers work on fixed-size blocks, they are combined with modes of operation to handle arbitrary-length data. Here are the most common ones with their associated potential flaws.
| Mode Name | Description | Common Weakness in CTFs |
|---|---|---|
| ECB | Each block encrypted independently. | Leaks patterns, identical plaintexts -> identical ciphertexts. |
| CBC | XORs each block with previous ciphertext. | Padding oracle attacks via IV or padding error oracle, Bit-flip. |
| CTR | Turns block cipher into stream cipher via counter. | Key/nonce reuse causes keystream leakage. |
| GCM | Authenticated encryption (AEAD). | Nonce reuse, Forbidden Attack. |
| IGE | XORs each block with previous ciphertext AND plaintext | Padding oracle. |
| CFB | Very similar to OFB | ZeroLogon Vulnerability (CFB-8) |
| OFB | XORs each block with repeated encryptions of IV | Symmetry + Encryption / Decryption oracle |
Attacks
Linear SBox
- StackExchange - How to find linear equations of a SBox?
- StackExchange - Consequences of AES without any one of its operations
- StackExchange - Linear AES : expression of K in AES(P) = AP+K
Out of the four main operations of the AES cipher, the SubBytes operation is the only non-linear operation.
If the S-box is poorly constructed and linear, the entire cipher becomes linear (and more precisely, affine).
In such a case, the encrypted message \(c\) can be expressed as:
\[ c = A \cdot p + k \]where:
- \(k\) is a vector dependent on the key,
- \(p\) is the plaintext message,
- \(A\) is a constant matrix dependent only on the cipher’s operations.
Now, in a white-box scenario, because you know the implementation of the AES cipher, you can calculate the \(i\)-th column of the matrix \(A\) by choosing
\[ \begin{aligned} p_i &= (0, 0, \dots, \overbrace{1}^{i\text{th}}, \dots, 0, 0) \\ k_i &= (0, 0, \dots, 0) \end{aligned} \]so that you have
\[ c_i = A \cdot p_i = A_i \]with \(A_i\) the \(i\)-th column of the matrix \(A\).
Here is a Sage code to analyze the linearity of an S-box using Gröbner basis.
| |
Fault attack
- GitHub - Differential fault analysis framework for AES128
- Differential Fault Analysis of the Advanced Encryption Standard using a Single Fault
- A Differential Fault Attack Technique against SPN Structures, with Application to the AES and KHAZAD
- Differential Fault Analysis on White-box AES Implementations
TODO