1 of 4

Your RightSignal

Cryptography from zero · 9 of 111 / 3

TLS handshake

The concept

What your browser does in the split second before the padlock appears

Before HTTPS sends any page, browser and server run the TLS handshake: a few messages that agree on a secret key and prove the server is the site you typed. Only then does the padlock appear.

In TLS 1.3, the current version, your browser's first message (ClientHello) lists its ciphers, names the site and carries a key share: a public number from a fresh Diffie–Hellman key pair.

The server's reply (ServerHello) carries its own key share. From these two public numbers both sides compute the same secret, which an eavesdropper who saw both cannot work out.

What it’s forLets browser and server compute the same secret after swapping only public numbers.

K = Bᵃ mod p = Aᵇ mod p, where A = gᵃ mod p and B = gᵇ mod p

a, b
secret random numbers picked fresh by browser and server, never sent
A, B
the public key shares sent in ClientHello and ServerHello
g, p
public agreed numbers (real TLS mostly uses elliptic curves like X25519 instead)
K
the shared secret both sides turn into encryption keys

What it givesAn identical secret on both ends that an eavesdropper who saw only A and B cannot compute.

  1. g = 2, p = 11, a = 3, b = 4: A = 2³ mod 11 = 8, B = 2⁴ mod 11 = 5
  2. Browser: K = 5³ mod 11 = 125 mod 11 = 4
  3. Server: K = 8⁴ mod 11 = 4096 mod 11 = 4, the same