1. Library
  2. Ssl and Tls
  3. Basics

Updated 10 hours ago

Here's a problem that plagued cryptography for centuries: symmetric encryption is fast and secure, but both parties need the same secret key. How do you share that key when your only communication channel is the one you're trying to secure?

Send the key in the open, and anyone listening can read everything. Meet in person first, and you can't communicate with strangers. Use a courier, and you're trusting your security to whoever carries the message.

This chicken-and-egg problem seemed unsolvable. Then, in 1976, Whitfield Diffie and Martin Hellman published a paper that changed everything.

Symmetric Encryption: Fast, but There's a Catch

Symmetric encryption uses the same key for both encryption and decryption—like a traditional lock where the same physical key locks and unlocks the door.

When Alice wants to send Bob an encrypted message, she encrypts it with their shared secret key, sends the ciphertext, and Bob decrypts it with the same key. Simple, elegant, and blazingly fast. Modern symmetric ciphers like AES can encrypt gigabytes per second on typical hardware.

The catch: Alice and Bob must both possess the same key. If they've never met and their communication channel might be monitored, how do they agree on that key without an eavesdropper learning it too?

Common Symmetric Algorithms

AES (Advanced Encryption Standard) is the gold standard. Adopted by the U.S. government in 2001, it supports key sizes of 128, 192, or 256 bits. It's fast, secure, and implemented in hardware on most modern processors.

ChaCha20 is a modern alternative designed by Daniel Bernstein. It's particularly efficient on devices without AES hardware acceleration, like older mobile phones. TLS 1.3 includes ChaCha20-Poly1305 as a standard cipher suite.

3DES was once common but is now deprecated—too slow, and its 64-bit block size creates vulnerabilities at scale.

Asymmetric Encryption: The Impossible Solution

Asymmetric encryption uses two mathematically related keys: a public key and a private key. The magic is that you cannot derive the private key from the public key—not with any computer that exists or will exist for the foreseeable future.

The public key encrypts. Only the corresponding private key decrypts.

This changes everything. Bob generates a key pair, publishes his public key openly, and keeps his private key secret. Anyone can encrypt a message to Bob using his public key. Only Bob can decrypt it.

You can shout your public key from the rooftops, and it only helps people send you secrets—it never helps them read yours.

The key distribution problem dissolves. No secret information needs to be exchanged in advance. No couriers, no secret meetings, no trusted intermediaries. Two strangers on opposite sides of the planet can establish secure communication through a channel that's completely monitored.

The cost? Asymmetric encryption is slow—100 to 1,000 times slower than symmetric encryption. You wouldn't want to encrypt a video stream with it.

Common Asymmetric Algorithms

RSA is the most well-known. Its security relies on the difficulty of factoring large numbers. Key sizes of 2048 bits are standard, with 3072 or 4096 bits for higher security.

Elliptic Curve Cryptography (ECC) provides equivalent security with much smaller keys. A 256-bit ECC key matches a 3072-bit RSA key in security, making ECC faster and more efficient. Modern TLS prefers ECC.

Diffie-Hellman is designed specifically for key exchange. Two parties can agree on a shared secret over an insecure channel without ever transmitting the secret itself. When used with ephemeral keys (ECDHE), it provides Perfect Forward Secrecy.

Digital Signatures: The Reverse Trick

Asymmetric encryption enables something else remarkable: digital signatures.

If you encrypt data with your private key, anyone can decrypt it with your public key. This doesn't hide the message—anyone can read it. But it proves you wrote it. Only someone with the private key could have created that ciphertext.

In practice, you don't sign the entire message (too slow). You hash the message and sign the hash. The signature proves both authenticity (it came from you) and integrity (it hasn't been modified).

This is how TLS certificates work. Certificate Authorities sign certificates with their private keys. Your browser verifies those signatures using the CA's public key.

How TLS Combines Both

TLS is a clever hack: use asymmetric encryption to solve the key distribution problem, then switch to symmetric encryption for speed.

During the handshake, asymmetric cryptography does the heavy lifting. The server proves its identity through a certificate containing its public key, signed by a trusted Certificate Authority. Client and server use algorithms like ECDHE to agree on a shared secret without transmitting it.

During data transfer, symmetric encryption takes over. Once both sides have the shared secret, all communication uses fast symmetric encryption like AES. The slow asymmetric algorithms have done their job—they're no longer needed.

This hybrid approach gives you the best of both worlds: the security of asymmetric key exchange with the performance of symmetric bulk encryption.

Perfect Forward Secrecy

The choice of key exchange algorithm has lasting consequences.

Older TLS configurations used RSA key exchange: the client encrypts a secret with the server's public RSA key. Simple, but dangerous. If that server's private key is ever compromised—even years later—every past conversation can be decrypted.

Ephemeral Diffie-Hellman (DHE/ECDHE) solves this. Each session generates temporary keys that are discarded immediately after use. Compromise the server's long-term key, and past sessions remain secure. The ephemeral keys no longer exist.

TLS 1.3 mandates Perfect Forward Secrecy by removing RSA key exchange entirely.

Comparing Key Sizes

Different algorithms achieve equivalent security with different key sizes:

Security LevelAESRSAECC
128 bitsAES-128RSA-3072ECC-256
192 bitsAES-192RSA-7680ECC-384
256 bitsAES-256RSA-15360ECC-521

This is why ECC has largely replaced RSA in modern TLS—equivalent security with keys an order of magnitude smaller.

The Quantum Threat

Current asymmetric algorithms rely on mathematical problems that classical computers find hard: factoring large numbers, solving discrete logarithms. Quantum computers, if built at sufficient scale, could solve these efficiently using Shor's algorithm. RSA, ECC, and traditional Diffie-Hellman would all break.

Symmetric encryption is more resilient. Grover's algorithm halves the effective key size, so AES-256 would provide 128 bits of security against quantum computers—still perfectly adequate.

This asymmetry is driving research into post-quantum cryptography: new asymmetric algorithms resistant to quantum attacks. NIST is standardizing these algorithms now, and experimental TLS implementations already exist.

Frequently Asked Questions About Symmetric vs. Asymmetric Encryption

Was this page helpful?

😔
🤨
😃