# Asymmetric Encryption Algorithms, Diffie-Hellman, RSA, ECC, ElGamal, DSA

The following are the major asymmetric encryption algorithms used for encrypting or digitally signing data.

__Diffie-Hellman key agreement:__ Diffie-Hellman key agreement algorithm was developed by Dr. Whitfield Diffie and Dr. Martin Hellman in 1976. Diffie-Hellman algorithm is not for encryption or decryption but it enable two parties who are involved in communication to generate a shared secret key for exchanging information confidentially. The working of Diffie-Hellman key agreement can be explained as below.

Assume we have two parties who need to communicate securely.

1) P1 and P2 agree on two large integers a and b such that 1 < a < b.

2) P1 then chooses a random number i and computes I = a^i mod b. P1 sends I to P2.

3) P2 then chooses a random number j and computes J = a^j mod b. P2 sends J to P1.

4) P1 computes k1 = J^i mod b.

5) P2 computes k2 = I^j mod b.

6) We have k1 = k2 = a^(ij) mod b and thus k1 and k2 are the secret keys for secure transmission.

__Rivest Shamir Adleman (RSA):__ Ron Rivest, Adi Shamir, and Len Adleman released the Rivest-Shamir-Adleman (RSA) public key algorithm in 1978. This algorithm can be used for encrypting and signing data. The encryption and signing processes are performed through a series of modular multiplications.

The basic RSA algorithm for confidentiality can be explained as below.

Ciphertext = (plaintext)^e mod n

Plaintext = (ciphertext)^d mod n

Private Key = {d, n}

Public Key = {e, n}

The basic RSA algorithm for authentication can be explained as below.

ciphertext = (plaintext)^d mod n

plaintext = (ciphertext)^e mod n

private key = {d, n}

public key = {e, n}

__Elliptic Curve Cryptography (ECC):__ Elliptic Curve Cryptography (ECC) provides similar functionality to RSA. Elliptic Curve Cryptography (ECC) is being implemented in smaller devices like cell phones. It requires less computing power compared with RSA. ECC encryption systems are based on the idea of using points on a curve to define the public/private key pair.

__El Gamal:__ El Gamal is an algorithm used for transmitting digital signatures and key exchanges. The method is based on calculating logarithms. El Gamal algorithm is based on the characteristics of logarithmic numbers and calculations. The Digital Signature Algorithm (DSA) is based on El Gamal algorithm.

__Digital Signature Algorithm (DSA).__ The Digital Signature Algorithm (DSA) was developed by the United States government for digital signatures. Digital Signature Algorithm can be used only for signing data and it cannot be used for encryption. The DSA signing process is performed through a series of calculations based on a selected prime number. Although intended to have a maximum key size of 1,024 bits, longer key sizes are now supported.

When DSA is used, the process of creating the digital signature is faster than validating it.

When RSA is used, the process of validating the digital signature is faster than creating it.