## Wednesday, September 8, 2021

### Diffie-Hellman Key Exchange Algorithm

Diffie-Hellman Key Exchange Algorithm

Introduction

The Diffie Hellman algorithm widely known as Key exchange algorithm or key agreement algorithm developed by Whitefield Diffie and Martin Hellman in 1976. The purpose of the algorithm is to enable two users to securely exchange a key that can be used for subsequent encryption of messages. The algorithm itself is limited to the exchange of secret values.

Diffie – Hellman Key Exchange Algorithm steps:

Step-1: Select q (prime number) and α (α is primitive root of q)

Step-2: User A Key Generation: select XA, XA < q

Calculate public key YA, YA = αXA mod q

YA Shared with user B

Step-3: User B Key Generation: select XB, XB < q

Calculate public key YB, YB = αXB mod q

YB shared with user A

Step-4: Calculation of secret key by user A: K = (YB)XA mod q

Step-5: Calculation of secret key by user B: K = (YA)XB mod q

Same Secret key generate both sides

K = (YB) XA mod q

= (αXB mod q) XA mod q

= (αXB) XA mod q

= (αXA) XB mod q

= (αXA mod q) XB mod q

= (YA) XB mod q

= K

Diffie – Hellman Key Exchange Algorithm explain with example:

Step – 1: Select q (prime number) and α (α is primitive root of q)

Example, here q = 7, α = 17.

Step – 2: User A Key Generation: Select XA < q,

calculate public key YA and shared with user B: YA = αXA mod q

Example, Here XA = 6,

Calculate YA = αXA mod q 176 mod 7 1

Step – 3: User B Key Generation: Select XB < q,

calculate public key YB and shared with user A: YB = αXB mod q

Example, Here XB = 4,

Calculate YB = αXB mod q 174 mod 7 4

Step – 4: Calculation of secret key by user A:

K = (YB) XA mod q

Example, Here YB = 4, XA = 6

Calculate K = (YB) XA mod q 46 mod 7 1

Step – 5: Calculation of secret key by user B:

K = (YA) XB mod q

Example, Here YA = 1, XB = 4

Calculate K = (YA) XB mod q 14 mod 7 1

Solution of exercise (Given in video)