Encryption, from the ground up · Start here · 1 of 6

Anyone on the line

Your app sends a password to a server. Between the two sit a café's Wi-Fi, a phone operator and a dozen machines you don't control. Here's what any of them can do, and the first defence that stops it.

The problem

Your app sends the user's password to your server. It doesn't fly there directly: it goes through the café's Wi-Fi, the internet provider, and many machines in between, each one passing it along. Every one of them sees every byte. What could one of them do with it?

See it

A phone sends a password through the café Wi-Fi to a server; a listener at the Wi-Fi reads it; after encryption the listener sees only gibberish your app café Wi-Fi your server pass: hunter2 listenerreads it read · change · pretend listener key x7#Q!f9 gibberish
  1. Your app sends a password. It doesn't fly straight to your server: it passes through the café's Wi-Fi and many machines after it.

    Step 1 of 4
  2. Any of them can read it as it passes: every byte, in plain sight.

    Step 2 of 4
  3. In fact, any of them could do three things: read it, change it, or pretend to be your server. Predict: what stops the reading?

    Step 3 of 4
  4. Encryption: with a secret key, your app turns the data into gibberish, ciphertext. The listener sees bytes that mean nothing.

    Step 4 of 4

The building block

Call any such machine the listener (or the attacker: same machine). It can do three things, and the later puzzles build the blocks that stop them:

  • read what passes by: the password, the token, the card number;
  • change it on the way: a different amount, a different account;
  • pretend to be the other side: answer as if it were your server.

The first block stops the reading. Encryption turns data into gibberish that only someone holding the right key, a secret number, can turn back (decrypt). The gibberish is ciphertext. A machine in the middle still sees every byte, but they mean nothing to it.

Encryption alone doesn't stop the other two. Someone can still change ciphertext (the result is garbage, or quietly different data, and nobody notices unless something checks), and encryption with someone who is pretending to be your server protects nothing. Puzzles 3 and 4 add those checks. First, though: where does the key come from?

The analogy

Sending a postcard through a chain of strangers. Anyone can read it. Write it in a code only your friend can read, and the strangers see nonsense. But a stranger could still scribble on it, or hand it to someone pretending to be your friend.

Check yourself

Your app sends a password, encrypted, over the café Wi-Fi. A machine in the middle copies every byte. What does it learn?

Not quite. Seeing the bytes isn't enough: without the key, ciphertext is gibberish.

Right. Ciphertext without the key means nothing.

Not quite. The Wi-Fi's own password doesn't matter here: what matters is your data is encrypted.

Why isn't encryption alone enough?

Not quite. A good key can't be guessed in any useful time; the gaps are changes and pretending. Re-read that part ↑

Right. Encryption stops reading, not the other two.

What's the difference between a key and ciphertext?

Not quite. Ciphertext is your data, encrypted; the key is what encrypts it.

Not quite. The key is never sent with the data; that would unlock it for everyone.

Right. The secret vs what it locks.

Sources

  • RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3 ("TLS allows client/server applications to communicate over the Internet in a way that is designed to prevent eavesdropping, tampering, and message forgery"; its goals are authentication, confidentiality and integrity, "even in the face of an attacker who has complete control of the network")

What you now know

Data crosses many machines on its way. Any of them can read it, change it, or pretend to be the other side. Encryption turns the data into ciphertext that only someone with the key can turn back, which stops the reading. The next puzzles stop the rest.