# Diffie Hellman Key exchange algorithm Implementation in C ## Diffie Hellman Key exchange algorithm:

The Diffie Hellman algorithm is a public-key algorithm used to establish a shared secret that can be used for secret communications while exchanging data over a public network. Diffie Hellman Key exchange algorithm

### Steps of Diffie Hellman key exchange Algorithm :

1      Requires two large numbers, one prime (P) and (G), a primitive root of P
2      P and G are both publicly available numbers
a.       P is at least 512 bits
3      Users pick private values a and b
4      Compute public values
a.       x = ga mod p
b.      y = GB mod p
5      Public values x and y are exchanged
6      Compute shared, private key
a.       ka = yamod p
b.      kb = xbmod p
c.       Algebraically, it can be shown that ka = kb

Users now have a symmetric secret key to encrypt.

### Example

1. Alice and Bob get public numbers
1. P = 23, G = 9
2. Alice and Bob compute public values
3. X = 94 mod 23 = 6561 mod 23 = 6
4. Y = 93 mod 23 = 729 mod 23    = 16
5. Alice and Bob exchange public numbers
2. Alice and Bob compute symmetric keys
1. ka = ya mod p = 164 mod 23 = 9
2. kb = xb mod p = 63 mod 23 = 9
3.       9 is the shared secret.

#### RSA Algorithm(Encryption and Decryption) implementation in C

1. 1. 