Chapter 3 · Lectures 8 to 9

Key Exchange

Key exchange lets two parties establish a secret over a public channel. This chapter moves from Diffie-Hellman to authenticated protocols, the Canetti-Krawczyk model, SIGMA, HMQV, key derivation, password protocols and TLS 1.3.

74 slides 5 stages 3 labs 8 exercises Source: 03_Crypto_101_Key_Exchange.pdf
How this chapter maps onto the lectures

Lecture 8 (16/10/25) is sections 1 to 9: the key exchange problem, Diffie-Hellman, man-in-the-middle attacks, authenticated key exchange, the Canetti-Krawczyk model, authenticators and the signature-based protocols ending with Hashed MQV (HMQV). Lecture 9 (21/10/25) is sections 10 to 14: key derivation with HKDF, passwords, Bloom filters, password-authenticated key exchange and TLS. Study plans for each: Lecture 8, Lecture 9.

Section 1The Key Exchange Problem

Lecture 8.

Every construction in Chapters 1 and 2 assumes a key the parties already share. Key exchange removes that assumption: Alice and Bob each want the same key $k$. The only communication channel available is public, while an adversary watches every message.

The adversary controls the channel, so she can read, reorder, drop and inject messages. Every protocol in this chapter is scored against one checklist of four items:

Authentication is the item most first attempts get wrong. Sections 2 to 9 and section 14 reuse this list for every protocol they present.

The chapter treats three adversaries in increasing strength. A passive eavesdropper only reads the transcript, and Diffie-Hellman resists her (section 2). An active adversary also rewrites messages, which is the setting of authenticated key exchange (sections 3 to 9). A quantum computer breaks the discrete-logarithm assumption under both, and Chapter 4 covers the post-quantum replacement.

Takeaway

Key exchange converts a public channel and some long-term authentication material into a fresh secret key. Secure-channel designs from IPsec (Internet Protocol security) to TLS (Transport Layer Security) build on that conversion.

Section 2Diffie-Hellman Key Exchange

Lecture 8.

The standard intuition is paint mixing. Alice and Bob start from the same public yellow paint. Alice stirs in a private red and Bob a private blue, then they swap pots. Each adds their own private color to the pot they received, and both arrive at the same final color. An eavesdropper who saw the two swapped pots cannot separate mixed paint back into its ingredients. The number-theoretic protocol replaces unmixing paint with a hard computation.

Take the prime $p = 23$ and the generator $g = 5$. Alice picks the secret $a = 4$ and sends $A = g^{a} \bmod p = 5^{4} \bmod 23 = 4$. Bob picks the secret $b = 3$ and sends $B = g^{b} \bmod p = 5^{3} \bmod 23 = 10$. Both then compute the shared secret

$$K_{\text{Alice}} = B^{a} \bmod p = 10^{4} \bmod 23 = 18, \qquad K_{\text{Bob}} = A^{b} \bmod p = 4^{3} \bmod 23 = 18.$$

Both hold $18$. Every value that crossed the channel is public. What each party can see:

AliceBobEve
knows$p = 23$, $g = 5$, her secret $a = 4$, the public value $B = 10$$p = 23$, $g = 5$, his secret $b = 3$, the public value $A = 4$the transcript $p = 23$, $g = 5$, $A = 4$, $B = 10$
computes$K = 10^{4} \bmod 23 = 18$$K = 4^{3} \bmod 23 = 18$nothing without solving a discrete logarithm
does not know$b$$a$$a$, $b$ and $K$

At this toy size Eve can try every exponent. Protocol groups make that search infeasible. The general protocol runs in a cyclic group $\mathbb{G}$ of prime order $q$ with generator $g$, for example a prime-order subgroup of $\Z_p^{*}$ with $q \mid p-1$. Alice picks $x \getsr \Z_q$ and sends $X = g^x$; Bob picks $y \getsr \Z_q$ and sends $Y = g^y$; both compute

$$K = Y^x = X^y = g^{xy}.$$

Security against a passive adversary follows from the Decisional Diffie-Hellman (DDH) assumption. If the triple $(g^x, g^y, g^{xy})$ is indistinguishable from $(g^x, g^y, g^z)$ for fresh $z \getsr \Z_q$, the public transcript gives no way to tell the session key from a random group element.

Against the section 1 checklist, agreement holds because both parties compute $g^{xy}$. Secrecy holds against a passive eavesdropper under DDH. Authentication and key confirmation are absent, since nothing in the transcript names a peer.

The protocol keeps no long-term secret: $x$ and $y$ are used once and erased. That erasure gives perfect forward secrecy: once the session key is destroyed there is no record from which it can be recovered, so a later compromise of long-term keys cannot decrypt past sessions that used no long-term keys. One caveat applies once authentication is added: ephemeral Diffie-Hellman gives forward secrecy only when the surrounding authenticated protocol does not rest on a recoverable static DH secret. This is one reason ephemeral Diffie-Hellman remains in TLS 1.3.

Common mistake. Forward secrecy protects keys stored on disk. The guarantee is that each session's key-exchange secrets are erased after use: an attacker who records ciphertext today and steals the server's long-term key tomorrow still cannot decrypt the recording.

Group size is a real parameter choice. Logjam precomputed a 512-bit prime in about a week on many cores, after which individual discrete logs fell in about a minute, and a 1024-bit precomputation is estimated near $100M. Current recommendations are elliptic-curve groups, or classical groups of at least 2048 bits.

Worked number. An X25519 public key is 32 bytes and gives about 128 bits of security: brute force needs roughly $2^{128}$ curve operations. Finite-field Diffie-Hellman needs a 3072-bit prime, a 384-byte modulus on the wire, for a comparable margin.

Takeaway

Plain Diffie-Hellman resists a passive eavesdropper under DDH and gives perfect forward secrecy for free. It authenticates nobody. A secure channel needs the authenticated variants of sections 3 to 9.

Section 3The Man-in-the-Middle Attack

Lecture 8.

Because the public values $g^x$ and $g^y$ carry no identity, an active adversary can replace each of them with one of her own. Eve picks $x', y' \getsr \Z_q$. When Alice sends $g^x$, Eve forwards $g^{y'}$ to Bob; when Bob sends $g^y$, Eve forwards $g^{x'}$ to Alice. Alice then computes $(g^{y'})^x = g^{xy'}$, which Eve also computes as $(g^x)^{y'}$. Bob computes $(g^{x'})^y = g^{x'y}$, which Eve computes as $(g^y)^{x'}$. Eve shares one key with Alice and another with Bob, and neither party sees anything unusual. She decrypts every subsequent message, reads or modifies it, and re-encrypts it toward the other side.

PartyExpected peerActual peerResulting key
AliceBobEve$g^{xy'}$, which Eve also computes as $(g^x)^{y'}$
BobAliceEve$g^{x'y}$, which Eve also computes as $(g^y)^{x'}$

With the lab preset $p = 29$ the two keys are $27$ and $23$, while the honest key $16$ is never established. On the checklist, the attack breaks authentication and agreement at once: each party names the wrong peer. The two outputs differ.

What went wrong. Logjam (2015) applied this idea to TLS: a man in the middle rewrote the handshake to force weak 512-bit Diffie-Hellman parameters and recovered the session keys. The lesson is that a protocol must authenticate its own negotiation, so such rewrites fail.

Slide 6 states the fix: authenticated messages. Long-term authentication keys (master keys) sign or tag the exchange. The session key is the fresh output of it. Station-to-station, covered in section 7, is the classic authenticated repair. Each party signs the two public Diffie-Hellman values and encrypts the signature under the shared key itself.

Lab

Man-in-the-Middle on Small Diffie-Hellman Parameters

Pick a prime, a generator and the four secrets, then watch the honest key and the two keys Eve establishes. The preset $p=29$ matches the exercise below; the preset $p=23$ matches the animation. All arithmetic is exact BigInt modular exponentiation.

·honest key
·Alice with Eve
·Bob with Eve
Takeaway

An unauthenticated Diffie-Hellman exchange gives Eve a key with each party and full access to the traffic. No parameter choice prevents this; authentication does.

Section 4Authenticated Key Exchange, and Two Failed Attempts

Lecture 8.

Authenticated key exchange establishes a common secret with authentication attached. The parties hold previously established authentication keys, called master keys. Slide 7 lists the requirements in the vocabulary of the section 1 checklist:

The first attempt signs the ephemeral public value alone. Alice sends $A, X, S(sk_A, X)$ and Bob sends $B, Y, S(sk_B, Y)$, after which they compute $K = Y^x = X^y$. Replay breaks it. If Eve ever obtains a triple $(x, g^x, S(sk_A, X))$, she sends it to Bob and impersonates Alice without learning $sk_A$, so ephemeral leakage turns into long-term impersonation and the attempt fails authentication.

The second attempt signs the whole transcript. Alice sends $A, X$; Bob replies with $B, Y, S(sk_B, X \| Y)$; Alice finishes with $S(sk_A, X \| Y)$. The signatures cover both public values, so replay of a single value no longer works.

The identity-misbinding attack breaks it anyway. Eve holds her own signing key $sk_E$ and runs two parallel sessions, relaying Alice's public value into Bob's session and Bob's reply back into Alice's.

#Session 1, Alice names BobSession 2, Eve names herself to Bob
1Alice $\to$ Eve: $A, X$Eve $\to$ Bob: $E, X$ (Alice's value relayed)
2Eve $\to$ Alice: $B, Y, S(sk_B, X \| Y)$ (relayed)Bob $\to$ Eve: $B, Y, S(sk_B, X \| Y)$
3Alice $\to$ Eve: $S(sk_A, X \| Y)$ (Eve drops it)Eve $\to$ Bob: $S(sk_E, X \| Y)$ (Eve signs the same string)
output$K = Y^x$, recorded peer Bob$K = X^y$, recorded peer Eve

The signed string $X \| Y$ is the same in both runs, so both signatures verify and the identities come out misbound. Alice accepts a key as shared with Bob, while Bob accepts the same key as shared with Eve. Eve never learns $K$; Bob simply attributes to Eve whatever Alice sends under that key. On the checklist, secrecy and agreement on the key value survive, and authentication is the item that fails.

What went wrong. The Triple Handshake attack (2014) showed the same danger in TLS: three sessions ended up sharing one master secret while disagreeing about the peer. TLS 1.3 hashes the whole handshake transcript into every derived key, so mismatched sessions derive different keys.

Takeaway

Signing the transcript fixes replay but leaves identities outside the signature. The binding between a key and the peer holding it must itself be signed.

Section 5The ISO 9796 Defense

Lecture 8.

The repair is to include the peer identity under the signature. Alice sends $A, X$; Bob replies with

$$B, Y, S(sk_B, X \mid Y \mid A),$$

and Alice finishes with $S(sk_A, X \mid Y \mid B)$. The session key is then derived with the identities inside the hash:

$$K = Y^x = X^y, \qquad k = \Hash(A \mid B \mid X \mid Y \mid K).$$

Eve cannot forge $S(sk_E, X \mid Y \mid A)$ for Alice's identity, because she does not hold $sk_A$. A parallel session under Eve's identity produces a different signed string, so the misbinding run fails at verification. The slides state that this protocol avoids the previous attack and can be proven secure.

One naming note. The slides call the protocol ISO 9796 and the syllabus prints ISO 9697. The standard family for entity authentication with public keys is ISO/IEC 9798-3, which describes this mechanism.

Takeaway

Bind the peer identity into the signed transcript and into the key derivation. The same two bindings reappear in SIGMA, HMQV and TLS 1.3.

Section 6The Canetti-Krawczyk Model

Lecture 8.

The Canetti-Krawczyk model gives a security definition for key exchange protocols in the setting where they are deployed. The desiderata on slide 12:

The setting is a two-party protocol run in a multi-party world. Multiple executions run concurrently. Each run at a party is a session named $(A, s_A)$ or $(B, s_B)$, where $B$ is the intended peer of Alice's session. The session id is $(A, s_A, B, s_B)$, and two sessions with corresponding names, such as $(A, s_A, B, s_B)$ and $(B, s_B, A, s_A)$, are matching. A completed session outputs its session id and its session key.

The adversary controls every unauthenticated channel. She monitors, modifies and schedules traffic, and interleaves sessions at will. Beyond network control she has two query types, and exposure is defined through them.

QueryInformation revealedWhy it exposes a session
Corrupt a partythe party's long-term secrets and stored statethe authentication material behind that party's sessions is known
Learning query on a sessionshort-term values, including the session keythe key the game is meant to protect is directly revealed

A session is exposed if its owner was corrupted or if the adversary issued a learning query for it.

Definition: CK security

Completed matching sessions output the same key. For any unexposed test session chosen by the adversary, the adversary receives either the real session key or a fresh random key and must not distinguish the two cases. Key confirmation can be added to the definition. Session keys must never be used as part of the key exchange protocol itself; TLS 1.2 is cited as the counterexample.

The definition catches the known failures. Impersonation breaks it, because an adversary who impersonates Bob without corrupting him learns a key for an unexposed session. Session independence is required, because the adversary must not break one session from the key of another. Identity misbinding breaks it through the test query: if Eve forces two non-matching sessions with outputs $(A, B, K)$ and $(B, E, K)$, she selects one as the test session, exposes the other and compares keys.

Takeaway

CK turns "the protocol is secure" into a game with named sessions, a network adversary and a test key. Every protocol in the rest of the lecture is judged by that game.

Section 7Authenticators, SKEME and Station-to-Station

Lecture 8.

CK analyzes protocols directly; authenticators give a modular route. Start in an idealized model where channels are authenticated and the adversary is passive everywhere else, so plain Diffie-Hellman is trivially secure. An authenticator is a protocol compiler that turns a protocol secure in the authenticated model into one secure in the unauthenticated model.

Signature Authenticator

The signature authenticator sends $A, M$, then $B, N$, then $A, S(sk_A, M \mid N \mid B)$. The nonce $N$ blocks replay. The guarantee is that if Bob believes he received $M$ from Alice, then Alice sent $M$ to Bob. The slides note that this authenticator implies CK security of the ISO 9796 protocol.

Encryption Authenticator

The encryption authenticator replaces the signature. Bob sends $B, \Enc(pk_A, k_B)$ for a fresh random key $k_B$, and Alice replies with $M, T(k_B, M \| B)$. Only Alice can decrypt the ciphertext, so a valid tag convinces Bob that Alice participated. The first message of the ideal protocol can be dropped in this compilation.

What went wrong. In 1998 Daniel Bleichenbacher showed that a server answering differently for malformed RSA padding becomes an oracle that recovers the transported secret. The attack plagued RSA key transport until TLS 1.3 removed it.

SKEME

SKEME, used in IKEv1 (version 1 of the Internet Key Exchange protocol), applies the encryption authenticator to Diffie-Hellman. The parties exchange $X = g^x$ and $Y = g^y$, encrypt random keys $k_A$ and $k_B$ under each other's public keys, tag the exchanged values with those keys, and derive $k = \Hash(A \mid B \mid X \mid Y \mid K)$ from the Diffie-Hellman value.

Identity protection is a design pressure on IKE. Hiding identities matters against probing attacks and for location privacy of roaming users, and typically only one identity can be hidden against an active adversary. SKEME with encrypted identities does this, at the cost of requiring Alice to know Bob's public key beforehand.

STS

The station-to-station protocol takes another route: encrypt the identity and a signature under the Diffie-Hellman key $K$ itself, proving possession of $K$. The slides show that STS is insecure if Eve can register $pk_A$ as her own key, at least in the variant where the identity is in the clear. Replacing signatures with Message Authentication Codes (MACs) under $K$ still needs the key bound to the peer identities. That requirement leads directly to SIGMA.

Takeaway

Authenticators separate the key agreement part from the authentication part. SKEME is the encryption-authenticator compilation of DH, and STS shows what happens when the authentication is tied to $K$ without binding identities.

Section 8SIGMA

Lecture 8.

SIGMA keeps the Diffie-Hellman exchange and changes what gets signed. In the basic version, Bob sends $B, Y, S(sk_B, X \mid Y), T(k', B)$ and Alice replies with $S(sk_A, X \mid Y), T(k', A)$. The signature covers the two public values, while the identity itself is tagged with a separate key $k'$ derived from $K$. The session key is again $k = \Hash(A \mid B \mid X \mid Y \mid K)$.

SIGMA satisfies every item in the section 1 checklist. The signatures over $X \mid Y$ authenticate the peers against an active adversary, the tags $T(k', A)$ and $T(k', B)$ confirm that the peer holds a key derived from $K$. The identities inside the final hash keep the two sides agreeing on one session.

SIGMA-I protects the initiator. Both identities are encrypted under a further derived key $k''$. Bob's identity is protected against passive attackers, and Alice's identity is protected against active attackers. SIGMA-R reverses the order so that Bob does not reveal his identity before checking who is talking to him; Bob's identity is protected against active attackers and Alice's against passive attackers.

The slides caution that the description is simplified and omits context and negotiation data. SIGMA can be proved secure in the CK model, although no modular proof through authenticators is known. It is used in IPsec (Internet Protocol security) and appears inside TLS 1.3 (Transport Layer Security; section 14).

Takeaway

SIGMA signs the DH transcript and tags identities with derived keys. The two variants choose which identity survives an active adversary.

Section 9MQV (Menezes-Qu-Vanstone) and Hashed MQV (HMQV)

Lecture 8.

Although the ISO 9796 style works, every exchange carries signatures and certificates. Implicit authentication asks whether authentication can be obtained without sending any signature or tag: the ability to compute the session key itself serves as proof of identity. The cost questions are communication, computation and the resulting security level.

The slides first discard two natural attempts. Taking $k = \Hash(g^{ay}, g^{xy})$ lets an adversary who learns one session key derive keys for other sessions. Taking $k = \Hash(g^{ay}, g^{xy}, g^x, g^y)$ lets an adversary who knows Bob's long-term $b$ impersonate Alice to Bob. The target is security unless the pair $(a, x)$ or the pair $(b, y)$ leaks.

MQV starts from the idea $K = g^{(a+x)(b+y)}$, with long-term keys $A = g^a$, $B = g^b$ and ephemeral values $X = g^x$, $Y = g^y$. The basic form is insecure: Eve can send a substituted value $X^{*} = g^{x^{*}} / A$. The key collapses to a value Bob also computes, so Eve can force matching keys across sessions. The repair is to use

$$K = g^{(x + da)(y + eb)},$$

where $d$ and $e$ are values Eve cannot control together with the corresponding public values.

Hashed MQV instantiates the repair with hashes. Alice computes $d = \Hash(X \| \mathrm{Bob})$ and Bob computes $e = \Hash(Y \| \mathrm{Alice})$, then

$$K_{\text{Alice}} = (Y B^{e})^{x + da}, \qquad K_{\text{Bob}} = (X A^{d})^{y + eb}.$$

Both sides obtain $K = g^{(x+da)(y+eb)}$. The session key is $k = \Hash(K)$. No signatures are exchanged. Each party performs one full exponentiation and one half-length exponentiation. The slides also give a signature reading: $(Y B^{e})^{x+da}$ acts as a signature by Alice on $X \| \mathrm{Bob}$. The matching term acts as Bob's signature on $Y \| \mathrm{Alice}$.

On the checklist, agreement holds by the algebra of the previous display, and authentication is implicit in the key computation itself, with the hashes $d$ and $e$ binding the peer name into it.

Proof provenance

The signature reading is formalized by Exponential Challenge-Response (XCR) and Dual XCR signatures: slide 37 reduces HMQV in the CK model, with $\Hash$ as a random oracle (an idealized hash that returns a fresh random answer to each new query), to unforgeability of Dual XCR, then to XCR, then to Computational Diffie-Hellman (CDH). HMQV is standardized by ANSI/ISO and IEEE and is also used by the NSA.

Takeaway

HMQV obtains implicit authentication by hashing the peer identity into the exponent. The hash binds the ephemeral value, the long-term key and the peer name into one group element.

Section 10Key Derivation and HKDF (HMAC-Based Extract-and-Expand Key Derivation Function)

Lecture 9.

A key derivation function turns an imperfect source of randomness into one or more random keys. The Diffie-Hellman value $g^{xy}$ is the typical source. Although it is secret, it is not uniform over bit strings, so it must not be used directly as a key. A naive treatment applies a hash once, as in $k = \Hash(g^{xy})$, and derives further keys by hashing again with context strings. The slides point out the flaw: no concrete hash is a random oracle, and Merkle-Damgård hashes admit length extension, so from $\Hash(g^{xy} \| A)$ one can compute $\Hash(g^{xy} \| B)$ whenever $A$ is a prefix of $B$.

Common mistake. The Diffie-Hellman shared secret is used directly as the session key. TLS 1.3 instead runs it through the HMAC-based Extract-and-Expand Key Derivation Function (HKDF), producing separate labeled keys for encryption, integrity and each direction of traffic.

HKDF separates the two jobs. Extract concentrates the dispersed entropy of the source into one fixed-length pseudorandom key, taking the source $K$ and a salt $s$. Expand takes that key, a context string called info and an output length, and derives as many context-bound keys as needed. The extract step is a randomness extractor; the expand step is a Pseudorandom Function (PRF). The salt is not secret and can be reused across exchanges.

$$PRK = \mathrm{HMAC}(salt, IKM),$$ $$T(i) = \mathrm{HMAC}(PRK, T(i-1) \mid info \mid i), \qquad T(0) = \epsilon,$$ $$OKM = \text{first } L \text{ bytes of } T(1) \mid T(2) \mid \cdots$$

The practical instantiation uses A Hash-Based Message Authentication Code (HMAC) for both steps. HKDF is standardized in RFC 5869 and appears in TLS 1.3 and WhatsApp.

The lab below reproduces RFC 5869 case 1, which doubles as a worked DH-to-traffic run. The Diffie-Hellman shared secret plays the role of Input Keying Material (IKM), here as 22 bytes of 0x0b, the salt is 000102...0c, and extract gives

PRK = 077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5

Two expand calls with different info labels then derive two distinct traffic keys:

info labellengthoutput key
client write key16 bytes46332297ba72d3307716184509ac7549
server write key16 bytes0e67eea0a1a708207e06536bf30d7d4e

Both keys come from the same PRK. Each is bound to its own label. Expanding the same PRK under a different info string gives an unrelated output.

Worked number. TLS 1.3 sizes these outputs. From one traffic secret, the label key yields a 16-byte key for the Advanced Encryption Standard in Galois/Counter Mode; the label iv yields a 12-byte base initialization vector, XORed with the 64-bit record sequence number to form each per-record nonce.

Why HMAC

The slides justify the HMAC instantiation through keyed Merkle-Damgård and Nested MAC (NMAC): NMAC with independent keys is a PRF if the compression function is a PRF, and HMAC derives both NMAC keys from one key.

HKDF is the wrong tool for passwords. It has no iteration cost and cannot slow an offline dictionary attack; the iterated password constructions of section 13 exist for that job.

The applications on slide 44 show why both roles matter. IPsec uses $k = \mathrm{HKDF}(\text{nonces}, g^{xy})$ with the protocol nonces as salt; if the nonces are public the analysis needs HKDF as an extractor, and if they are secret, as in SKEME, as a PRF. TLS 1.3 resumption uses $k = \mathrm{HKDF}(k_i, g^{xy})$ and again needs both views depending on whether the resumption key is revealed.

Lab

HKDF-SHA256 Extract and Expand

Run the exact HKDF construction from RFC 5869 with SHA-256. Enter text or hex bytes, change the salt, info or output length and read the PRK and OKM. The RFC buttons reproduce the published test vectors.

·PRK length
·OKM length
Takeaway

Extract first, then expand. The salt makes the extractor role work on public context. The feedback expansion makes the PRF role produce any number of independent keys.

Section 11Passwords and Entropy

Lecture 9.

A password is a string of symbols from a finite alphabet, equivalently a bit string. It must be stored securely. Its two standard uses are deriving a cryptographic key and authenticating a user. The attacks on slide 47:

The server can throttle online guessing by limiting failed attempts and slowing the response after each failure, while avoiding a denial of service against the real user. Offline guessing cannot be detected once the verifier has leaked. The attacker chooses the resources. The only defense the user controls is the entropy of $\pi$.

Definition: password entropy

For a random variable $X$ over an alphabet $\{a_0, \dots, a_n\}$ with probabilities $p_i$, the average information in bits per symbol is

$$H(X) = -\sum_{i=0}^{n} p_i \log_2 p_i,$$

with maximum $\log_2 n$ for the uniform distribution.

For 7-bit ASCII there are 95 printable characters, so uniform passwords carry $\log_2 95 = 6.57$ bits per character, and 128 bits of security requires roughly 20 characters. Restricting to upper and lower case letters plus digits gives $\log_2 62 = 5.95$ bits per character, requiring 22 characters. Passphrases are measured by the entropy rate of the language; the slides give Italian at about 3.15 bits per character for single symbols, 2.22 for pairs and 1.87 in the limit, which means about 69 characters of Italian text for 128 bits.

Those rates hold for passwords drawn uniformly from the alphabet, as a generator would draw them. Human-chosen passwords carry less entropy than the alphabet size suggests, because users pick from a small predictable subset, so their strength is estimated from leaked-password studies; alphabet size alone does not measure it.

Users choose poorly. The Purdue study on slide 53 found that 42% of passwords in the sample had length 8, and among 69 million Yahoo passwords, 1.1% of users picked the same password. Computer-generated passwords are hard to remember; periodic server guessing checks are expensive and annoying; the practical middle ground is checking passwords as entered against simple acceptability guidance.

Takeaway

Entropy per symbol times length is the only quantity an offline attacker respects. Alphabet size and language predictability set the rate; the user sets the length.

Section 12Bloom Filters for Password Checking

Lecture 9.

A server that checks passwords against a dictionary $\mathcal{D}$ faces a tradeoff between accuracy and the time and memory needed to store and query $\mathcal{D}$. A Bloom filter compresses the dictionary into a bit table. Take $k$ hash functions $\Hash_i$ with values in $[0, N-1]$ and set $N = 2^m$. Create a table $T$ of $N$ bits. For every word $w \in \mathcal{D}$, compute $y_i = \Hash_i(w)$ and set $T[y_i] = 1$. To test a proposed password $\pi$, reject it if $T[\Hash_i(\pi)] = 1$ for every $i \in [k]$.

The filter has false positives and no false negatives. If $\pi \in \mathcal{D}$, all $k$ of its bits were set at insertion, so it is always rejected. If $\pi \notin \mathcal{D}$, it may still be rejected, because all $k$ positions may have been set by other words. With $D = |\mathcal{D}|$, the probability a given bit is still zero is

$$q = \left(1 - \frac{1}{N}\right)^{kD} \approx e^{-kD/N},$$

and the false positive rate is

$$p = (1 - q)^k \approx \left(1 - e^{-kD/N}\right)^k.$$

For a fixed target false positive rate, the optimal parameters are $k \approx -\log_2 p$ and $N \approx -1.44 \, D \log_2 p$. The filter never stores the dictionary itself, which also makes it attractive when the table leaks: a leaked Bloom filter reveals membership only probabilistically.

Lab

A 64-Bit Bloom Filter Against a Weak-Password Dictionary

The dictionary has six entries and the filter uses $N=64$ bits with $k=3$ probes. Query a password and inspect the bit table, the probe positions and the verdict. Try a dictionary word, the known false positive and an absent word.

·verdict
·probe positions
·bits set
Takeaway

A Bloom filter trades a controlled false positive rate for a small bit table. For password rejection, a false positive only inconveniences the user; a stored dictionary would hand the attacker the exact list.

Section 13Password Storage, Password-Based Encryption and Password-Authenticated Key Exchange (PAKE)

Lecture 9.

Password Storage

A server never stores $\pi$ itself. It stores a verifier $y = f(\pi, z)$ with a public salt $z$ and a deliberately slow public $f$. The server checks a guess $\pi'$ by testing $y = f(\pi', z)$. The salt separates users, so one rainbow table (a precomputed table of password hashes) does not attack every account at once. The cost of $f$ sets the price of each offline guess once the verifier leaks. The adversary is assumed to hold the salt and $f$.

Password-Based Encryption

Password-based encryption turns a low-entropy password into a key for encrypting a message. The PKCS #5 (Public-Key Cryptography Standard number 5) construction on slide 57 chooses an 8-byte salt, iterates the hash $c$ times with $K = \Hash^{c}(\pi \| \mathrm{salt})$, sets $C = K \oplus M$ and outputs $(\mathrm{salt}, C)$, with $c = 10000$ as the example. The hash chain slows offline attacks by the factor $c$.

The remaining leak is structure. If step 2 of decryption produces recognizable text only for the right password, the attacker knows immediately which guess worked. Honey encryption addresses this by arranging that every plausible password decrypts to a plausible-looking message, so the adversary cannot distinguish the real plaintext from decoys.

PAKE

Authenticated key exchange so far required a public-key infrastructure. Password-authenticated key exchange replaces the infrastructure with a shared password. Its specific guarantee is that an adversary who records a full transcript cannot test password guesses offline, since verifying a guess would require a fresh interaction with a live party. Encrypted Key Exchange is the example on slide 60: Alice sends $C_A = \Enc(\pi_{AB}, g^x)$ and Bob sends $C_B = \Enc(\pi_{AB}, g^y)$, each decrypts with the shared password and computes $k = \Dec(\pi_{AB}, C)^{x}$ or the matching value. The instantiation uses an ideal cipher for $\Enc$ and hashes the transcript with a random oracle.

Standardization took decades from 1982 onward; today PAKE appears in iCloud and in Radio-Frequency Identification (RFID) authentication. The TLS 1.3 pre-shared key mode of section 14 is a PAKE in general only when the PSK itself comes from a PAKE exchange. On its own it resumes from a high-entropy PSK, and if a low-entropy password is used as the PSK, an attacker who recorded the handshake can derive the Finished key for each guess and test it offline against the transcript.

Takeaway

Salt and stretching make password-derived keys expensive to attack offline. PAKE then lets a password authenticate a key exchange without letting an offline attacker test guesses against a transcript.

Section 14TLS and TLS 1.3

Lecture 9.

Transport Layer Security applies the chapter's key-exchange mechanisms to a secure channel. The handshake yields keys for confidentiality and authenticity. A record layer secures traffic under those keys, with authentication applied usually on the server side. The client-server scenario on slide 62 is the everyday case: the browser types a domain, TLS is negotiated, the URL switches to https and the user authenticates over the resulting secure link.

Common mistake. TLS encrypts web traffic with the server's public key. Public-key operations happen only during the handshake, for signatures and key agreement. Fast symmetric ciphers such as the Advanced Encryption Standard encrypt the bulk data under keys derived fresh for each session.

SSL (Secure Sockets Layer, the predecessor of TLS) started at Netscape around 1995 and became TLS in 1999. SSL 1.0 was never released, SSL 2.0 shipped in February 1995 with security flaws, SSL 3.0 followed in 1996, and TLS 1.3 arrived in August 2018 as a complete revision. The revision reads best as a table of legacy flaws and the TLS 1.3 response to each.

Legacy flawTLS 1.3 response
Renegotiation on SSL 3.0 let an attacker splice sessionsrenegotiation removed
Version rollback attacked backward compatibilitylegacy version negotiation removed, with a downgrade signal in ServerHello
BEAST exploited Cipher Block Chaining (CBC) in browsersCBC removed, only Authenticated Encryption with Associated Data (AEAD) cipher suites remain
Lucky 13 exploited CBC padding timingno CBC padding left to time, since AEAD suites carry their own authentication
POODLE downgraded connections to SSL 3.0SSL 3.0 and the other legacy versions are no longer negotiable
RC4 output biases persisted despite RFC 7465 prohibiting themRC4 removed with the legacy cipher suites
Heartbleed read server memory through a heartbeat request whose declared size exceeded its payloadthe heartbeat extension is not part of TLS 1.3

The slides pair each attack with its proposed and deployed fixes. Backward compatibility kept flawed primitives available through TLS 1.2. TLS 1.3 removed those primitives.

Common mistake. TLS 1.3 removed RSA. It removed RSA key transport, where the client encrypted a secret to the server's public key. RSA certificates remain common: servers still prove identity with RSA-PSS signatures while keys are agreed through ephemeral Diffie-Hellman.

TLS 1.3 with (EC)DHE ((elliptic-curve) Diffie-Hellman ephemeral key exchange) runs the handshake in seven flights. The animation below walks them. The table marks the protection on each one.

#FlightEncryptedAuthenticatedTranscript-bound
1ClientHello, ClientKeyShare ($N_A$, $g^x$)nonoyes, it seeds the transcript hash
2ServerHello, ServerKeyShare ($N_B$, $g^y$)nonoyes; both sides then derive the handshake key
3ServerConfigurationyes, under the handshake keycovered by $\sigma$ and $\tau$yes
4ServerCertificateyescovered by $\sigma$ and $\tau$yes
5ServerCertificateVerify, $\sigma = S(sk_B, CH, \ldots, SCert)$yesyes, signature under the server's long-term keyyes, $\sigma$ covers the transcript through the certificate
6ServerFinished, $\tau = T(k_s, CH, \ldots, SKS)$yesyes, MAC under a handshake-derived keyyes, $\tau$ covers the transcript through ServerKeyShare
7ClientFinishedyesyes, MAC under a handshake-derived keyyes; both sides then derive the channel key
TLS 1.3 key schedule, as given on slide 70

The client picks $N_A \in \{0,1\}^{256}$ and $x \in \Z_q$; the server picks $N_B \in \{0,1\}^{256}$ and $y \in \Z_q$. The handshake key is $\mathrm{KDF}(g^{xy}, CH, \ldots, SKS)$ on both sides. The server sends its certificate and two authenticators: $\sigma = S(sk_B, CH, \ldots, SCert)$ and $\tau = T(k_s, CH, \ldots, SKS)$, where $k_s$ is derived from the handshake key. After ClientFinished, the channel key is $\mathrm{KDF}(g^{xy}, CH, \ldots, CF)$.

Scored against the checklist, (EC)DHE gives secrecy, and forward secrecy as well because the static key material in the run is the signing key, which cannot recover $g^{xy}$ after the ephemerals are erased. The signature $\sigma$ authenticates the server. The two Finished tags give key confirmation in both directions. The transcript inside every Key Derivation Function (KDF) call keeps both sides agreeing on one session.

Common mistake. Whoever obtains the server's certificate can decrypt its traffic. A certificate is a public document that binds a domain name to a public key; decryption needs the matching private key. With ephemeral Diffie-Hellman, even a stolen private key cannot unlock recorded past sessions.

The pre-shared key variant resumes from a shared key, either external or from session resumption (see the PAKE note in section 13). The ClientHello carries early data and PSK modes. The ServerHello selects the PSK. Zero round-trip time pushes this further: the client sends application data immediately, using a semi-static server key that is available only for short periods. The slides credit Google with inventing 0-RTT to reduce latency. In QUIC the client uses an ephemeral key together with the server's semi-static key to derive an early key and encrypt data under it. The server later supplies an ephemeral share for a forward-secure key. The price is replay: the same early ciphertext can be sent again. The only defense shown on slide 74 is for the server to store previously received values.

Takeaway

TLS 1.3 is SIGMA with a key schedule: ephemeral Diffie-Hellman for forward secrecy, signatures over the transcript for authentication, HKDF-style KDFs binding every key to the full handshake, and 0-RTT as a controlled replay risk.

Section 15Further Resources

Further reading: Katz and Lindell (2015), Introduction to Modern Cryptography.

Section 16Exercises

Answers are worked out in full and checked against the labs on this page.

Take $p = 29$, $g = 2$, Alice's secret $a = 5$ and Bob's secret $b = 12$. Compute the public values and the shared key. Drill

Alice sends $A = 2^{5} \bmod 29 = 32 \bmod 29 = 3$. Bob sends $B = 2^{12} \bmod 29 = 4096 \bmod 29 = 7$. Alice computes $K = B^{a} = 7^{5} \bmod 29 = 16807 \bmod 29 = 16$. Bob computes $K = A^{b} = 3^{12} \bmod 29 = 16$. The shared key is $16$.

Using $p = 29$, $g = 2$, $a = 5$ and $b = 12$, let Eve choose $y' = 3$ for her exchange with Alice and $x' = 4$ for her exchange with Bob. Compute the keys Eve establishes and compare them with the honest key. Attack

Eve sends $g^{y'} = 2^{3} = 8$ to Alice and $g^{x'} = 2^{4} = 16$ to Bob. Alice computes $8^{5} \bmod 29 = 27$, and Eve computes the same value as $A^{y'} = 3^{3} \bmod 29 = 27$. Bob computes $16^{12} \bmod 29 = 23$. Eve computes the same value as $B^{x'} = 7^{4} \bmod 29 = 23$. The honest key from the previous exercise was $16$. It is never established. Eve holds $27$ with Alice and $23$ with Bob.

Explain why the second Authenticated Key Exchange (AKE) attempt, which signs $X \| Y$, still permits identity misbinding. What does Eve learn, and what does Bob believe? Attack

Eve holds her own long-term key $sk_E$. She relays Alice's public value $g^x$ into a session with Bob while presenting that session as Eve-to-Bob, and she runs a parallel session in which Bob's public value returns toward Alice. The signed string $X \| Y$ is identical in both runs, so both signatures verify. The identities attached to the verified signatures differ.

Eve does not learn $K$. The damage is attribution: Alice accepts $K$ as shared with Bob, while Bob accepts the same $K$ as shared with Eve. Anything Alice sends under $K$ is treated by Bob as coming from Eve.

Show how identity misbinding violates the CK definition using the test session and an exposure query. Proof

After the attack there are two completed sessions with outputs $(A, B, K)$ and $(B, E, K)$. They are not matching sessions, because the peer names differ. The adversary selects one of them as the test session and receives either its real key or a random key. She then issues an exposure query on the other session and learns $K$. Comparing the exposed key with the challenge answers the test query with probability $1$, which breaks indistinguishability.

In hashed MQV, Alice computes $(Y B^{e})^{x + da}$ and Bob computes $(X A^{d})^{y + eb}$. Show that both values equal $g^{(x+da)(y+eb)}$. Proof

Substitute $A = g^{a}$, $B = g^{b}$, $X = g^{x}$ and $Y = g^{y}$. Alice's value is

$$(Y B^{e})^{x+da} = (g^{y} g^{be})^{x+da} = g^{(y+eb)(x+da)}.$$

Bob's value is

$$(X A^{d})^{y+eb} = (g^{x} g^{ad})^{y+eb} = g^{(x+ad)(y+eb)}.$$

The exponents are products of integers, so $(y+eb)(x+da) = (x+da)(y+eb)$, and both parties obtain $g^{(x+da)(y+eb)}$. The hashes $d$ and $e$ bind the peer identity into those exponents.

RFC 5869 test case 1 uses 22 bytes of $0x0b$ as IKM, salt $000102\ldots0c$, info $f0f1\ldots f9$ and $L = 42$. Give the PRK and OKM for HKDF-SHA256. Drill

Extract gives

PRK = 077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5

and expanding to 42 bytes gives

OKM = 3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865

The lab on this page reproduces both values with the RFC 5869 case 1 button. Test case 3, with empty salt and info, gives PRK = 19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04.

How many characters are needed for 128 bits of entropy with uniform ASCII-95 passwords, alphanumeric 62 passwords and Italian text at the asymptotic rate of 1.87 bits per character? Drill

ASCII-95 carries $\log_2 95 = 6.5699$ bits per character, so $128 / 6.5699 = 19.48$ characters, rounded up to 20. Alphanumeric 62 carries $\log_2 62 = 5.9542$ bits per character, so $128 / 5.9542 = 21.50$ characters, rounded up to 22. Italian at 1.87 bits per character needs $128 / 1.87 = 68.45$ characters, rounded up to 69.

A server checks a dictionary of $D = 10^{6}$ passwords with target false positive rate $p = 2^{-10}$. Compute the optimal number of hash functions, the table size in bits and the memory in megabytes. Drill

The optimal number of hash functions is $k \approx -\log_2 p = 10$. The table size is $N \approx -1.4427 \, D \log_2 p = 1.4427 \cdot 10^{6} \cdot 10 \approx 14{,}427{,}000$ bits. That is about $1{,}803{,}375$ bytes, or roughly $1.8$ MB. With these parameters the achieved false positive rate is close to $2^{-10}$.