In WPA2, where does the PMK come from, and what do the KCK, KEK and TK carved from the PTK each protect?
answer
- two roots, one tree
- PBKDF2 over the SSID
- first 32 octets of the MSK
- three slices of the PTK
- group keys stand apart
basics
~20 sThe PMK comes from the passphrase via PBKDF2 in Personal mode, or from the EAP MSK in Enterprise. The PTK derived from it splits into the KCK for handshake MICs, the KEK for wrapping group keys, and the TK for unicast data.
solid answer
~40 sWPA2 has two roots and one tree. In Personal mode the PMK is PBKDF2 with HMAC-SHA1 over the passphrase, salted with the SSID, 4096 iterations, 32 octets; in Enterprise mode it is the first 32 octets of the Master Session Key the EAP method exports. The four-way handshake turns the PMK, both nonces and both MAC addresses into the PTK, 384 bits with CCMP. Its first 128 bits are the **KCK**, which keys the MIC on EAPOL-Key messages; the next 128 bits are the **KEK**, which wraps the GTK and IGTK in message 3; the last 128 bits are the **TK**, the key CCMP uses for unicast data. Broadcast and multicast use the separate GTK, and group management frames the IGTK.
code
pseudocode · 14 lines# Personal: PMK from the passphrase
PMK = PBKDF2(HMAC-SHA1, passphrase, salt = SSID, iterations = 4096, length = 32 octets)
# Enterprise: PMK from the EAP method's key material
PMK = MSK[octets 0..31]
# Both modes, after messages 1 and 2 of the four-way handshake
PTK = PRF-384(PMK, "Pairwise key expansion",
Min(AA, SA) || Max(AA, SA) ||
Min(ANonce, SNonce) || Max(ANonce, SNonce))
KCK = PTK[bits 0..127] # keys the MIC on EAPOL-Key messages
KEK = PTK[bits 128..255] # wraps the GTK and IGTK in message 3
TK = PTK[bits 256..383] # CCMP key for unicast datago deeper
Recall that the passphrase is not the encryption key: it leads to a PMK, and the keys that protect traffic are derived further down.
Explain both roots of the PMK, the inputs to the PTK, and the job of each slice: KCK for handshake integrity, KEK for wrapping, TK for data.
Show the operational consequences: an SSID rename changes the PSK, a shared PMK cannot be revoked per user, and the GTK is shared by all clients.
Use the hierarchy to argue access-model choices: only the root differs between Personal, Enterprise and SAE, so that is where revocation and rotation costs are decided.
## Two roots, one hierarchy WPA2's keys form a tree. At the top sits the **Pairwise Master Key (PMK)**, a 256-bit secret both sides hold before any data flows. Where the PMK comes from depends on the mode; everything below it is identical in Personal and Enterprise mode, and is produced by the **four-way handshake**. ## Personal: from passphrase to PMK - The passphrase (8 to 63 characters) is run through **PBKDF2** (RFC 8018) with HMAC-SHA1, the **SSID as the salt** and **4096 iterations**, producing 32 octets. hostapd's `wpa_passphrase` helper and its access-point code both compute it this way. - An operator may instead configure the 256-bit PSK directly as 64 hex digits; hostapd's `wpa_psk` setting takes that form. NIST's 802.11i guide puts it simply: in pre-shared key environments the PSK becomes the PMK. - Because the SSID is the salt, renaming the network changes the PMK even when the passphrase is unchanged. - Every device that knows the passphrase holds the **same PMK**, which is why access on a Personal network is shared rather than per user. ## Enterprise: from the EAP MSK to the PMK - In 802.1X mode the client authenticates with an EAP method against an authentication server. The method exports a **Master Session Key (MSK)** of at least 64 octets (RFC 5247). - RFC 5247 states that in IEEE 802.11 octets 0-31 of the MSK are known as the PMK. The server delivers the MSK to the access point, and the client computes the same value itself; how it travels to the AP is covered with EAP over RADIUS. - The result is a **per-user, per-session PMK**, which is what makes individual revocation possible. ## The PTK and its three slices After messages 1 and 2 of the handshake, both sides compute the **Pairwise Transient Key (PTK)** with a pseudo-random function keyed by the PMK, over the label "Pairwise key expansion", the two MAC addresses and the two nonces, each pair ordered smaller-first so both sides build the same input. With CCMP the PTK is 384 bits: | Slice | Size with CCMP | Protects | Used in | |---|---|---|---| | **KCK** (EAPOL-Key Confirmation Key) | 128 bits | Integrity of EAPOL-Key frames, through the Key MIC | Messages 2, 3 and 4, and the group key handshake | | **KEK** (EAPOL-Key Encryption Key) | 128 bits | Confidentiality of key material, through AES key wrap (RFC 3394) | The GTK and IGTK in message 3 and in group key updates | | **TK** (Temporal Key) | 128 bits | Unicast data frames, as the CCMP key | Every unicast frame after the handshake | The KCK and KEK protect key-management messages; the TK is the pairwise key that touches user traffic. ## The group keys - The **GTK (Group Temporal Key)** protects broadcast and multicast data. NIST's guide describes it as derived from a **Group Master Key (GMK)** the AP holds; hostapd generates the GMK at random and renews it on its own timer. The GTK is not derived from any client's PTK: it is one key shared by every client of the BSS, delivered to each under that client's KEK. - The **IGTK (Integrity Group Temporal Key)** came with Protected Management Frames (802.11w-2009). It protects group-addressed management frames through BIP, whose default in hostapd is AES-128-CMAC, and it is delivered in message 3 only when PMF is negotiated. ## Lifetimes at a glance 1. **PMK**: as long as the passphrase in Personal mode; per authentication, and possibly cached, in Enterprise mode. 2. **PTK**: per association, renewed by a new four-way handshake. 3. **GTK**: until the AP rotates it with the two-message group key handshake. ## Common confusions - **The passphrase is not a key.** It is only the input to PBKDF2; nothing on the air is encrypted with it directly. - **The PMK never encrypts a frame.** It exists to derive the PTK, and it stays the same across sessions in Personal mode. - **The GTK is not part of the PTK.** It is generated by the AP, shared by all clients, and merely carried under each client's KEK. - **hostapd's `wpa_psk` is the PMK itself.** Entering 64 hex digits skips the PBKDF2 step, so that value is tied to the SSID it was computed for.
- Why are both MAC addresses and both nonces fed into the PTK derivation?The MAC addresses bind the keys to this particular client and AP, and the nonces make each session's keys fresh even though the PMK is unchanged. Each pair is ordered smaller-first, so the authenticator and supplicant build exactly the same input without agreeing on who goes first.
- Which part of this hierarchy changes when a network moves to WPA3-Personal?Only the root. SAE replaces the PBKDF2 step with a password-authenticated exchange that yields a fresh PMK for every session; the four-way handshake, the PTK with its KCK, KEK and TK, and the group keys follow as before.
- The TK is derived directly from the passphrase.
- The KEK encrypts user data frames after the handshake.
- In WPA2-Enterprise the PMK is a hash of the user's password.
- Renaming the SSID leaves the PSK unchanged as long as the passphrase stays the same.
- Each client's GTK is derived from its own PTK.