Which keys are used to encrypt and decrypt data in asymmetric cryptography?

Today we’re talking about encryption, but not salting or hashing, even though the two are often associated with one another when storing things like passwords in a secure manner. They are actually very different, and this post focuses on encryption.

A Quick Overview of Encryption

Encryption is a method of turning data into a form that, while keeping its original meaning intact, is not understandable by anyone without a decryption key.

Think of the process of encryption as having a letter in an envelope stored in a sealed container with a lock on it.  Nobody can open that container and read the contents of the letter without the key associated with the lock on the box.

And that’s it—the basic premise of encryption.  What changes from encryption type to encryption type are the types of “locks” and the types of “keys” that are used to conceal the data that is being sent.

There are Two Types of Encryption

In the context of encryption keys, there are two main types of encryption: symmetric and asymmetric.

Some encryption algorithms will use a combination of symmetric and asymmetric, such as in SSL data transmission

Symmetric encryption requires that the same key used to lock the box is the one that is used to open the box.  Asymmetric encryption means one key is used to lock the box, and a different key is used to unlock the box (and ONLY that key can unlock the box).

Many types of encryption algorithms will use either symmetric or asymmetric, or in some cases, a combination of both, such as in SSL data transmission.

Use of Symmetric Encryption

You’ve probably heard of Advanced Encryption Standard (AES), such as AES-256 Encryption. (This is the standard we use for encrypting data stored in Secret Server.)  This is a type of symmetric encryption where a single Master Key is used to both encrypt and decrypt the data.  AES is an extremely fast encryption protocol both at the hardware and the software level.

AES-256 Encryption is the standard approved by the NSA for encrypting Top Secret information.

Use of Asymmetric Encryption

Asymmetric encryption is the type that is used most frequently to securely send data from one machine to another.  Remember, asymmetric has a single lock with two keys.  One key is called the Private Key and the other key is called the Public Key.  Anything encrypted with the Public Key can ONLY be decrypted with the Private Key; a public key CANNOT decrypt data if it was used to encrypt the data—ONLY the private key can unlock that data.

Therefore, the Public Key is not something that necessarily needs to be safeguarded, and in fact, it usually isn’t.  When people or organizations (like news agencies) want to receive sensitive encrypted data, they will send their public key out to people, who can use it to encrypt the data and send it to the holder of the private key.  Once the Private Keyholder has the encrypted data (again, encrypted with the public key), then that person (and only that person) can decrypt the message.

Often Public/Private Keypairs are also used to authenticate someone into an endpoint—such as a Linux machine using SSH.

This also works in reverse, for proving the validity of a message that came from a single person, but that is outside the scope of this article.

At PreVeil we often find ourselves explaining to our customers the concepts of how public and private keys work. We thought it would be helpful to discuss what these keys are, what they aren’t, and how they work.

The blog below provides a general overview on public and private key pairs rather than an architectural overview of PreVeil. For a detailed understanding of PreVeil’s public-private key architecture, please check out our architectural whitepaper.

How public and private key encryption works

Public and private keys form the basis for public key cryptography , also known as asymmetric cryptography. In public key cryptography, every public key matches to only one private key. Together, they are used to encrypt and decrypt messages. If you encode a message using a person’s public key, they can only decode it using their matching private key.

Public and private keys: an example

Bob wants to send Alice an encrypted email. To do this, Bob takes Alice’s public key and encrypts his message to her. Then, when Alice receives the message, she takes the private key that is known only to her in order to decrypt the message from Bob.

Although attackers might try to compromise the server and read the message, they will be unable to because they lack the private key to decrypt the message. Only Alice will be able to decrypt the message as she is the only one with the private key. And, when Alice wants to reply, she simply repeats the process, encrypting her message to Bob using Bob’s public key.


More on how public and private keys are used:
Whitepaper: PreVeil Security and Design
Article: End-to-end encryption

The difference between public and private keys

Public keys have been described by some as being like a business’ address on the web – it’s public and anyone can look it up and share it widely. In asymmetric encryption, public keys can be shared with everyone in the system. Once the sender has the public key, he uses it to encrypt his message.

Each public key comes paired with a unique private key. Think of a private key as akin to the key to the front door of a business where only you have a copy. This defines one of the main differences between the two types of keys. The private key ensures only you can get through the front door. In the case of encrypted messages, you use this private key to decrypt messages

Together, these keys help to ensure the security of the exchanged data. A message encrypted with the public key cannot be decrypted without using the corresponding private key.

Which keys are used to encrypt and decrypt data in asymmetric cryptography?

Generating public and private keys

The public and private key are not really keys but rather are really large prime numbers that are mathematically related to one another. Being related in this case means that whatever is encrypted by the public key can only be decrypted by the related private key.

A person cannot guess the private key based on knowing the public key. Because of this, a public key can be freely shared. The private key however belongs to only one person.

There are several well-known mathematical algorithms that are used to produce the public and private key. Some well-respected algorithms include:

  • Rivest-Shamir-Adelman (RSA) – Oldest of the public-private key cryptography systems. Frequently used to transmit shared keys for symmetric key cryptography
  • Digital Signature Standard (DSS) – a Federal Information Processing Standard specifying the algorithms that can be used to generate digital signatures used by NIST
  • Elliptic curve cryptography (ECC)– As its name implies, ECC relies on elliptic curves to generate keys. Often used for key agreement and digital signatures. At PreVeil, we use elliptic-curve cryptography’s Curve-25519 and NIST P-256.

Summary Public key cryptography

Public key cryptography provides the basis for securely sending and receiving messages with anyone whose public key you can access.

Public keys enable:

  • Users to encrypt a message to other individuals on the system
  • You can confirm a signature signed by someone’s private key

Private keys enable:

  • You can decrypt a message secured by your public key
  • You can sign your message with your private key so that the recipients know the message could only have come from you.

Public-private key encryption: Real world examples

Digital signatures

Public and private keys can also be used to create a digital signature. A digital signature assures that the person sending the message is who they claim to be.

Typically, we use the recipient’s public key to encrypt the data and the recipient then uses their private key to decrypt the data. However, using the scheme of digital signatures, there’s no way to authenticate the source of the message. Mike could get a hold of Alice’s public key (since it’s public) and pretend that Bob is the person sending a message to Alice.

To create a digital signature, Bob digitally signs his email to Alice using his private key. When Alice receives the message from Bob, she can verify the digital signature on the message came from Bob by using his public key. As the digital signature uses Bob’s private key, Bob is the only person who could create the signature.

PreVeil’s method for securing messages is a bit more complex than the example provided above. However, the example provides a good general overview for how asymmetric encryption works.

Which keys are used to encrypt and decrypt data in asymmetric cryptography?

Diffie-Helman key exchange

The Diffie Hellman key exchange demonstrates an example of how users can securely exchange cryptographic keys over a public channel.

In the past, secure encrypted communication required that the individuals first exchange keys by a secure means such as paper key lists transported by a trusted courier. The Diffie–Hellman key exchange method allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure channel.

PreVeil uses the Diffie Hellman key exchange to enable Web PreVeil. Web PreVeil is a browser based end-to-end encrypted email service that allows users to easily access their secure email account on the web without any software download or any passwords to remember.

Here’s a video to explain how this works:

Business benefits of public private key encryption


By using a public and private key for encryption and decryption, recipients can be confident that the data is what the sender says it is. The recipient is assured of the confidentiality, integrity and authenticity of the data.

Confidentiality is ensured because the content that is secured with the public key can only be decrypted with the private key. This ensures that only the intended recipient can ever review the contents

Integrity is ensured because part of the decryption process requires checking that the received message matches the sent message. This ensures that the message has not been changed in between.

Authenticity is ensured because each message sent by Alice to Bob is also signed by Alice’s private key. The only way to decrypt Alice’s private key is with her public key, which Bob can access. By signing the message with her private key, Alice ensures the authenticity of the message and shows that it really did come from her.

Conclusion

Public and private key pairs form the basis for very strong encryption and data security. If you are interested in reading more about public and private keys, take a look at the following articles:

Which key is used to encrypt data in an asymmetric encryption system?

Asymmetric, or public/private encryption, uses a pair of keys. Data encrypted with one key are decrypted only with the other key in the public/private key pair. When an asymmetric key pair is generated, the public key is typically used to encrypt, and the private key is typically used to decrypt.

Which key is used to encrypt and decrypt the data?

The sender uses a public key to encrypt the message. The recipient uses its private key to decrypt the message. Public key infrastructure (PKI) is a set of hardware, software, organizations, and policies to public key encryption work on the Internet.

Which key is used for decryption in asymmetric key cryptography?

Asymmetric encryption algorithms use two different keys for encryption and decryption. The key used for encryption is the public key, and the key used for decryption is the private key.

How many keys are used in asymmetric key encryption?

Asymmetric encryption is also called public key encryption, but it actually relies on a key pair. Two mathematically related keys, one called the public key and another called the private key, are generated to be used together.