**Asymmetric Encryption - VPN Tutorial**

**Asymmetric Encryption Traffic - Data Encryption**

Symmetric keys provide confidentiality and are very fast compared to asymmetric encryption. However unlike asymmetric encryption they do not provide authentication or nonrepudation. Symmetric encryption also does not provide any scalability or key distribution.

In asymmetric encryption an entity has two different keys, which are mathematically related, a public key and a private key. Everyone is allowed to see the public key, but the private key has to remain hidden. The public and private key can only encrypt and decrypt messages that have been encrypted or decrypted by one of the two. So for example if Barclays bank encrypted a message using their own private key, it can only be decrypted using their public key, and if they encrypted the same message using their public key, this key can only be decrypted using their private key, as both keys are different but mathematically related.

Asymmetric encryption is much more scalable because you have two keys and can hand your public key out to the world, not requiring to keep a track of who has the key. With symmetric keys, you need to ensure only the entities intended to communicate with you securely has your key and no one else, which does not scale well at all.

### Authentication and Non-repudiation with Public keys

If Barclays bank wanted to provide authentication and non-repudiation, they can encrypt data with their own private key, and anyone who decrypts this data with their public key can be assured it came from them (Barclays), as only their public key can decrypt what was encrypted with their private key. This assures users the data was sent and secured by Barclays bank, and this also assure non-repudiation which means Barclays can not deny the data was not sent from them.

### Providing confidentiality using public keys

If confidentiality was needed over the public network then a user can encrypt data using Barclays bank public key. Barclays bank can only decrypt this data as they hold the corresponding private key for that public key.

### Providing confidentiality, authentication and non-repudiation

If Barclays bank wanted to provide all, authentication, non-repudiation, and confidentiality to another bank, they would first encrypt the message using the other bank’s public key and then encrypt again using their own private key. So when the other bank receives this packet, they will first decrypt the message using Barclays bank public key which would assure it came from Barclays, and then they would decrypt the packet again using their own private key, which would assure confidentiality.

Remember when Barclays encrypted this message with the other banks public key, this would provide confidentiality because no one else but the other bank can decrypt the message as only they hold the private key which is mathematically related to their public key. Also when Barclays bank encrypted the message with their own private key, this provides authentication because only the public key that is accessible to everyone can decrypt the messages which would prove it cam from Barclays bank. The clever point is not everyone can see the final message other than the bank it was intended for, because it was encrypted twice. The first part everyone can decrypt, which would only provide authenticity, but the second decryption required the other bank’s private key which only they have access to as it was encrypted with their public key.

Although asymmetric systems are much slower and require more processing power than symmetric systems, they are much more scalable, provide key distribution and provide authentication and non-repudiation. Asymmetric algorithms require much larger keys than symmetric keys to provide sufficient level of security over the public network.

### The Hybrid system

Asymmetric algorithms are much slower than symmetric algorithms, and so for large amounts of data this process can be very slow. We can not use a symmetric algorithm as key distribution is a problem, and we may need to prove authenticity and non-repudiation. However we have a clever way of using a hybrid system intended to eliminate this issue. In a hybrid system we use both symmetric and asymmetric encryption.

In a hybrid system Barclays Bank would create a symmetric key, and encrypt bulk data with this key. Then Barclays Bank would encrypt the symmetric key using the public key of the other bank. Then Barclays bank will send both the bulk data which was encrypted using the fast symmetric encryption and send the key which was encrypted using the public key system in which only the other bank can decrypt. So we are using the faster algorithm (Symmetric) on the bulk data, and the slower but scalable algorithm (Asymmetric) to encrypt the small amount of data (the key). Now we have a system best of both world, which would provide scalability, speed and security.

### Session key

Do not confuse a session key as an asymmetric key. A session key just means a key used for that session. In fact it is a symmetric key produced by two entities every time they create a new session. After the session is over, the key is destroyed and so only lasts for the lifetime of that session. This provides a more secure level of security, as if a hacker captured a session key, he/she would only be able to use this key to see that session and not any future sessions.

## Asymmetric algorithms

The different types of common asymmetric encryptions are as below;

### RSA

RSA provides authentication, encryption and key distribution. RSA is based on large prime numbers. See RSA page for more information.

### Diffie-Hellman

Diffie-Hellman was the first public key algorithm. Being the first, Diffie-Hellman has its problems, the primary one being it does not provide authentication. However using Diffie-Hellman within IPSec along side other authentication methods works well and is still used today. It is based on calculating discrete logarithms in a finite field. To note, Diffie-Hellman only provides key distribution. Authentication and encryption are not supported. See Diffie-Hellman page for more information.

### Elliptic Curve Crypto system (ECC)

ECC provides support for authentication (digital signatures), encryption and key distribution. ECC does not require a key size as large as the other algorithms and still provides the same level of security. ECC’s algorithm uses an elliptic curve system, which proves to be very secure and effective.

### Knapsack

Knapsacks algorithm is based on fixed weights. Knapsack also provides authentication, encryption and key distribution. Unfortunately Knapsack has been proved to be insecure and so is not used anymore.

### Digital signature standards

Digital signatures provide authenticity and integrity of a message. A digital signature processes messages through a hashing algorithm to provide integrity of data, ensuring it has not been changed through transit.

As the name implies, and as digital signatures play an important part in providing integrity, authentication and non-repudiation, the government produced a standard for digital signatures. The Digital signature algorithm uses sha1 with a public key algorithm to produce a 160 bit hash.

### El Gamal

El Gamal also produces encryption, digital signatures and key distribution. Like Diffie-Hellman, El Gamal is based on calculating discrete logarithms in a finite field. The main issues with El Gamal as compared to the other algorithms is performances, it is slow.

**Further Reading**

Wikipedia's guide to **Asymmetric Encryption (Public Key Cryptography)**