← Security and privacy

Public and private keys

To send a secret to someone you've never met, you can't share a key first: anyone could copy it on the way. Public key encryption works like an open padlock: anyone can lock a message with someone's public key, but only their private key opens it. HTTPS uses it to start every secure connection.

Your browser has never met the online shop's server, yet it sends your card number safely across café Wi-Fi. How do two strangers share a secret in public?

Hashes protect passwords where they're stored. This lesson is about protecting a secret while it travels, between two people who have never met.

How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.

Strangers

Bob wants to send Alice a secret. They've never met, and everything they send can be copied by Eve. A shared key, like a shift cipher's, would have to be sent first. What can Alice do?

TryTry it on the board and compare the result with your prediction.

Try: lock it with Alice's padlock

Was your prediction right?

Try it yourselfYour edits are saved in this browser.

Bob locks the box with Alice's padlock and sends it. Who can read it?

Use the board. This ticks when you get there.

InvestigateWork out why it happens, one step at a time.

Worked example: two keys, two jobs

Worked exampleBefore each step, say what you think comes next.
  1. public key=open padlock\text{public key} = \text{open padlock}Alice gives it to anyone. It can only lock.

Now: who can open it?

Alice has given out hundreds of open padlocks. Who can open a box Bob locks with one?

Sam sends Alice a secret. Click the line where it first goes wrong.

Why doesn't it matter that Eve has one of Alice's padlocks?

ModifyChange the problem on purpose and see what happens.

Vary: one change at a time

Try it yourselfYour edits are saved in this browser.

Now Bob uses his own padlock. Send it. Who can read it?

Use the board. This ticks when you get there.

Send it with no padlock.

Use the board. This ticks when you get there.

Eve copies Alice's private key from her laptop. What can Eve do now?

PractiseA few on your own, to check you have it.

Which key?

Which key do you use to send someone a secret?

A browser shows a padlock beside a shop's address. What does it promise?

Which tool fits? Sort each one.

A site keeps your password so it can check it next time
Your card number on its way to an online shop
Checking a downloaded app is exactly the file its maker published
A private message to a friend across the internet
A news headline anyone can read

MakeMake your own problem using what you have learned. Expect a few tries; that is normal.

Explain HTTPS

Then: why does it matter that the padlock is the shop's, and not one Eve handed you? (Ask your teacher about certificates.)

Your browser has never met the shop's server, and you're on café Wi-Fi with Eve. Explain how your card number reaches the shop without Eve reading it. Say which key does what.

Why can't Eve open the locked secret?

Now you can
Next lesson6. Capture the flag: secure the portalA security team tests a system before attackers do. Use everything from this course to find four weaknesses in a school portal (a lookalike link, a weak password, a wrong permission and an unlocked message), capture a flag for each, then fix the portal and match each weakness to its fix.
For teachers

Students send a message past an eavesdropper locked with Alice's public padlock, see why Bob's own padlock and no padlock both fail, then sort hashes from public key encryption and explain how HTTPS starts (AC9TDI10K01 node 4, second half; Hashes and salt is the first). About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Try the board yourself. Every name is made up.

The kit's typical width: public key cryptography (as in TLS/HTTPS) secures data in transit; hashing (last lesson) secures stored passwords; they address different threats. Split from Hashes and keys on 25 Oct. Simplifications: the padlock is an analogy; HTTPS uses public keys to agree a shared key, then faster encryption for the rest; certificates (who vouches that a public key really is the shop's) are a stretch question, not taught.

Links: Secret messages' key sharing (agreeing a key in public) is the other half of how HTTPS starts.

Running the lesson

  1. Predict: students who chose "send Bob the key first" haven't met the problem: ask what Eve does with the key.
  2. Try: ask what Eve has. (The box and a padlock.) What is she missing?
  3. Worked example: ask why the key that opens must never travel.
  4. Vary: ask why Bob's own padlock is safe from Eve but useless to Alice.
  5. Make: compare two students' explanations against the criteria before showing the model.

The hard part (on purpose)

The public key only locks, which runs against intuition (a key that doesn't open?). Use the padlock as the anchor all lesson: anyone can snap one shut.

When students get stuck

Stretch and support

Stretch: Eve hands you a padlock and says it's the shop's. How would you know? Look up what a certificate is.

Support: A card: public key = open padlock (anyone locks); private key = the only key (only the owner opens). Lock with theirs.

Where it leads

Next: Capture the flag (use everything from this course to find and fix the weaknesses in a school portal).

Links: Secret messages (key sharing, challenge and response).

What each step is for