A more secure key generation method Diffie Hellman

Time:2021-1-19

A more secure key generation method Diffie Hellman

Before we talked about the problem of key distribution, the world is so dangerous that if we are not careful, the communication line will be monitored, so how can we transfer the key in such an insecure line?

Here we introduce Diffie Hellman key exchange algorithm. This algorithm was invented by Whitfield Diffie and Martin Hellman in 1976.

Through this algorithm, both sides only need to exchange some common information to generate a shared key. Isn’t it amazing?

Let’s look at the specific steps:

A more secure key generation method Diffie Hellman

The above figure is the Diffie Hellman key exchange algorithm. If x wants to send a message to y, if the above algorithm is adopted, the following steps are required:

  1. Two shared prime numbers g and P are generated and shared in X and y.

P is a very large prime number, and G is the generator of P (the power result of generator corresponds to the number in 1 ~ P-1 one by one).

The two numbers g and P need not be kept secret. It doesn’t matter if it’s stolen.

  1. X generates a random number a, which can only be known by X. A is an integer from 1 to P-2.
  2. Y generates a random number B, which can only be known by y. B is an integer from 1 to P-2.
  3. X will be gAThe result of mod p is sent to y. this result is not confidential
  4. Y will be gBThe result of mod p is sent to X. This result is not confidential
  5. X calculates the final shared key (g) using the result of step 5 and random number aB mod P)A mod P = GA*B mod P
  6. Y uses the result of step 4 and random number B to calculate the final shared key (g)A mod P)B mod P = GA*B mod P

We can see that the final key calculated by 6 and 7 is the same.

Next, we discuss the security of Diffie Hellman algorithm

In this algorithm, the variables exposed to the outside are p, G, GAMod p and GBMod p is the four variables.

According to these four variables to generate the final GA*BMod p is very difficult.

This problem involves the discrete logarithm problem, which is very difficult to solve. Therefore, we can believe that Diffie Hellman algorithm is very secure.

For more information, please visit http://www.flydean.com/diffie-hellman/