← Dev log

security

SPAKE2 Short-Code Pairing

SPAKE2 Short-Code Pairing

Two machines that have never met need to learn each other's public keys over a network anyone can listen to. A six-digit code is far too weak to use as a key: an eavesdropper would try all million offline.

A password-authenticated key exchange such as SPAKE2 fixes that. Both sides derive a strong shared key from the weak code, and an attacker gets one guess per live attempt, with nothing to grind offline.

A shows code ──(read aloud)──▶ B types it
A ⇄ SPAKE2 ⇄ B           → shared channel
exchange identities       → both compute a phrase from the two fingerprints
human on A confirms AND human on B confirms → each writes the roster entry
any "no" or timeout      → nothing is written

The phrase is the second factor: it makes a person compare something that differs if a third party sits in the middle. A word list built for being read aloud (the PGP word list, alternating by position) beats hex.

Rules that fell out of building it. The confirmation never defaults to yes. It needs a process a human can reach, so a headless service has to hand the question to a CLI or GUI and wait with a timeout. Socket deadlines must be extended while the human reads and restored afterwards. A completed pairing should be persisted by the service itself, so a closed window doesn't lose it, and a cancelled one must release its listening port.

Related: Device-Activation-and-Pairing. Used in: Ferry