WPA3-SAE: the Dragonfly Commit and Confirm
WPA2-Personal's weakness is structural: the PMK is a fixed function of the passphrase, so a recorded handshake lets anyone test guesses offline. WPA3-Personal replaces the PSK mapping with SAE, Simultaneous Authentication of Equals, a password-authenticated key exchange (PAKE) based on Dan Harkins' Dragonfly design (described in RFC 7664 and specified for Wi-Fi in IEEE 802.11). Both sides prove they know the password and agree on a fresh, high-entropy PMK, and the messages give an eavesdropper nothing to test guesses against. This lesson builds SAE's idea with small numbers, so every value can be checked by hand, and then lists what makes the real protocol safe.
The idea in one paragraph
Both sides turn the password and both MAC addresses into a group element, the password element . Each side then runs something like Diffie–Hellman with as the base (Diffie–Hellman): only someone who knows the password knows the base, so only they can compute the shared secret. Each side hides its secret exponent behind a random mask, sends the masked values in a Commit message, and then proves knowledge of the shared secret with a Confirm message. A wrong password gives a different shared secret, and the Confirm fails, once per live attempt.
The lab
Set the security to WPA3-Personal: two Commit and two Confirm messages run before the familiar 4-way handshake, and the observer's panel shows that the capture contains nothing usable for offline guessing.
The exchange, written out
Let be an element of a group of prime order . Each side picks two secrets, and , from to :
and sends (scalar, element) as its Commit. On receiving the peer's commit, side A computes
and side B gets the same value with the roles swapped. From and both scalars, each side derives a KCK and the PMK; the Confirm is an HMAC under the KCK over both commits. Only then does the 4-way handshake run, with this fresh PMK.
The program uses a toy group: , and the squares modulo , a subgroup of prime order . The password element is a hash of the password and both MACs, squared into that subgroup. Real SAE uses elliptic-curve group 19 (NIST P-256) or larger groups, and a careful mapping to the password element (next lesson).
import hashlib, hmac
# A toy group: p = 2q + 1 with p and q prime; squares mod p form the subgroup of prime order q.
p, q = 1019, 509
STA, AP = bytes.fromhex("020000000a05"), bytes.fromhex("020000000a01")
def pwe(password): # password element: hash password + both MACs, square into the subgroup
h = hashlib.sha256(password + min(STA, AP) + max(STA, AP)).digest()
return pow(int.from_bytes(h, "big") % (p - 3) + 2, 2, p)
def commit(P, r, mask): # Commit: scalar = r + mask, element = P^(-mask) (r: the spec's first secret)
return (r + mask) % q, pow(pow(P, mask, p), -1, p)
def shared(P, r, peer_scalar, peer_element):
return pow(pow(P, peer_scalar, p) * peer_element % p, r, p) # = P^(r_a * r_b)
def confirm(k, counter, s1, s2, e1, e2):
msg = b"".join(x.to_bytes(2, "big") for x in (counter, s1, s2, e1, e2))
return hmac.new(hashlib.sha256(b"kck" + k.to_bytes(2, "big")).digest(), msg, hashlib.sha256).hexdigest()[:16]
P = pwe(b"correct horse lab staple") # both sides know the password
# Fixed lab values; real SAE draws r and mask from a secure generator for every attempt
a_rand, a_mask, b_rand, b_mask = 101, 222, 303, 404
a_s, a_e = commit(P, a_rand, a_mask)
b_s, b_e = commit(P, b_rand, b_mask)
print(f"PWE = {P} STA commit: scalar {a_s}, element {a_e} AP commit: scalar {b_s}, element {b_e}")
k_sta, k_ap = shared(P, a_rand, b_s, b_e), shared(P, b_rand, a_s, a_e)
print("shared secret K: STA", k_sta, " AP", k_ap, " equal:", k_sta == k_ap)
print("STA confirm", confirm(k_sta, 1, a_s, b_s, a_e, b_e), " AP checks it:",
confirm(k_ap, 1, a_s, b_s, a_e, b_e) == confirm(k_sta, 1, a_s, b_s, a_e, b_e))
# Someone with the wrong password runs the exchange: same messages, different K, confirm fails
P_wrong = pwe(b"correct horse lab stapler")
c_s, c_e = commit(P_wrong, a_rand, a_mask)
print("wrong password: AP's K", shared(P, b_rand, c_s, c_e), "vs attacker's K", shared(P_wrong, a_rand, b_s, b_e))
# A passive observer tests guesses: is the observed element consistent with a guessed PWE?
for guess in (b"password", b"LabNet2026!", b"correct horse lab staple"):
G = pwe(guess)
masks = [m for m in range(1, q) if pow(pow(G, m, p), -1, p) == a_e]
print(f"guess {guess.decode():26} PWE {G:4}: masks consistent with the capture: {masks}")PWE = 322 STA commit: scalar 323, element 833 AP commit: scalar 198, element 672
shared secret K: STA 273 AP 273 equal: True
STA confirm 59e096373d05277a AP checks it: True
wrong password: AP's K 921 vs attacker's K 303
guess password PWE 689: masks consistent with the capture: [320]
guess LabNet2026! PWE 169: masks consistent with the capture: [365]
guess correct horse lab staple PWE 322: masks consistent with the capture: [222]
Read the output in three parts:
- Both sides agree on and the AP accepts the client's Confirm.
- A wrong password gives a different password element, so the two sides compute different values of and the Confirm check fails. The attacker learns "wrong" for one guess, at the cost of one live exchange that the AP can log, slow down and lock out.
- The capture eliminates no guess. For every guessed password there is a mask that explains the observed element, so the Commit message is consistent with any password. To test a guess, an observer would need that mask, and the program found it by trying all 508 possible values: a discrete logarithm. In a 509-element toy group that is instant; in group 19 it is as hard as breaking elliptic-curve Diffie–Hellman. That is the security argument of SAE in one line: one guess costs one discrete logarithm or one live attempt.
What SAE gives
| Property | WPA2-PSK | WPA3-SAE |
|---|---|---|
| offline guessing from a capture | yes | no (one guess = a discrete log or a live attempt) |
| PMK | fixed: | fresh per session from |
| forward secrecy | no: the passphrase plus old captures decrypt old sessions | yes: old sessions stay safe if the password leaks later |
| who authenticates | both, via the MIC (anyone with the passphrase can be the AP) | both, symmetrically ("equals"); anyone with the password can still be the AP |
| denial of service | handshake is cheap | Commit processing is expensive: anti-clogging tokens make a flooding client prove it receives frames at its claimed MAC address first |
The last two rows are limits. SAE still uses one shared password, so every member of the network can impersonate the AP; SAE-PK (an extension, 2020) adds a public key bound to the password for public networks such as cafés, and Enterprise mode gives per-user credentials.
How SAE problems are detected
- Beacon and configuration audit: AKM 8 (SAE) present, PMF required (PMF); which SAE groups are allowed (only strong ones such as 19, 20, 21); whether hash-to-element is enabled.
- AP logs: SAE authentication failures per MAC address and per time window, which are now the only way to guess passwords; anti-clogging token activity, which indicates a Commit flood.
- Client inventory: devices that fall back to WPA2 in transition mode (next lesson).
How SAE is deployed well
- WPA3-only (SAE + PMF required) where every client supports it; transition mode only as a temporary step.
- Hash-to-element (H2E) enabled, which removes the timing leaks of the original password-element derivation; required on 6 GHz.
- A good password anyway: SAE stops offline guessing, not online guessing, and a password that everyone knows can still be used for an evil twin.
- Rate limits and alerts on SAE failures; patched clients and APs (the Dragonblood fixes).
Pitfalls
- "WPA3 makes any password safe": online guessing still works for very weak passwords, and every holder of the password can impersonate the AP.
- Allowing weak SAE groups for compatibility: group downgrade was part of Dragonblood.
- Forgetting that the 4-way handshake still follows SAE: the KRACK fixes still matter.
Practice
1. In the program, change the client's a_rand from 101 to 102. Which values change, and does the exchange still succeed?
The client's scalar (and so the AP's K, the client's K and the Confirm value) change; the element stays the same because it depends only on the mask. Both sides still compute the same , because holds for any choice of rand. The exchange succeeds with a different session key: that is forward secrecy at work.
2. Why must rand and mask be fresh for every attempt?
If they repeat, an observer sees the same commit twice and later sessions are linkable; worse, if one session's secrets leak, others would be exposed. Fresh secrets give a fresh and PMK every time, which is what forward secrecy needs.
3. Why can't an observer use the toy program's mask search against real WPA3?
The search tries every exponent, which is a discrete logarithm. The toy group has 509 elements; P-256 has about , so the search would take longer than the age of the universe, for each single password guess.
Test yourself
What does an SAE Commit message contain?
- The password hash
- A scalar (rand + mask) and an element (PWE to the power of minus mask)
- The PMK
- The SSID and the GTK
Why is a captured SAE exchange useless for offline guessing?
- It is encrypted with WEP
- Every password is consistent with the observed commit; testing one needs a discrete logarithm or a live attempt
- The AP refuses captures
- The password is not used
Which property does SAE add that WPA2-PSK lacks?
- Hidden SSIDs
- Forward secrecy: a later password leak doesn't decrypt old sessions
- Faster roaming
- Per-user passwords
What are anti-clogging tokens for?
- Encrypting data
- Making a client prove it receives frames at its MAC before the AP does expensive Commit processing
- Choosing the channel
- Storing the PMK