๐Ÿ”‘ Cryptography

Symmetric vs asymmetric cryptography: differences and uses

A shared key or a key pair? How symmetric and asymmetric cryptography work, their strengths and limits, and why real-world systems use them together.

When talking about encryption, the first distinction to make is between symmetric and asymmetric cryptography. They are not competing alternatives: they solve different problems, and almost every system you use daily combines them. Understanding the role of each is the first step to finding your way in any discussion about data security.

Symmetric cryptography: a single key

In symmetric cryptography the same key is used both to encrypt and to decrypt. It is like a safe with a combination: whoever knows it can lock and unlock.

Modern symmetric algorithms, such as AES or ChaCha20, have three important characteristics:

  • they are very fast: a current processor encrypts gigabytes of data per second, often with dedicated hardware instructions;
  • they use short keys: 128 or 256 bits are enough for long-term security;
  • they produce ciphertext about the same size as the original, with a small overhead.

That is why symmetric encryption is everywhere: encrypted disks, protected archives, network traffic, backups.

The distribution problem

There is only one limitation, but it is huge: how do you end up with the same key as the other party without anyone else intercepting it? If you need to communicate with a website you have never visited, you cannot meet the operator to exchange the key in person. And if you communicate with a hundred different people, you need a hundred different keys, each of which must be protected.

Asymmetric cryptography: a key pair

Asymmetric cryptography, also called public-key cryptography, uses two mathematically linked keys:

  • a public key, which you can share freely;
  • a private key, which must remain yours alone.

Whatever is encrypted with the public key can only be decrypted with the matching private key. The classic analogy is an open padlock: you can give it to anyone, anyone can lock a box with it, but only you hold the key to open it again.

The same pair also allows the reverse operation, the digital signature: with the private key you produce a signature that anyone can verify using your public key. This proves the origin and integrity of a message.

The best-known asymmetric algorithms are RSA and those based on elliptic curves, such as ECDH for key exchange and Ed25519 or ECDSA for signatures.

The limits of asymmetric cryptography

Public-key cryptography comes at a price:

  • it is much slower than symmetric cryptography, by several orders of magnitude;
  • it requires longer keys for the same level of security (RSA typically uses 2048 or 3072 bits);
  • in some schemes it can directly encrypt only small amounts of data.

There is also a new problem: how do you know that a public key really belongs to the person who claims to own it? This is where certificates and certificate authorities come in.

A direct comparison

Aspect Symmetric Asymmetric
Keys One, shared Public/private pair
Speed Very high Low
Typical key length 128-256 bits 2048-3072 bits (RSA), 256 bits (elliptic curves)
Main problem Distributing the key Verifying who owns the public key
Typical uses Encrypting large volumes of data Key exchange, digital signatures

The real-world solution: hybrid encryption

Real systems use both, each for what it does best. The scheme is called hybrid encryption and works like this:

  1. a random symmetric key, called the session key, is generated;
  2. the actual data is encrypted quickly with this key;
  3. the session key is protected with asymmetric cryptography, either by encrypting it with the recipient's public key or by agreeing on it through a key exchange;
  4. the recipient recovers the session key with their private key and decrypts the data.

When you open a website over HTTPS, something very similar happens: the asymmetric part is used to establish a shared secret and authenticate the server, then all the traffic travels under symmetric encryption. The same principle applies to emails encrypted with PGP and to messaging apps with end-to-end encryption.

A concrete example

Imagine you want to send a colleague a 2 GB archive. Encrypting all of it with RSA would be extremely slow and technically awkward. With the hybrid scheme, the program generates an AES key, encrypts the archive in a few seconds, then encrypts only those 32 bytes of key with your colleague's public key. The recipient receives the encrypted archive and the small envelope containing the key: only they can open the envelope, and therefore the archive.

Which one is "more secure"?

The question is badly framed. Both, when used with modern algorithms and adequate keys, offer security that cannot be broken by brute force today. Real problems almost always arise elsewhere: poorly protected private keys, weak passwords used to protect keys, home-made implementations, unverified certificates. Choosing between symmetric and asymmetric is not a matter of strength but of which problem you need to solve.

In short

  • Symmetric cryptography uses a single shared key and is extremely fast, but raises the problem of how to distribute that key.
  • Asymmetric cryptography uses a key pair and solves distribution, but it is slow and requires verifying who owns the public key.
  • Digital signatures are an application of asymmetric cryptography.
  • Real systems, from HTTPS to PGP, use hybrid encryption: asymmetric for the keys, symmetric for the data.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also