# What is Perfect forward secrecy?

I have read that when a user contacts an entity like a bank, it creates a pre-master key and then selects a master key for subsequent communications.

Can the lack of PFS, create a security flaw if the pre-master key and master key are random and different for each session?

How can the knowledge of the private key help a hacker to decrypt old communications? Are the pre-master key and master keys stored on the server?

I have also read that just like PFS, it works by using an ephemeral/time-varying key.

So can any key exchange/encryption algorithm, which ensures keys are discarded after each session, be regarded as a PFS system?

I am finding it hard to understand the differences.

As indicated in Forward Secrecy Article of Wikipedia;

In cryptography, forward secrecy (FS), also known as perfect forward secrecy (PFS), is a feature of specific key agreement protocols that gives assurances your session keys will not be compromised even if the private key of the server is compromised. Forward secrecy protects past sessions against future compromises of secret keys or passwords. By generating a unique session key for every session a user initiates, even the compromise of a single session key will not affect any data other than that exchanged in the specific session protected by that particular key

$$\text{perfect forward secrecy} = \text{forward secrecy}$$

• how can lack of PFS, create a security flaw if the pre-master key and master key are random and different for each session?

Generating a unique session key that cannot be reconstructed then it is already forward secrecy. The process of key generation, as a result, requires a randomly generated numbers, as in Diffie–Hellman key exchange

• how can knowledge of the private key, helps the hacker to decrypt old communication? are the pre-master key and master keys stored by the server? In forward secrecy,

There is no way if the forward secrecy is applied since one cannot construct old (randomly generated) keys from the pre-master and master keys.

• I read like PFS, works by using an ephemeral/time-varying key.

Yes, your reading is correct. The key is called ephemeral if generated for each key exchange protocol. Note the little difference, Wikipedia states a case that ephemeral keys in some cases used more than once.

• So could any key exchange/ encryption algorithm which ensures keys are discarded after each session be called as PFS?

You need to discard once the key is used, otherwise, you let the attacker decrypt the old messages that he stored before attacking your machine to steal the master key.

What is the reason for storing the old cryptographic keys when you don't need them? Delete them as soon as the usage is finished. In this way, you are betraying the Forward secrecy, forget them!