What Is Asymmetric Encryption And How is it Used?

This is a republication of a post I originally wrote on November 4, 2022 over on my dedicated blog site that I am rolling into wonksecurity.com.

In 2009, I read about asymmetric encryption, also known as public-key cryptography, for the first time in Bruce Schneier’s book, Secrets & Lies. At the time, I did not fully understand the power of asymmetric encryption algorithms, what they could enable, or how cool they actually are. Recently, I had the chance to learn more about encryption while studying for CompTIA’s Security+ exam.

This time around, I started to understand the power of asymmetric encryption, but I also understood why such power was not apparent to me initially. In fact, it seems that asymmetric encryption can be a tricky concept to learn and use. My goal with this post is to provide an overview of asymmetric encryption and to detail some of its power and a couple of use cases.

What is Encryption?

There are entire books on the history of cryptography, but at a basic level encryption is the process of using a cryptographic algorithm to transform a piece of information, referred to as the plaintext, into an encoded version of that information, the ciphertext. The ciphertext ideally should be unreadable by anyone that does not have the key to decrypt the ciphertext back into the plaintext. Encryption algorithms vary from simple, such as the Caesar Cipher, which shifts alphanumeric characters by a set value all the way to highly complex, such as the Advanced Encryption Standard (AES), which uses advanced mathematics and is employed by the U.S. government, among others, to secure classified information.

Symmetric Encryption

The problem with both of these algorithms (ignoring the Caesar Cipher’s simplicity for the moment) lies with the key used to encrypt or decrypt a particular message. Encryption like this uses a symmetric key cipher, meaning the same key that encrypts also decrypts. Using AES is fine to protect a single file stored locally on a user’s computer, but symmetric encryption does not scale well if there are hundreds or thousands of encrypted files, each used by a separate user and each with a separate key to manage. Similarly, if I wanted to share an encrypted file with a friend, sharing the key with that person could be problematic.

A Graphical Representation of Symmetric Encryption. By Phayzfaustyn, CC0, via Wikimedia Commons.
A Graphical Representation of Symmetric Encryption. Phayzfaustyn, CC0, via Wikimedia Commons.

Asymmetric Encryption

That is where asymmetric key encryption comes in. Asymmetric ciphers, such as Rivest-Shamir-Adleman (RSA), Diffie-Hellman, and various elliptic-curve cryptographic algorithms, produce two keys — a public key that can be publicly shared through either key exchanges or simply appended to an email, and a private key, which must remain secret. Both keys are necessary to the encryption process, and one cannot be used to derive the other.

Graphic Showing Each Key Used to Transform the Message. By Bananen🍌falter🦋, CC0, via Wikimedia Commons.
Graphic Showing Each Key Used to Transform the Message. Bananen🍌falter🦋, CC0, via Wikimedia Commons.

With asymmetric key encryption, I can overcome the challenges associated with trying to send encrypted files to a friend or colleague. With a symmetric algorithm, I could send the encrypted message, but the message would be useless to the recipient unless I found a way to send along the key to the recipient as well. If I sent the key via the same method as the message, such as email, the key could be intercepted by an attacker and used to decrypt my message. Asymmetric algorithms allow me to receive my friend’s public key and then begin using their public key to encrypt messages that I send to them, which they then decrypt using their private key.

Graphic Depicting Alice Sending an Encrypted Message to Bob Using Bob’s Public Key. By Winstonlee, CC0, via Wikimedia Commons.
Graphic Depicting Alice Sending an Encrypted Message to Bob Using Bob’s Public Key. Winstonlee, CC0, via Wikimedia Commons.

This is where people typically get lost (myself included the first time I was exposed to the concept), so let me explain a bit more. Each key pair, both public and private, can only be used once in the process of encrypting and decrypting a message. Of course, the key pair can be used to send subsequent messages, but for the process of a single encryption/decryption, each key is used only once.

To elaborate, if I encrypt a file with my public key, I must use my private key to decrypt it. Conversely, if I use my private key to encrypt a file, I must use my public key to decrypt it. However, if I am sending a file to someone else, then I should be using that person’s public key, not my own. If I use my own public key to send an encrypted message to someone else, they do not have my private key, so they cannot decrypt my message. If I use my private key to encrypt a message and send it to someone, anyone who has the public key (not just my intended recipient) can decrypt my message, defeating the purpose of encrypting it in the first place. Furthermore, I should not have my recipient’s private key, so if I want to send a message that is encrypted to my recipient then, by process of elimination, it should become clear that using their public key is my only option. Many thanks to (ISC)² instructor Simon Salmon for explaining proper key usage in this way; I struggled with this until I realized only one key option works.

Asymmetric Encryption in Action

If you’re like me, you read a lot about world affairs on Twitter and have probably come across a PGP public key listed on a person’s profile. It is not uncommon to find investigative journalists, who often get their scoops through leaks from government officials, with a PGP public key somewhere on their Twitter profile so people can reach out to them using encrypted email. PGP, or Pretty Good Privacy, allows for the creation of public-private key pairs to use for email encryption. Other methods, such as GPG can integrate into mail clients like Outlook or Thunderbird and provide the same functionality.

How does it work? Well, a government official, whistleblower, or activist living in a repressive state, would save the journalist’s public key, add it to their own installation of PGP or GPG, encrypt their email using the journalist’s public key and then send the email to the journalist. The journalist would then use their own private key to decrypt and read the message. If back and forth communication was necessary, the person initiating the conversation would have likely appended their own public key to the message so the journalist could reply using the whistleblower’s public key. Problems still exist with this approach; for example, the journalist’s Twitter account could still be compromised to replace the journalist’s public key listing with an attacker’s public key. However, asymmetric encryption certainly helps to increase the chances of maintaining confidentiality by increasing the complexity of trying to intercept and decrypt the whistleblower’s message.

Other people use ProtonMail, which does this asymmetric key encryption behind the scenes when sending or receiving mail to or from another person using ProtonMail. Regardless of the method, it is important to note, as the International Consortium of Investigative Journalists warns on its site, asymmetric encryption does not obscure the message’s metadata. As the the ICIJ’s website states, emails sent using a PGP key may have the message contents encrypted, but the fact that the message was sent in the first place, as well as the time, date, subject, sender, and recipient all remain in plaintext.

Other Uses

While sending encrypted email is certainly useful for ensuring the confidentiality of communications between a tax preparer and a client, for example, there is so much more that asymmetric encryption enables. Asymmetric encryption is also essential to what is known as Public Key Infrastructure (PKI), a critical system for enabling HTTPS (Hypertext Transfer Protocol Secure), the protocol that allows users to connect securely to their bank’s website. HTTPS uses Secure Sockets Layer (SSL) or, more preferably, Transport Layer Security (TLS) to encrypt web traffic to and from a website, enabling users to transmit sensitive information that is reasonably protected against man-in-the-middle attacks by malicious actors or eavesdroppers. The lock icon in the browser window, right next to the web address, signifies a successful HTTPS connection to a website. Conversely, if you are not on an HTTPS site, such as if you went to https://wonksecurity.com, or the secure connection was not established, don’t worry your web browser will probably try to scare you away from using the site (or if I have configured my site correct, you’ll simply be redirected to an HTTPS connection).

At its most basic level, HTTPS uses PKI to authenticate and initiate a secure connection using public keys and certificates to exchange a shared secret that then creates a secure connection between your browser and the site. Asymmetric encryption has a major downside in that it is not very performance friendly, so maintaining a secure connection to a site is actually done through symmetric encryption, which is much less computationally intensive. PKI ensures a secure handshake between you and the server, which allows the sharing of the symmetric key via asymmetric encryption.

Going back to the email example, you can imagine I have sent a large file encrypted using a symmetric algorithm like AES and then used asymmetric key encryption to send the recipient the symmetric key in a secured message that only the recipient can decrypt. PKI is doing this process but in reverse, establishing an agreed upon shared secret between two machines and then beginning to stream symmetrically encrypted data back and forth that is unlocked at either end using that previously shared secret.

But there’s more; PKI not only gets around the conundrum of having to securely exchange symmetric keys to transmit large amounts of encrypted data but also provides a mechanism for two previously unknown parties (a new user and a company’s login server, for example) to prove their identities to each other. This prevents the user from having to go find some random server’s public key for every website that the user visits. There is a lot more that goes into PKI than this top-level overview, but that is a topic for a separate post.

I hope that this rundown of asymmetric key encryption has been helpful in explaining a bit more about the concept as well as some use cases. I plan to continue writing these posts as I continue to learn. I am a firm believer that explaining a concept is the best way to learn, so sharing

Scroll to Top