Diffie-HellmanKey Exchange Algorithm and Its Optimization
The first published Public Key algorithm appeared in the Diffie and Hellman papers. This far-reaching paper laid the foundation for public key cryptography. Because the algorithm is limited to the purpose of key exchange and is used by many commercial products as the key exchange technology, this algorithm is usually called Diffie-Hellman Key Exchange. This key exchange technology aims to enable two users to securely exchange a secret key for future message encryption.
The effectiveness of the Diffie-Hellman Key Exchange algorithm depends on the difficulty of calculating the discrete logarithm. In short, discrete logarithm can be defined as follows: first, a prime number is defined.PThe original root of which is generated from 1P-All Integer root of 1, that is, ifAYes Prime NumberPIs a source root, then the value
AMoDP,A2 modP,...,AP-1 modP
Is a different integer, and in a certain arrangement form from 1PAll integers of-1.
For an integerBAnd prime numberPA source rootA, You can find the only IndexI, Making
B=AIMoDP0 ≤I≤ (P-1)
IndexICalledBToABase ModePDiscrete Logarithm or exponent. This value is recorded as Ind.A, P(B ).
Based on this background knowledge, you can define the Diffie-Hellman Key Exchange algorithm. The algorithm is described as follows:
1. Two global parameters, one prime numberQAnd an integerA,AYesQ.
2. Assume that user a and user B want to exchange a key, and user a chooses a random number XA as the Private Key <Q, And calculate the Public Key YA =AXA modQ. A keeps XA values confidential so that ya can be publicly obtained by B. Similarly, user B selects a private random number XB <QAnd calculate the Public Key Yb =AXB modQ. B keeps XB values confidential so that Yb can be publicly obtained by.
3. The calculation method for user a to generate a shared secret key is k = (Yb) XA Mod.Q. Similarly, user B generates a shared secret key using k = (ya) XB Mod.Q. These two computations produce the same results:
K = (Yb) XA modQ
= (AXB modQ) XA modQ
= (AXB) XA modQ(Based on the modulo operation rules)
=AXBXA modQ
= (AXA) XB modQ
= (AXA modQ) XB modQ
= (Ya) XB modQ
Therefore, the two sides have exchanged the same secret key.
4. Because Xa and XB are confidential, a competitor can use onlyQ,A, Ya, and Yb. Therefore, the competitor is forced to take discrete logarithm to determine the key. For example, to obtain the secret key of user B, the competitor must calculate
XB = indA, Q(Yb)
Then, user B uses the same method to calculate its secret key K.
The security of the Diffie-Hellman Key Exchange algorithm depends on the fact that although it is relatively easy to calculate an index modeled by a prime number, it is difficult to calculate the discrete logarithm. It is almost impossible to calculate the discrete logarithm of a large prime number.
The following is an example. Key Exchange is based on prime numbersQ= 97 and 97A= 5. Select private keys XA = 36 and XB = 58 For A and B respectively. Each person calculates its Public Key
Ya= 536 = 50 mod 97
Yb = 558 = 44 mod 97
After obtaining public keys from each other, the secret keys shared by both parties are calculated as follows:
K = (Yb) XA mod 97 = 4436 = 75 mod 97
K = (ya) XB mod 97 = 5058 = 75 mod 97
Starting from | 50,44 |, it is not easy for attackers to calculate 75.
A simple protocol using Diffie-Hellman computing is provided.
Assume that user a wants to establish a connection with user B and use a shared secret key to encrypt the packets transmitted over the connection. User A generates a one-time private key XA, computes the Public Key ya, and sends it to user B. User B generates a private key XB, computes the Public Key Yb, and sends it to user A as a response. Necessary public valueQAndAYou need to know in advance. Another method is user a's choice.QAndAAnd include these values in the first packet.
The following is an example using the Diffie-Hellman algorithm. Assume that there is a group of users (for example, all users on a LAN), each person generates a long-term private key Xa and calculates a public key ya. These public key values, together with the global public key valuesQAndAAre stored in a central directory. At any time, user B can access the public value of user a, calculate a secret key, and use this key to send an encrypted message to user. If the central directory is trustworthy, this form of communication provides confidentiality and a certain degree of authentication. Because only a and B can determine the key, other users cannot interpret the message (confidentiality ). Receiver a knows that only user B can use this key to generate this message (authentication ).
The Diffie-Hellman algorithm has two attractive features:
1. Generate a key only when necessary, reducing the chance of an attack caused by storing the key for a long time.
2. Except for the global parameter conventions, key exchange does not require an existing infrastructure.
However, this technology also has many shortcomings:
1. No information about the identity of both parties is provided.
2. It is computation intensive and therefore prone to obstructive attacks, that is, the opponent requests a large number of keys. Attackers spend a lot of computing resources to solve useless power coefficients rather than doing real work.
3. There is no way to prevent repeated attacks.
4. attackers are vulnerable to man-in-the-middle attacks. The third-party C acts as B when communicating with A, and the third-party C acts as a when communicating with B. Both A and B negotiate a key with C, and then C can monitor and transmit traffic. Man-in-the-middle attacks are carried out as follows:
(1) B sends his public key in the message to.
(2) c. Intercept and parse the newspaper. C saves the public key of B and sends messages to a. the stationery of the newspaper has the user ID of B, but the public key YC of C is still sent as if it was from B. After receiving the C message, a stores the user IDs of YC and B in one. Similarly, C uses YC to send messages from A to B.
(3) B calculates the secret key K1 based on the private key XB and YC. A calculates secret key K2 based on private keys Xa and YC. C uses private keys XC and Yb to calculate K1, and XC and ya to calculate K2.
(4) from now on, C can forward the packets sent by A to B or the packets sent by B to A, and modify their ciphertext as needed on the way. So that both A and B do not know that they are sharing communication with C.
The Oakley algorithm is an optimization of the Diffie-Hellman Key Exchange algorithm. It retains the advantages of the latter and overcomes its weaknesses.
The Oakley algorithm has five important features:
1. It uses a mechanism called Cookie program to defend against blocking attacks.
2. It allows both parties to negotiate a global parameter set.
3. It uses the current method to prevent repeated attacks.
4. It can exchange Diffie-Hellman public keys.
5. It identifies Diffie-Hellman exchange to defend against man-in-the-middle attacks.
Oak Ley can use three different authentication methods:
1. Digital Signature: The exchange is identified by signing a hash code that can be obtained from each other. Each party uses its own private key to encrypt the hash code. Hash code is generated on some important parameters, such as the user ID and the current status.
2. public key encryption: the sender's private key is used to encrypt parameters such as ID and current to identify and exchange.
3. symmetric key encryption: symmetric encryption is performed on exchange parameters by using a shared key to implement exchange authentication.
(Edited by Yang Xianchun)