Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Harvest now, decrypt later and KEMs

After this lesson: I can explain why encrypted traffic recorded today is at risk from a future quantum computer.

60 min lesson8 commandsPost-quantum cryptography lab: ML-KEM, ML-DSA, hybrid TLS and post-quantum SSH with OpenSSL 3.5 and OpenSSH 10

Why post-quantum cryptography matters today

Post-quantum cryptography is public-key cryptography that a large quantum computer is not known to break. It matters today because traffic recorded now can be decrypted later, once such a computer exists.

Picture a hospital sending patient notes over a VPN. Someone copies the encrypted traffic and stores it. In fifteen years the notes are still private, and still on that disk.

By the end of this lesson

Note

I can explain why encrypted traffic recorded today is at risk from a future quantum computer.

Key words

WordWhat it means
Quantum computera machine using qubits that could run Shor's algorithm
Shor's algorithma quantum method that breaks RSA and elliptic curves
Harvest now, decrypt laterrecording traffic today to break it in future
Key exchangetwo computers agreeing a secret over an open network
KEMkey encapsulation mechanism: sending a fresh secret with a public key
Shelf lifehow many years data must stay secret

The cells students fill in are left blank in this preview.

What harvest now, decrypt later means

An attacker cannot break today's key exchange. But copying encrypted traffic is cheap, and disks are cheap too. So a patient attacker records now and waits.

If a large quantum computer arrives, it can recover the key exchange's secret from the recording. Every message protected by that secret then opens. Nothing you change later can protect a recording that already exists.

Worked example: how long data stays secret

What is sentShelf lifeStill secret in 15 years?
A canteen menu0 yearsNo, nobody cares
A card payment2 yearsNo, the card has expired
Payroll records7 yearsNo, but close
Patient notes30 yearsYes, and harmful if read

The cells students fill in are left blank in this preview.

Mosca's rule: x plus y against z

The researcher Michele Mosca gave a simple test. Let x be the shelf life and y the years your migration will take. Let z be the years until a quantum computer breaks your key exchange.

If x plus y is more than z, you are already late. Nobody knows z, so try several values and see which data fails first.

Worked example: who is late?

Datax shelf lifey migrationx + yz = 12: at risk?
Card payment257No, 5 years to spare
Payroll7512No, 0 years to spare
Research data12517Yes, 5 years late
Patient notes30535Yes, 23 years late

The cells students fill in are left blank in this preview.

What a quantum computer breaks, and what not

Shor's algorithm breaks public-key maths built on factoring or discrete logarithms. That is RSA, Diffie-Hellman, ECDH, X25519, ECDSA and Ed25519.

Symmetric ciphers and hashes are different. The best known quantum attack, Grover's algorithm, only roughly halves their strength. AES-256 and SHA-256 stay safe, so only the public-key parts need replacing.

A common mistake

Warning

Many people think nothing needs to change until a quantum computer exists. That is true for signatures, which are checked now. It is false for key exchange, because a recording made today can be broken later. So key exchange moves first.

How a KEM sends a fresh secret

A key encapsulation mechanism, or KEM, has three steps. Key generation makes a key pair. Encapsulation takes the public key alone and gives a ciphertext and a fresh 32-byte secret. Decapsulation takes the private key and the ciphertext and gives back the same secret.

ML-KEM, standardised in 2024, is the post-quantum KEM. Lesson 2 runs all three steps.

A classical exchange in the lab

In the pq-lab, the service pq is your workstation. Each Run reaches it with docker exec pq. The Runs below agree a secret with X25519, the classical exchange most HTTPS and SSH use today.

This is exactly the kind of exchange a recording could break later. Alice and Bob each make a key pair, swap public keys and derive the same secret.

Which OpenSSL is in the lab

Command
docker exec pq openssl version

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Alice makes an X25519 key pair

Command
docker exec pq openssl genpkey -algorithm X25519 -out alice-x.pem

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Bob makes an X25519 key pair

Command
docker exec pq openssl genpkey -algorithm X25519 -out bob-x.pem

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Copy out Alice's public key

Command
docker exec pq openssl pkey -in alice-x.pem -pubout -out alice-x.pub

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Copy out Bob's public key

Command
docker exec pq openssl pkey -in bob-x.pem -pubout -out bob-x.pub

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Alice derives the shared secret

Command
docker exec pq openssl pkeyutl -derive -inkey alice-x.pem -peerkey bob-x.pub -out alice-shared.bin

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Bob derives the shared secret

Command
docker exec pq openssl pkeyutl -derive -inkey bob-x.pem -peerkey alice-x.pub -out bob-shared.bin

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Compare the two secrets

Command
docker exec pq diff -qs alice-shared.bin bob-shared.bin

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

What the Runs print

RunWhat it prints
openssl versionOpenSSL 3.5.7 9 Jun 2026 (Library: OpenSSL 3.5.7 9 Jun 2026)
genpkey, pkey and both derivesNothing: each writes a file
diff -qsFiles alice-shared.bin and bob-shared.bin are identical

The cells students fill in are left blank in this preview.

About this lab and its source: Post-quantum cryptography lab: ML-KEM, ML-DSA, hybrid TLS and post-quantum SSH with OpenSSL 3.5 and OpenSSH 10

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.