**Asymmetric Encryption - IPsec 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 nonrepudiation. Symmetric encryption also does not provide any scalability or key distribution.

In asymmetric encryption an entity has two different keys, which are mathematically related, which is 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 keys can only encrypt and decrypt messages that have been encrypted or decrypted by one of the two. For example, if Barclays bank encrypted a message using its own private key, it can only be decrypted using its public key, and if it has encrypted the same message using its public key, this key can only be decrypted using its 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, and therefore you do not need 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, the bank can encrypt data with its own private key, and anyone who decrypts this data with its public key can be assured it came from the bank, as only the bank's public key can decrypt what was encrypted with its private key. This assures users the data was sent and secured by Barclays bank, and this also assure non-repudiation, which means Barclays cannot 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 do this by encrypting data using Barclays bank's public key. Barclays bank can only decrypt this data as the bank holds 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, it would first encrypt the message using the other bank’s public key and then encrypt the message again using its own private key. 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 it would decrypt the packet again using its own private key, which would assure confidentiality.

Remember, when Barclays encrypted this message with the other bank's public key, this would provide confidentiality because no one else but the other bank can decrypt the message as only the other bank holds the private key which is mathematically related to its own public key. Also when Barclays bank encrypted the message with its own private key, this provides authentication because only the public key that is accessible to everyone can decrypt the messages which would prove it came from Barclays bank. The intelligent mechanism or point to note here is that 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 it has access to as it was encrypted with its own public key.

Although asymmetric systems are much slower and require more processing power than symmetric systems, they are much more scalable; they 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, using Barclays Bank as an example, we 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. Next, Barclays bank would 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 here 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, because in a situation where 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 that it does not provide authentication. However, using Diffie-Hellman within IPsec alongside other authentication methods work 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 a slow algorithm.

**Further Reading**

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