Path: blob/main/foundations/03-galois-fields-aes/connect/aes-gcm-authentication.ipynb
483 views
Connect: AES-GCM Authenticated Encryption
Module 03 | Real-World Connections
AES-GCM combines AES encryption with Galois field authentication --- two fields, one protocol.
Introduction
Encryption alone is not enough. If an attacker can modify the ciphertext and the receiver decrypts the modified version without detecting the tampering, the attacker wins. This is the malleability problem.
AES-GCM (Galois/Counter Mode) solves this by combining:
AES-CTR for encryption (confidentiality)
GHASH for authentication (integrity)
The "G" in GCM stands for Galois --- the authentication tag is computed using polynomial evaluation in GF(). This is the same kind of Galois field arithmetic from Module 03, just in a bigger field.
The GCM Construction
AES-GCM processes a message in three phases:
Derive the hash key: (encrypt a block of zeros)
Encrypt with AES-CTR:
Authenticate with GHASH: compute a polynomial in GF() evaluated at
The output is where is the 128-bit authentication tag.
where is optional associated data (authenticated but not encrypted).
GHASH: Polynomial Evaluation in GF()
The authentication in GCM uses the field constructed as:
This is the same construction as GF() in Module 03, just with a degree-128 irreducible polynomial instead of degree 8.
| Module 03 (AES bytes) | GCM (auth tags) | |
|---|---|---|
| Field | GF() | GF() |
| Modulus | ||
| Element = | 8-bit byte | 128-bit block |
| Addition = | XOR of bytes | XOR of blocks |
| Multiplication = | polynomial product mod | polynomial product mod |
Step-by-Step Toy Example: AES-GCM
Let's walk through a complete AES-GCM encryption on a toy-sized message. We'll use a simplified AES (just a single round for demonstration) so the focus stays on the GCM structure.
Phase 1: Derive the Hash Key
Encrypt a block of zeros: .
Phase 3: GHASH Authentication
GHASH computes a polynomial in GF():
This is polynomial evaluation --- the same concept as evaluating , but in GF() instead of the integers.
The inputs are the ciphertext blocks (and optionally, associated data blocks), plus a final length block.
Why Authenticated Encryption Matters
Without the authentication tag, an attacker can flip ciphertext bits and the decryption will succeed, producing a corrupted plaintext that the receiver accepts as genuine.
In CTR mode, flipping bit of ciphertext block flips bit of the corresponding plaintext block . This is called malleability --- the attacker can make targeted changes to the plaintext without knowing the key.
The GHASH tag detects this because changing even one ciphertext bit changes the polynomial inputs, producing a completely different tag.
Concept Map: Two Galois Fields, One Protocol
| Component | Field | Role |
|---|---|---|
| AES SubBytes | GF() | Byte-level non-linearity via field inversion |
| AES MixColumns | GF() | Column-level diffusion via matrix multiplication |
| AES-CTR keystream | GF() internally | Generates pseudo-random blocks for encryption |
| GHASH | GF() | Computes authentication tag via polynomial evaluation |
| Tag computation | Both | AES encrypts the GHASH output to produce the final tag |
The field arithmetic from Module 03 appears at two different scales:
GF(): inside AES, operating on individual bytes
GF(): in GHASH, operating on entire 128-bit blocks
Both are constructed the same way: .
Summary
| Concept | Key idea |
|---|---|
| AES-GCM | The gold standard for authenticated encryption in TLS 1.3, combining AES-CTR for confidentiality with GHASH for integrity |
| GHASH | Polynomial evaluation in GF(), constructed the same way as GF() but with a degree-128 irreducible polynomial |
| Two Galois fields | AES-CTR uses GF() internally (S-box and MixColumns), while GHASH uses GF() for authentication |
| Malleability without auth | CTR mode alone is malleable. Flipping a ciphertext bit flips the corresponding plaintext bit, and the receiver cannot detect it |
| Tag detects tampering | The GHASH tag catches any modification, because changing even one ciphertext bit produces a completely different polynomial evaluation |
| Same construction, different scale | GF() and GF() are both built as GF(2), with the same operations at different sizes |
The field theory from Module 03 is not just about AES bytes. It extends to 128-bit blocks, authentication tags, and the security of every HTTPS connection.
Back to Module 03: Galois Fields and AES