Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Perfect Forward Secrecy | TLS 1.3, Cipher Suites, And Modern Crypto
TLS and HTTPS Internals

Perfect Forward Secrecy

Pyyhkäise näyttääksesi valikon

Imagine someone is sitting on the wire today, recording everything that flows between you and your bank. They can't read it — it's encrypted. But they save it. Petabytes of encrypted traffic in a warehouse, waiting.

Five years from now, they break into the bank's servers and steal the private key. The question — can they go back and decrypt all that saved traffic?

Without Perfect Forward Secrecy, the answer is yes. Every single byte. Bank logins, emails, passwords, the lot. All retroactively decrypted. With PFS, the answer is no — even with the stolen key, the past stays sealed.

This is the most important security property TLS gained in the last decade. In 2026 it matters more than ever because of one specific threat: Harvest Now, Decrypt Later — nation-state attackers recording today's encrypted traffic, betting that quantum computers will eventually break the math.

What's Going Wrong Without PFS

In the old TLS handshake (RSA key exchange, the default in TLS 1.0 and 1.1, optional in 1.2), the server's long-term private key did two jobs:

  • Authenticate the server (signing the handshake);
  • Decrypt the shared secret the client picked and sent over.

The client would generate a random symmetric key, encrypt it with the server's public key, and ship it. The server would decrypt it using its private key. Now both sides had the symmetric key. Conversation proceeds.

The problem is that the symmetric key was sent encrypted with the long-term public key. So the wire recording contains, in encrypted form, every symmetric key the server ever used. If you ever get the long-term private key, you can decrypt every recorded handshake. Every recorded handshake gives you the symmetric key. The symmetric key gives you the conversation.

One key compromise → all past traffic decrypted forever.

What PFS Does Differently

The fix is to never use the long-term key for encryption. Use it only to authenticate. For the actual key agreement, generate a brand-new ephemeral key pair on every connection. Use it, derive the shared secret, throw it away immediately.

Concretely, with ECDHE (Elliptic Curve Diffie-Hellman Ephemeral):

  • The server has its long-term certificate key — used only to sign the ephemeral key exchange, proving "this ephemeral key really came from me";
  • For each new connection, the server generates a fresh ephemeral elliptic curve key pair;
  • The client also generates a fresh ephemeral key pair;
  • Both sides do the Diffie-Hellman math to derive the shared secret;
  • The ephemeral private keys are immediately discarded — never written to disk, never logged, gone within milliseconds.

Now imagine the attacker has all your wire recordings and steals the long-term key. They can verify signatures over the recordings, but the ephemeral keys are gone. The shared secret was never sent on the wire — it was derived independently by each side from values whose private halves no longer exist. The traffic stays encrypted forever.

This is what the "E" in ECDHE buys you.

The Math In One Paragraph

If you've never seen Diffie-Hellman before, here's the gist. Both sides agree on a public parameter (a curve, for ECDHE). The client picks a random number a and sends g^a (the public part). The server picks a random number b and sends g^b. Both sides compute (g^a)^b = (g^b)^a = g^(a*b) — the shared secret. The eavesdropper sees g^a and g^b on the wire but can't compute g^(a*b) without solving the discrete logarithm problem, which is hard.

The private values a and b never leave the respective machines. After the handshake, they're discarded. There's nothing left to steal.

TLS 1.3 Makes PFS Mandatory

In TLS 1.2, PFS was optional. Servers could be configured with cipher suites like RSA-AES256-GCM-SHA384 — no ECDHE prefix, no PFS. Plenty of older configs still ran this way for years. Auditors checked for it.

In TLS 1.3, every key exchange is ephemeral. There is no non-PFS option. The five TLS 1.3 cipher suites we saw last chapter all implicitly use ECDHE (or PSK, which has different properties). If you're running TLS 1.3, you already have PFS.

Why This Matters In 2026 — Harvest Now, Decrypt Later

PFS used to be a "nice to have" — protection against the unlikely event of a server compromise years from now. Today, it's mission-critical, because the threat model changed.

Intelligence agencies and well-funded adversaries are believed to be recording vast volumes of encrypted traffic right now, with no current way to read it. They're betting that:

  • Quantum computers will eventually break elliptic curve and RSA cryptography (perhaps a decade out, perhaps much longer);
  • When that happens, they'll have a giant archive of yesterday's "encrypted" traffic to read.

This is called Harvest Now, Decrypt Later. PFS doesn't fully solve it — quantum attacks against the ephemeral keys themselves could still work in principle — which is why the industry is also adding post-quantum key agreement (we cover that briefly at the end of Section 3). But PFS makes the attacker's job dramatically harder, because they can't just steal one key and unlock everything.

How To Check You Have PFS

On any server, run:

openssl s_client -connect example.com:443 -tls1_2 < /dev/null 2>/dev/null \
  | grep -E "Protocol|Cipher"

If you see a cipher suite starting with ECDHE- or DHE-, you have PFS. If you see anything starting with plain RSA- or AES- without an ephemeral key exchange, you don't.

For TLS 1.3, simply being on TLS 1.3 means you have PFS. There's nothing to check.

question-icon

In the cipher suite name ECDHE-RSA-AES256-GCM-SHA384, what does the letter E at the end of ECDHE stand for? Enter a single word.

Answer:
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 3

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Osio 2. Luku 3
some-alt