Two ways to lock a message
The padlock analogy helps. In symmetric cryptography, one key both closes and opens the padlock, so both parties need a copy of it. Examples include AES, which is widely used for encrypting data.
In asymmetric cryptography, each person has a key pair. The public key works like an open padlock that anyone can snap shut. Only the matching private key can open it. Examples include RSA and elliptic curve schemes.
How the key pair works
The two keys are linked by a mathematical problem that is easy to compute in one direction and very hard to reverse. RSA relies on the difficulty of factoring a large number into its primes. Knowing the public key does not let an attacker practically work out the private key when key sizes are chosen properly.
For confidentiality, a sender encrypts with the recipient's public key, and the recipient decrypts with the private key. For digital signatures, the signer uses the private key, and anyone can check the result with the public key.
A worked case: sharing a secret with ten people
Suppose a group of 10 people wants each pair to communicate privately using symmetric keys. The number of pairs is 10 x 9 / 2 = 45 keys, and each key must first be delivered by a safe route.
With public key cryptography, each person holds one key pair. That is 10 key pairs, and the 10 public keys can be published openly. Anyone can then send an encrypted message to anyone else without a prior secret exchange.
Common misconceptions
One belief is that public key cryptography replaces symmetric cryptography. It usually does not. Asymmetric operations are much slower, so systems typically use them to agree on or protect a symmetric session key, and then encrypt the bulk data with the symmetric cipher.
Another belief is that a public key proves who owns it. It does not by itself. Certificates issued by certificate authorities bind a public key to an identity, and a user must still trust that authority. The private key must also not be shared, because anyone holding it can decrypt messages or forge signatures.
Where it shows up
HTTPS uses TLS, which relies on public key methods to authenticate a server and establish a session key. SSH uses key pairs to log in to remote machines. Software and code signing depend on digital signatures.
Key terms
- Symmetric cryptography
- A method in which the same secret key encrypts and decrypts data.
- Asymmetric cryptography
- A method that uses a linked public key and private key.
- Public key
- The key in a pair that can be shared openly.
- Private key
- The key in a pair that its owner keeps secret.
- Digital signature
- A value created with a private key that anyone can verify with the matching public key.
- Certificate
- A signed document that links a public key to an identity.
- Session key
- A temporary symmetric key used to encrypt the data of one communication session.
