No history yet

WPA2 Handshake Analysis

The WPA2 Handshake

The core of WPA2 security is the 4-way handshake. Its primary job is to confirm that both the client (the Supplicant) and the access point (the Authenticator) possess the correct Pre-Shared Key (PSK) without ever transmitting that key over the air. This process also generates a fresh, unique set of encryption keys for the new session, ensuring that each connection is cryptographically isolated.

The entire exchange is conducted using EAPOL-Key frames, a specific type of Ethernet frame designed for authentication. Let's walk through the four messages in this security dance.

Generating the Keys

The first message is simple: the Authenticator sends a large random number, the ANonce (Authenticator Nonce), to the Supplicant. A nonce is just a number used once to prevent replay attacks.

After receiving the ANonce, the Supplicant generates its own random number, the SNonce (Supplicant Nonce). Now, the Supplicant has all five ingredients needed to create the session key, known as the Pairwise Transient Key (PTK). The PTK is derived using a (PRF) that combines the Pre-Shared Key (PMK, which is derived from your Wi-Fi password), both nonces, and the MAC addresses of both devices.

PTK=PRF(PMK,ANonce,SNonce,MACAP,MACSTA)PTK = PRF(PMK, ANonce, SNonce, MAC_{AP}, MAC_{STA})

Once the Supplicant has the PTK, it sends Message 2, containing its SNonce. Crucially, it also includes a Message Integrity Check (MIC). The MIC is a cryptographic hash of the EAPOL frame, signed with a portion of the newly derived PTK. It proves two things: that the message hasn't been tampered with, and that the sender (the Supplicant) must have known the original PSK to create the correct PTK in the first place.

The MIC acts as a digital seal. If the seal is broken or incorrect, the message is discarded.

When the Authenticator receives Message 2, it uses the SNonce along with its own ANonce and the PSK to derive the same PTK. It then calculates its own MIC on the EAPOL frame it received and compares it to the MIC sent by the Supplicant. If they match, the Authenticator knows the Supplicant is legitimate.

Now the roles reverse. In Message 3, the Authenticator sends the Group Temporal Key (GTK) to the client. The GTK is the key used to encrypt broadcast and multicast traffic to all clients on the network. This message is also protected with a MIC, proving the Authenticator's identity to the Supplicant. The Supplicant verifies this MIC, and if it's correct, it installs the PTK and GTK. Finally, it sends Message 4 as a final confirmation, and the encrypted session begins.

Capturing for Analysis

The security of this whole process hinges on the secrecy of the PMK. Because the PMK is never transmitted, an attacker can't simply sniff it from the air. However, they can perform a passive capture of the 4-way handshake. The ANonce, SNonce, and MAC addresses are all sent in the clear.

If an attacker captures these four frames, they have all the inputs to the PRF except for one: the PMK. This allows them to perform an offline brute-force or dictionary attack. They can repeatedly guess the Wi-Fi password, derive a PMK from that guess, and then run it through the PRF with the captured nonces and MAC addresses.

Lesson image

How do they know if a guess is correct? They use the resulting PTK to sign a copy of the captured EAPOL frame and check if their calculated MIC matches the MIC from the original handshake. If it does, they've found the password. This is why a long, complex, and non-dictionary-word password is the single most effective defence against attacks on WPA2-PSK networks. It dramatically increases the entropy and makes a successful brute-force attack computationally infeasible.

To crack a WPA/WPA2 password, you need to capture the four-way handshake.

Time to check your understanding of the handshake process.

Quiz Questions 1/5

What is the primary purpose of the WPA2 4-way handshake?

Quiz Questions 2/5

Which of the following components is NOT used as an input to the Pseudo-Random Function (PRF) to create the Pairwise Transient Key (PTK)?

Understanding the handshake's mechanics is key to appreciating both its strengths and the vulnerabilities that later protocols like WPA3 were designed to address.