preface

Diffie Hermann key exchange is a method to exchange keys securely between communication parties. This method realizes the secure exchange of keys between two parties by hiding the common cryptographic values in the open numeral-related operation.

Conceptual diagram

  • Suppose there is a way to merge the two keys. Use this method to combine key P and key S, and you get a key P-S made up of the components of the two keys.
  • This synthesis method has three characteristics. First, the key P and the synthesized key P-S cannot be taken out separately.
  • Second, no matter how the key is synthesized, it can be taken as a new element and continued to be combined with other keys. As shown in the figure, a new key p-p-S can be synthesized by using the key P and the key P-S.
  • Third, the result of key composition has nothing to do with the composition order, only with which key is used. For example, after key B and key C are synthesized, the key B-C is obtained, and then the key B-C is synthesized with key A to obtain the key A-B-C. After key A and key C are synthesized, key A-C is obtained, and key B-A-C is obtained by combining it with key B. The key A-B-C is the same as the key B-A-C

The illustration example

  • As shown in the figure, the key is exchanged securely between A and B using the above method. First, A generates the key P.
  • A then sends the key P to B.
  • Next, A and B each prepare their own private keys SA and SB.
  • A Uses the key P and the private key SA to synthesize the new key p-sa.
  • B also uses the key P and the private key SB to synthesize the new key P-sb.
  • A sends the key P-sa to B, and B sends the key P-sb to A.
  • A Combines the private key SA and the received key P-sb into A new key sa-p-sb.
  • Similarly, B combines the private key SB and the received key P-sa into a new key p-sa-sb. So both A and B get P minus SA minus SB. This key will be used as an encryption key and a decryption key.

Safety diagram

Next, we verify the security of the key exchange. Because key P, p-SA, and P-SB need to be transmitted over the Internet, X may eavesdrop on them.

However, X cannot synthesize p-SA-SB from the key of its own eavesdropping channel, so this exchange is secure.

Diffie Hermann key exchange diagram

As shown in the figure, two integers P and G represent the public key P generated at the beginning. Where P is a very large prime number and G is one of the generators (or “primers”) corresponding to the prime number P.

  • First, A prepares the prime P and the generator G. It doesn’t matter if these two numbers are public.
  • A sends the prime P and the generator G to B.
  • Next, A and B prepare their secret numbers X and Y, respectively. Both X and Y have to be less than p minus 2
  • A and B compute “(G to the secret number power)mod P” respectively. Mod is mod.” G mod P” is the remainder of G divided by P. The operation here is equivalent to “composition” in the conceptual sense.
  • A and B send their calculations to each other.
  • When A and B receive each other’s results, they first compute the value to the secret number power before mod P. In the end, A and B will get the same answer.

security

As shown in the figure, even if X eavesdropped on the entire communication process, it could not use the eavesdropped numbers to calculate the numbers shared by A and B. Also, X cannot compute the secret numbers X and Y. Therefore, it is safe to use the Diffiermann key exchange here.

Di Mr Herman key exchange is the generator through the prime number P, G and “G x to the power of the mod P” the issue of x is the discrete logarithm problem, so far has not yet found the solution to this problem, and di Mr Herman key exchange is the use of the mathematical problems, so in front of the discrete logarithm problem not solved, the encryption method is safe.

With the Diffie Hermann key exchange, the communication parties can exchange keys only by exchanging some public information. But in reality, the two parties don’t exchange keys, they generate them. Therefore, this method is also known as the “Diffie Hermann protocol”.

Write in the last

  • The pictures used in this article are from “my first algorithm book”, if infringement, please leave a message in the comment section, the author immediately delete the relevant pictures.
  • If there are any errors in this article, please correct them in the comments section. If this article helped you, please like it and follow 😊
  • This article was first published in nuggets. Reprint is prohibited without permission 💌