Encryption, from the ground up · Puzzle 7 · 8 of 9
Proof of who you are
In puzzle 3, the key exchange worked with whoever answered, and in puzzle 5 an attacker could swap a digest. Both gaps close the same way: a mark on the data that only the real server can make.
The problem
Two gaps are open. In puzzle 3, your app agreed on a secret with whoever answered, which might be the listener pretending to be your server. In puzzle 5, a digest only helped if the attacker couldn't swap it. Both come down to one question: how does your app know that something really comes from your server?
See it
Unlike puzzle 2's single key, the server has a key pair: a private key it never shows, and a public key anyone may have.
Step 1 of 4It hashes the data and runs the digest through a step only its private key can do: a signature.
Step 2 of 4Your app checks it with the public key. It only checks out if the private key made it and the data is unchanged. Predict: but whose public key is it?
Step 3 of 4A certificate says so: the server's name and public key, signed by a certificate authority whose key your phone already trusts.
Step 4 of 4
The building block
This needs a different kind of key from puzzle 2. There, one key did both jobs. Here the server has a key pair: two keys made together, a private key it never shows anyone and a public key anyone may have. What one does, only its partner can check. That's why this kind is also called asymmetric.
- To make a signature, the server hashes the data (puzzle 5) and runs the digest through a signing step that needs its private key.
- Anyone with the public key can check the signature against the data: it checks out only if it was made with the matching private key and the data hasn't changed since.
- Without the private key, nobody can make a signature that checks out. Not the listener, not anyone. (Signing isn't encrypting: the data stays readable; the signature only proves who made it and that it's unchanged.)
So a signature proves two things at once: who sent it, and that it wasn't changed. That closes puzzle 4's gap: in HTTPS, the server signs the key exchange, including its public value, so a swapped value from a man in the middle can't carry the server's signature.
That moves the question: how does your app know which public key is really your server's? A listener could hand over its own. The answer is a certificate: a small document with your server's name and its public key, signed by a certificate authority, an organization whose public key is already built into your phone. Before it signs, the authority checks that whoever asks really controls that name. Certificates aren't secret: your server shows its certificate to every visitor, so anyone can copy one. A certificate signed by anyone else, including one the server signs itself, fails that check. Your app checks the authority's signature on the certificate, checks that the name matches the one in the address it asked for, and from then on trusts that public key. Puzzle 8 shows why a copied certificate alone gets the listener nowhere.
Note the look-alike from puzzle 3: a key exchange's private value is thrown away when the connection ends; a server's private key is kept for years and proves who it is.
The analogy
A wax seal. Only the king has the seal (private key), but everyone knows what it looks like (public key), so anyone can check a letter is really his and unopened. And how do you know what the king's seal looks like? A register kept by someone you already trust (the certificate authority) shows it, with the king's name beside it.
Check yourself
Sources
- RFC 8446: TLS 1.3, section 4.4.2 Certificate and section 4.4.3 Certificate Verify (CertificateVerify "is used to provide explicit proof that an endpoint possesses the private key corresponding to its certificate"; authentication "can happen via asymmetric cryptography (e.g., RSA, … ECDSA, … EdDSA)")
- NIST FIPS 180-4: Secure Hash Standard ("Secure hash algorithms are typically used with other cryptographic algorithms, such as digital signature algorithms")
What you now know
A key pair is a private key the owner keeps and a public key anyone may have. Signing computes a signature from a digest and the private key; anyone can check it with the public key, and nobody can fake it without the private key. A certificate is a server's name and public key, signed by a certificate authority your phone already trusts.
Answer every question above correctly to unlock the next puzzle.
Something wrong or unclear on this page? Tell me: a puzzle that didn't click is a bug in the puzzle.