Authenticated Encryption, KDFs and Capstone Preparation
The theorem from Lecture 04, now proved.
reject
reject (useless)AES-GCM internals and nonce misuse resistance.
\[ \begin{aligned} &k_m \leftarrow E(k, 0^{128}) \\ &x \leftarrow (\mathcal{n} \| 0^{31} \| 1) \in \{0, 1\}^{128} \\ &x' \leftarrow x + 1 \\ &c \leftarrow \text{CTR-Encrypt}(k, x', m) \\ &d' \leftarrow \text{ZeroPad}(d, 128),\quad c' \leftarrow \text{ZeroPad}(c, 128) \\ &h \leftarrow \text{GHASH}(k_m,\; d' \| c' \| \text{length}(d) \| \text{length}(c)) \\ &t \leftarrow h \oplus E(k, x) \\ &\textbf{return } (c, t) \end{aligned} \]
Deriving keys from shared secrets.
\[ \begin{aligned} &\textbf{Extract: } t \leftarrow \text{HMAC}(\text{salt}, s) \\ &\textbf{Expand: } q \leftarrow \lceil L / \text{HashLen} \rceil \\ &\quad z_0 \leftarrow \varepsilon \\ &\quad \textbf{for } i = 1 \textbf{ to } q \textbf{ do:} \\ &\qquad z_i \leftarrow \text{HMAC}(t,\; z_{i-1} \| \text{info} \| \text{octet}(i)) \\ &\textbf{return first } L \text{ octets of } z_1 \| \cdots \| z_q \end{aligned} \]
PBKDF2 and Argon2.
\[ \begin{aligned} &\text{PBKDF2}_\text{PRF}(pw, salt, d): \\ &\quad x_0 \leftarrow \text{PRF}(pw, salt) \\ &\quad \textbf{for } i = 1, \ldots, d-1: \\ &\qquad x_i \leftarrow \text{PRF}(pw, x_{i-1}) \\ &\quad y \leftarrow x_0 \oplus x_1 \oplus \ldots \oplus x_{d-1} \in \mathcal{X} \\ &\quad \textbf{return } y \end{aligned} \]
Building the EPIC project’s core cryptographic stack.
alice_sk, alice_pk = generate_x25519_keypair()bob_sk, bob_pk = generate_x25519_keypair()shared_secret = x25519(alice_sk, bob_pk)x25519(bob_sk, alice_pk)key = HKDF(secret=shared_secret, salt=session_id, info="messaging-key", length=32)nonce = generate_random_nonce(12) (96 bits)ciphertext, tag = AES_GCM_encrypt(key, nonce, plaintext, associated_data)signature = sign(sender_sk, ciphertext || associated_data)verify(sender_pk, ciphertext || associated_data, signature)key = PBKDF2(password, salt, iterations=600000, length=32)What did we learn?
Ask now, catch me after class, or email eoin@eoin.ai
© 2026 Eoin O’Brien. All rights reserved.