No history yet

WPA2 Handshake Mechanics

The Handshake

When you connect to a WPA2-protected Wi-Fi network, your device and the access point (AP) perform a clever, four-step negotiation to prove they both know the password without ever broadcasting it. This process, called the 4-Way Handshake, is the core of WPA2 security. It establishes a fresh set of encryption keys for your session, ensuring that even if someone recorded past traffic, they couldn't decrypt your new data.

The entire goal is to generate and exchange keys securely, confirming both sides have the Pre-Shared Key (PSK) without transmitting it over the air.

Before the handshake even begins, both your device (the supplicant) and the access point (the authenticator) independently derive a master key from the network's password. This isn't the key used for encryption itself, but a starting point. It's called the Pairwise Master Key (PMK), and it's created by running the Wi-Fi password (the PSK) and the network name (SSID) through a key stretching algorithm called PBKDF2 for 4096 iterations. This makes the PMK computationally expensive to guess, even if an attacker has a list of common passwords.

PMK=PBKDF2(PSK,SSID,4096,256)PMK = PBKDF2(PSK, SSID, 4096, 256)

The Four Steps

With the PMK calculated on both ends, the handshake can begin. The four messages exchanged are a specific type of network packet called an -Key frame. The process is designed to create a session key, known as the Pairwise Temporal Key (PTK), that will encrypt all unicast traffic (data sent directly between you and the AP).

The magic is in how the PTK is created. It’s derived from five ingredients: the PMK, two random numbers called nonces (ANonce from the AP, SNonce from the client), and the MAC addresses of both the client and the AP. Since both sides already have the PMK and can see the MAC addresses and nonces from the handshake messages, they can both compute the exact same PTK without ever sending it.

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

The Message Integrity Check (MIC) is the proof. It's a cryptographic hash of the EAPOL frame, signed with a key that is part of the newly-derived PTK. If the client sends a message with a MIC, the AP can only verify it if it has calculated the same PTK. If the MIC is valid, the AP knows the client must have the correct PSK. The same logic applies when the AP sends its own MIC back to the client. This confirms the shared secret for both parties.

Unicast and Group Keys

The PTK is used to encrypt unicast traffic—data meant for a single recipient. But what about broadcast or multicast traffic, which an AP sends to all connected clients at once? Encrypting that traffic with each client's unique PTK would be incredibly inefficient.

To solve this, the AP generates a separate key called the Group Temporal Key (GTK). This key is shared among all clients connected to the AP and is used to encrypt all broadcast and multicast traffic. The AP securely delivers the GTK to your device during step 3 of the 4-Way Handshake, encrypted using your unique PTK. This way, the shared GTK is never sent in the clear.

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

This whole process explains why network security tools need to capture the 4-Way Handshake to attempt to crack a Wi-Fi password. The handshake contains the nonces and the MICs. An attacker can take this captured data offline and start guessing passwords. For each guess, they can perform the same PMK and PTK calculations your device would, generate their own MIC, and check if it matches the one in the captured handshake. If it matches, they've found the password.

Quiz Questions 1/6

What is the primary purpose of the WPA2 4-Way Handshake?

Quiz Questions 2/6

The Pairwise Temporal Key (PTK), used to encrypt data between your device and the access point, is derived from five components. Which of the following is NOT one of those components?

Understanding these mechanics reveals the elegant design of WPA2, but also its primary vulnerability: its reliance on a single pre-shared key for initial authentication.