More secure key generation method Diffie-Hellman

More secure key generation method Diffie-Hellman

Earlier we talked about the issue of key distribution. This world is so dangerous. If you accidentally listen to the communication line, how can we pass the key over this unsafe line?

Here we introduce the Diffie-Hellman key exchange algorithm. This algorithm is an algorithm co-invented by Whitfield Diffie and Martin Hellman in 1976.

Through this algorithm, the two parties only need to exchange some common information to generate a shared key. Is it amazing?

Let's look at the specific steps:

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

  1. Generate two shared prime numbers G and P, and share these two numbers in x and y.

P is a very large prime number, and G is the generator of P (the power of the generator is in one-to-one correspondence with the numbers in 1 ~ P-1).

These two numbers G and P do not need to 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 sends the result of G A mod P to y, the result is not confidential
  4. y sends the result of G B mod P to x, the result is not confidential
  5. x Use the result of step 5 and random number A to calculate the final shared key (G B mod P) A mod P = G A * B mod P
  6. y and a random number using the results of step B 4 to calculate the final shared key (G A MOD P) B MOD P G = A * B MOD P

We can see that the final keys calculated by 6 and 7 are the same.

Next, we discuss the security of the Diffie-Hellman algorithm:

In this algorithm, the variables exposed to the outside are P, G, G A mod P and G B mod P.

It is very difficult to generate the final G A * B mod P based on these four variables .

This problem involves the discrete logarithm problem, and it is very difficult to solve. Therefore, we can believe that the Diffie-Hellman algorithm is very safe.

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

Guess you like

Origin www.cnblogs.com/flydean/p/diffie-hellman.html