Definition
Forward secrecy, also called perfect forward secrecy (PFS), is a property of a protocol by which two parties agree on session keys: if a party’s long-term key §7.28, the secret it keeps across many sessions to prove its identity, is stolen after a session has ended, that session’s keys stay secret, so the recorded traffic of the session still cannot be decrypted. Protocols achieve it by deriving each session key from short-lived secrets that both parties erase after use, so that nothing stolen later determines an old key.
The idea
An attacker can record encrypted traffic today and wait. If one long-term key can decrypt that traffic, then a single later theft, legal order or software bug that exposes the key exposes every recorded conversation. Older versions of TLS (Transport Layer Security, the protocol that protects web traffic) allowed exactly this with RSA key transport, RSA being a public-key scheme named after Rivest, Shamir and Adleman. The client chose the secret from which the session keys were derived and sent it encrypted under the server’s long-term RSA public key. Whoever later held the server’s private key could decrypt that secret from every recorded handshake, and so decrypt every recorded session. TLS 1.3, published in 2018 as RFC 8446 [325], removed this option.
The remedy is to make each session key depend on a secret that exists only during the session. In ephemeral Diffie–Hellman key agreement §19.1.4, each side draws a fresh random private number for this one session, and the two sides combine public values derived from those numbers into a shared secret. The long-term key is used only to sign the public values, which proves who sent them. After the session both sides erase the private numbers. A later thief obtains a signing key: it can sign new messages, but signing does not help to recompute a secret built from numbers that no longer exist anywhere.
How it works
Signed ephemeral Diffie–Hellman, the pattern that every full TLS 1.3 handshake uses, works as follows. Let be a large public prime and a public number called the generator; all arithmetic is modulo , meaning that only the remainder after division by is kept. Computing from and without knowing or is believed infeasible for well-chosen large groups; this belief is the computational Diffie–Hellman assumption. Most deployments use elliptic-curve §19.1.5 groups, which have the same structure with a different multiplication rule.
Client and server each draw a fresh private value, and , from a cryptographically secure pseudorandom number generator §5.27 (CSPRNG), and compute the public values and .
They exchange and . The server signs the handshake transcript, the record of all handshake messages so far, which contains both public values, with its long-term private key. The client checks that signature with the public key in the server’s certificate, a signed statement that binds the server’s name to that key.
Each side computes the shared secret and derives the session keys from and the transcript with a key derivation function §5.20 (KDF), an algorithm §14.1 that turns a secret into keys.
Each side erases its private value and as soon as the session keys exist, and erases the session keys when the session ends.
Four common designs lack forward secrecy:
key transport under a long-term key, such as the RSA key transport of TLS 1.2 and earlier;
static Diffie–Hellman, in which each party reuses one long-term Diffie–Hellman key for every session, so every session key can be computed from the two long-term keys and the recorded traffic;
deterministic derivation from a kept root secret , in which the key of session is ;
resumption shortcuts that store session secrets encrypted under a long-lived server key, such as TLS session tickets whose encryption key is rarely changed.
Forward secrecy can also be obtained without public-key operations, by a one-way ratchet. Keep a current key . To move to the next period, compute with a one-way function , such as a cryptographic hash function §5.1, and then erase . An attacker who steals the state in period obtains and can compute every later key, but no earlier one, because that would require inverting . This protects past periods against theft of the current state, provided the starting key was erased as well. It does nothing for the periods after the theft; regaining security for those is the subject of post-compromise security §5.34.
Worked example
Take a toy group: the numbers 1 to 22 multiplied modulo the prime , with generator . Real systems use elliptic-curve groups with about elements or primes of at least 2048 bits; these small numbers only make the steps visible. In session 1 the client draws and the server draws . The client’s public value is , because . For the server’s value, square repeatedly: , and , where means equal after reduction modulo 23. Then , so .
The client computes . Since , , so . The server computes : , and , so , again . Both derive the session keys from and then erase 6, 15 and 2.
A year later the attacker steals the server’s long-term signing key. It holds the recording, with , and the server’s signature, and it holds the signing key. None of these yields . To compute the attacker needs or , for example the with , which is a discrete logarithm §19.1.3. In this toy group at most 22 tries find it; in the groups used in practice, no known method on ordinary computers finds it in feasible time.
Compare a design without forward secrecy. A device keeps a root secret and derives the key of session as , the HMAC §5.8 (hash-based message authentication code) of the session number under . A device that opened one session per hour for a year ran sessions. An attacker who later steals recomputes all 8,760 session keys with 8,760 HMAC computations and decrypts every recorded session. That every session had its own key did not help.
Stated precisely
Forward secrecy is defined by an experiment with four stages.
The attacker observes and records any number of sessions between honest parties.
A target session completes, and both parties erase its ephemeral secrets and its session keys.
The attacker then receives the long-term secret keys of both parties.
The attacker is given either the target session’s key or a random string of the same length, and must say which.
The protocol has forward secrecy if no feasible attacker answers correctly with probability noticeably above , the success rate of a blind guess.
The guarantee rests on five assumptions.
A hard group: the Diffie–Hellman problem is infeasible in the chosen group.
A sound KDF: the key derivation function turns into keys that look random to anyone who lacks .
Good randomness: and come from a CSPRNG whose output the attacker cannot predict.
Real erasure: no copy of , , or the session keys survives in memory, swap space, logs, crash dumps or resumption caches.
An authenticated session: in the target session the attacker did not replace the public values. With signed ephemeral Diffie–Hellman this holds for every session that the honest parties completed while the long-term keys were still secret.
Some definitions distinguish weak forward secrecy, which covers only sessions in which the attacker merely listened, from full forward secrecy, which also covers sessions that the attacker tried to tamper with before it held any long-term key.
Limits and common mistakes
Erasure is the assumption most often broken in practice. Keys left in freed memory, in swap files, in crash dumps or in debug logs undo forward secrecy; the secret zeroization §5.37 entry treats erasure.
Forward secrecy protects only sessions that ended before the theft. With the stolen long-term key, the attacker can impersonate its owner in new sessions. Regaining security after a theft is post-compromise security, a separate property.
Forward secrecy does not survive a later break of the key agreement itself. A future quantum computer able to compute discrete logarithms in the groups used today would decrypt recorded sessions despite forward secrecy; recorded traffic is one reason to adopt post-quantum key agreement, designed to resist such computers, early.
An endpoint that is compromised while the session runs exposes the plaintext. Forward secrecy protects keys after the fact, not endpoints during the session.
Distinct keys are not forward secrecy. Per-device or per-session keys that are all derived from a kept root fall together when the root is stolen.
Predictable ephemeral values destroy the property: if came from a weak random number generator, the attacker recomputes instead of stealing it.
Metadata, such as who talked to whom, when and how much, is not protected. The word perfect is historical; the property holds only under the assumptions above.
Questions answered
Does deterministic derivation from a persistent root provide forward secrecy?
No. If every session key is computed by a fixed function from a root secret that is kept, together with public inputs such as labels, counters or device identifiers, then anyone who later obtains the root recomputes every earlier session key and decrypts every recorded session. Making the keys different per session or per device limits the harm of losing one session key, not the harm of losing the root.
Forward secrecy needs the material that can be stolen later to no longer determine the earlier keys. Two designs achieve that. In the first, each session key depends on an ephemeral secret that both sides erase after the session, as in ephemeral Diffie–Hellman key agreement. In the second, the key state is advanced through a one-way function and each old state is erased, as in a hash ratchet. Deterministic derivation qualifies only in the second form, and only for keys whose predecessors, including the original root, have really been erased.
Related entries: Post-compromise security (§5.34), Secret zeroization (§5.37), Root key and root seed (§5.25), Diffie–Hellman key agreement (§19.1.4), Authenticated key exchange and transcript binding (§19.1.6). Further reading: [325].