Key negotiation method and device

By replacing random numbers with quantum keys in SSH connections, generating public keys and generating session keys through the Diffi-Helen algorithm, the problem of limited random numbers in the prior art is solved, and the security of data transmission is improved.

CN120034321APending Publication Date: 2025-05-23NEW H3C TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510121482.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In existing SSH connections, the random numbers generated by the server and the client are limited, which are easily obtained by eavesdroppers through exhaustive methods, resulting in the security of data transmission being threatened.

Method used

The quantum key is used to replace the random number, generate the public key as the private key, and generate the session key through the Diffi-Helen algorithm. The generation of quantum keys uses the superposition and measurement characteristics of quantum. Any eavesdropping behavior will cause changes in the quantum state and be detected by both parties in the legal communication.

Benefits of technology

Improve the security of session keys, enhance the security of data transmission, and prevent eavesdroppers from obtaining quantum keys, thereby ensuring the security of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120034321A_ABST
    Figure CN120034321A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a key negotiation method and device, and relates to the technical field of network security, and the method comprises the steps that a first communication party obtains a first quantum key generated by a first quantum key distribution server; generating a first public key of the first communication party by using the first quantum key; and sending the first public key to the second communication party, so that the second communication party generates a first session key for performing a session with the first communication party by using the first public key and a private key of the second communication party. According to the scheme, the security of data transmission can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security technology, and in particular to a key negotiation method and device. Background Art

[0002] The Secure Shell (SSH) protocol is a network security protocol that uses encryption and authentication mechanisms to achieve secure remote access and file transfer services in an insecure network environment. To achieve an SSH connection, the server and client must go through five stages: version negotiation, key and algorithm negotiation, authentication, session request, and session interaction.

[0003] During the key and algorithm negotiation phase of establishing an SSH connection, after the server and client negotiate the key exchange algorithm, public key algorithm, encryption algorithm, message authentication code (MAC) algorithm, compression algorithm, etc., the server and client each generate a random number as a private key, and use the Diffie-Hellman (DH) algorithm and random numbers to generate their own public keys, and send the public keys to the other end; the server and client use their own random numbers and the other end's public key to generate a session key. Subsequently, the server and client use the session key to encrypt and decrypt data.

[0004] The random numbers generated by the server and the client are kept confidential and not disseminated. Therefore, it is difficult for other users to infer the random numbers generated by the server and the client, and it is difficult to obtain the session key between the server and the client to ensure the security of data transmission. However, the random numbers generated by the server and the client are currently limited, and other users can obtain the random numbers generated by the server and the client through exhaustive methods, which poses a threat to the security of data transmission. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a key negotiation method and device to improve the security of data transmission. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present application provides a key negotiation method, which is applied to a first communication party, and the method includes:

[0007] Obtaining a first quantum key generated by a first quantum key distribution server;

[0008] Using the first quantum key, generating a first public key of the first communication party;

[0009] The first public key is sent to a second communication party, so that the second communication party generates a first session key for conducting a session with the first communication party by using the first public key and a private key of the second communication party.

[0010] In some embodiments, the method further comprises:

[0011] receiving a second public key sent by the second communication party, where the second public key is a public key generated by the second communication party using the second communication party's private key;

[0012] A second session key for conducting a conversation with the second communicating party is generated using the second public key and the first quantum key.

[0013] In some embodiments, before obtaining the first quantum key generated by the first quantum key distribution server, the method further includes:

[0014] Acquire a shared factor between the first communication party and the second communication party, wherein the shared factor includes a prime number and a primitive root of the prime number;

[0015] The generating a first public key of the first communication party by using the first quantum key specifically includes:

[0016] Calculating the first quantum key power number of the primitive root to obtain a first value; taking the first value modulo the prime number to obtain a first public key of the first communication party;

[0017] The step of generating a second session key for conducting a conversation with the second communication party by using the second public key and the first quantum key specifically includes:

[0018] Calculate the first quantum key power of the second public key to obtain a second value; and take the second value modulo the prime number to obtain a second session key for conducting a conversation with the second communication party.

[0019] In some embodiments, the private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

[0020] In a second aspect, an embodiment of the present application further provides a key negotiation method, which is applied to a second communication party, and the method includes:

[0021] Receive a first public key sent by the first communication party, where the first public key is a public key obtained by the first communication party according to any method provided in the first aspect;

[0022] A first session key for conducting a session with the first communication party is generated using the first public key and the private key of the second communication party.

[0023] In some embodiments, the method further comprises:

[0024] Obtaining a private key of the second communication party;

[0025] generating a second public key of the second communication party using the private key of the second communication party;

[0026] The second public key is sent to the first communication party, so that the first communication party generates a second session key for conducting a conversation with the second communication party by using the second public key and the first quantum key of the first communication party.

[0027] In some embodiments, before obtaining the private key of the second communication party, the method further includes:

[0028] Acquire a shared factor between the first communication party and the second communication party, wherein the shared factor includes a prime number and a primitive root of the prime number;

[0029] The step of generating the second public key of the second communication party by using the private key of the second communication party specifically includes:

[0030] Calculate the power of the private key of the second communication party of the primitive root to obtain a third value; modulo the third value with the prime number to obtain the second public key of the second communication party;

[0031] The step of generating a first session key for a session with the first communication party by using the first public key and the private key of the second communication party specifically includes:

[0032] Calculate the power of the private key of the second communication party of the first public key to obtain a fourth value; take the fourth value modulo the prime number to obtain a first session key for conducting a session with the first communication party.

[0033] In some embodiments, the private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

[0034] In a third aspect, an embodiment of the present application provides a key negotiation device, applied to a first communication party, the device comprising:

[0035] An acquisition module, used to acquire a first quantum key generated by a first quantum key distribution server;

[0036] A first generating module, configured to generate a first public key of the first communicating party using the first quantum key;

[0037] The sending module is used to send the first public key to the second communication party, so that the second communication party uses the first public key and the private key of the second communication party to generate a first session key for conducting a session with the first communication party.

[0038] In some embodiments, the apparatus further comprises:

[0039] A receiving module, used to receive a second public key sent by the second communication party, where the second public key is a public key generated by the second communication party using the private key of the second communication party;

[0040] The second generating module is used to generate a second session key for conducting a session with the second communicating party by using the second public key and the first quantum key.

[0041] In some embodiments, the acquisition module is further used to acquire a shared factor between the first communication party and the second communication party before acquiring the first quantum key generated by the first quantum key distribution server, wherein the shared factor includes a prime number and a primitive root of the prime number;

[0042] The first generating module is specifically used to: calculate the first quantum key power number of the primitive root to obtain a first value; take the first value modulo the prime number to obtain the first public key of the first communication party;

[0043] The second generation module is specifically used to: calculate the first quantum key power number of the second public key to obtain a second value; and take the second value modulo the prime number to obtain a second session key for conducting a conversation with the second communication party.

[0044] In some embodiments, the private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

[0045] In a fourth aspect, an embodiment of the present application provides a key negotiation device, applied to a second communication party, the device comprising:

[0046] a receiving module, configured to receive a first public key sent by the first communication party, where the first public key is a public key obtained by the first communication party according to any device provided by the third aspect;

[0047] The first generating module is used to generate a first session key for conducting a session with the first communicating party by using the first public key and the private key of the second communicating party.

[0048] In some embodiments, the apparatus further comprises:

[0049] An acquisition module, used to acquire the private key of the second communication party;

[0050] A second generating module, used to generate a second public key of the second communicating party by using the private key of the second communicating party;

[0051] The sending module is used to send the second public key to the first communication party, so that the first communication party uses the second public key and the first quantum key of the first communication party to generate a second session key for conducting a conversation with the second communication party.

[0052] In some embodiments, the acquisition module is further used to acquire a shared factor between the first communication party and the second communication party before acquiring the private key of the second communication party, wherein the shared factor includes a prime number and a primitive root of the prime number;

[0053] The second generation module is specifically used to: calculate the power of the private key of the second communication party of the primitive root to obtain a third value; modulo the third value with the prime number to obtain the second public key of the second communication party;

[0054] The first generation module is specifically used to: calculate the power of the private key of the second communication party of the first public key to obtain a fourth value; and take the fourth value modulo the prime number to obtain a first session key for conducting a conversation with the first communication party.

[0055] In some embodiments, the private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

[0056] In a fifth aspect, an embodiment of the present application provides a communication device, comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement any method provided in the first aspect.

[0057] In a sixth aspect, an embodiment of the present application provides a communication device, comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to implement any method provided in the second aspect.

[0058] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it implements any method provided in the first aspect, or implements any method provided in the second aspect.

[0059] In an eighth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any method provided in the first aspect, or execute any method provided in the second aspect.

[0060] Beneficial effects of the embodiments of the present application:

[0061] In the technical solution provided in the embodiment of the present application, in the key negotiation stage, a quantum key is used to replace a random number as a private key, and the public key is generated by the private key, and then the session key is generated. The generation of quantum keys utilizes the superposition and measurement characteristics of quantum. Any eavesdropping behavior will cause the quantum state to change, which will be detected by the legitimate communicating parties. Therefore, it is difficult for an eavesdropper to obtain the quantum key. In the embodiment of the present application, a quantum key is used to generate a session key, which improves the security of the session key, thereby greatly improving the security of data transmission using the session key.

[0062] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0064] Figure 1 A schematic diagram of a process of establishing an SSH connection in the prior art;

[0065] Figure 2 A flowchart of the DH key negotiation process is shown below;

[0066] Figure 3 A schematic diagram of a first process flow of a key negotiation method provided in an embodiment of the present application;

[0067] Figure 4 A second flow chart of the key negotiation method provided in the embodiment of the present application;

[0068] Figure 5 A third flow chart of the key negotiation method provided in the embodiment of the present application;

[0069] Figure 6 A fourth flow chart of the key negotiation method provided in an embodiment of the present application;

[0070] Figure 7 A fifth flow chart of the key negotiation method provided in the embodiment of the present application;

[0071] Figure 8 A sixth flow chart of the key negotiation method provided in an embodiment of the present application;

[0072] Figure 9a A schematic diagram of the process of establishing an SSH connection using quantum keys on the client side;

[0073] Figure 9b A schematic diagram of the process of establishing an SSH connection using quantum keys on the server side;

[0074] Fig.9c A schematic diagram of the process of establishing an SSH connection using quantum keys on both the client and server sides;

[0075] Fig.10 A schematic diagram of the first structure of a key agreement device provided in an embodiment of the present application;

[0076] Fig.11 A second structural diagram of the key agreement device provided in an embodiment of the present application;

[0077] Fig.12 A schematic diagram of a first structure of a communication device provided in an embodiment of the present application;

[0078] Fig.13 A second structural diagram of a communication device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0079] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.

[0080] Quantum key: In quantum cryptography, the communicating parties generate and share a random, secure key to encrypt and decrypt information.

[0081] Quantum Key Distribution (QKD): uses the characteristics of quantum mechanics to ensure communication security. Its main principle is to use the superposition and measurement characteristics of quantum. Any eavesdropping will cause the quantum state to change, which can be detected by both parties of legitimate communication.

[0082] During the entire communication process, in order to achieve SSH connection, such as Figure 1 As shown in the figure, after the server and the client interact and establish a Transmission Control Protocol (TCP) connection, they go through the following five stages to achieve an SSH connection:

[0083] (1) Version negotiation phase.

[0084] Currently, the SSH protocol includes two versions: SSH1 and SSH2. The server and the client determine the version to be used through version negotiation.

[0085] (2) Key and algorithm negotiation phase.

[0086] SSH supports multiple encryption algorithms. In the key and algorithm negotiation phase, the server and the client respectively send algorithm negotiation messages to the peer, and the messages contain the list of key exchange algorithms, public key algorithms, encryption algorithms, Message Authentication Code (MAC) algorithms, compression algorithms, etc. that they support; the server and the client determine the finally used algorithms according to the algorithm lists supported by the peer and themselves; in addition, the server and the client use parameters such as the DH algorithm and the host key to perform DH key negotiation to generate a session key and a session identifier (ID).

[0087] Specifically, the DH key negotiation process can be referred to Figure 2 as shown: Communicator A interacts with Communicator B to obtain a shared factor, which includes a prime number p and a primitive root g of the prime number, 1 < g < p; Communicator A generates a random number a (i.e., the private key) within a specified random number range, calculates g^a mod(p) to obtain the public key a', and sends the public key a' to Communicator B; Communicator B generates a random number b (i.e., the private key) within a specified random number range, calculates g^b mod(p) to obtain the public key b', and sends the public key b' to Communicator A; Communicator A calculates b'^a mod(p) to obtain the session key Sa, and Communicator B calculates a'^b mod(p) to obtain the session key Sb. The session key Sa is the same as the session key Sb.

[0088] Through key and algorithm negotiation, the server and the client obtain the same session key and session ID. For subsequent data transmission, both ends use the session key for encryption and decryption, ensuring the security of data transmission.

[0089] (3) Authentication phase.

[0090] The client initiates an authentication request to the server, and the server authenticates the client. The authentication methods include: password authentication, publickey authentication, password-publickey authentication, keyboard-interactive authentication, and any authentication, etc.

[0091] (4) Session request phase.

[0092] After authentication is passed, the client sends a session request to the server, and the server confirms the session request.

[0093] (5) Session interaction phase.

[0094] After the session request is passed, the server and client exchange data.

[0095] In the above key and algorithm negotiation phase, the private key (i.e., random number) used to generate the session password is limited and is random within the specified random number range. In this case, other users can obtain the private key between the server and the client through exhaustive methods, which poses a threat to the security of data transmission.

[0096] To solve the above problems, the present invention provides a key negotiation method. Figure 3 As shown, it is applied to the first communication party and includes the following steps:

[0097] Step S31, obtaining a first quantum key generated by a first quantum key distribution server;

[0098] Step S32, using the first quantum key to generate a first public key of the first communication party;

[0099] Step S33: Send the first public key to the second communication party, so that the second communication party generates a first session key for conducting a session with the first communication party by using the first public key and the private key of the second communication party.

[0100] In the technical solution provided in the embodiment of the present application, in the key negotiation stage, a quantum key is used to replace a random number as a private key, and the public key is generated by the private key, and then the session key is generated. The generation of quantum keys utilizes the superposition and measurement characteristics of quantum. Any eavesdropping behavior will cause the quantum state to change, which will be detected by the legitimate communicating parties. Therefore, it is difficult for an eavesdropper to obtain the quantum key. In the embodiment of the present application, a quantum key is used to generate a session key, which improves the security of the session key, thereby greatly improving the security of data transmission using the session key.

[0101] In the embodiment of the present application, the first communication party and the second communication party are the two communication parties, and the first communication party can be any one of the two communication parties. For example, the first communication party can be Figure 1 The client in can also be Figure 1 In the server, correspondingly, the second communication party is the opposite end of the first communication party. If the first communication party is the client, the second communication party is the server, or if the first communication party is the server, the second communication party is the client.

[0102] In the above step S31, the first quantum key distribution server is a quantum key distribution server connected to the first communication party. The first quantum key distribution server is used to generate a quantum key (such as a first quantum key) and distribute the first quantum key to the first communication party. The first quantum key is a private key used by the first communication party to generate a session password.

[0103] The first communication party interacts with the first quantum key distribution server to obtain a first quantum key, and then uses the first quantum key to replace the random number as the private key of the first communication party.

[0104] In the above step S32, the first public key is a public key used by the first communication party to generate a session password. After obtaining the first quantum key, the first communication party generates the first public key of the first communication party using the first quantum key, and then executes step S33 to send the first public key to the second communication party.

[0105] In the above step S33, the private key of the second communication party is the private key used by the second communication party to generate the session password. The private key of the second communication party can be a random number, such as a random number generated by the above communication party according to its own random algorithm within a specified random number range. The private key of the second communication party can also be a quantum key, such as a second quantum key generated by a second quantum key distribution server. The way in which the second communication party obtains the second quantum key can refer to the way in which the first communication party obtains the first quantum key, which will not be repeated here. In the case where the second communication party also uses a quantum key to replace the random number, the security of the session key can be further improved, and the security of data transmission using the session key can be improved.

[0106] The first session key is a key used by the second communication party to encrypt and decrypt session data between the second communication party and the first communication party.

[0107] The first communication party sends the first public key to the second communication party. After receiving the first public key, the second communication party can use the first public key and the private key of the second communication party to generate a first session key. The specific method of generating the first public key and the first session key is related to the key exchange algorithm negotiated by the first communication party and the second communication party.

[0108] In some embodiments, the key exchange algorithm negotiated by the first communication party and the second communication party is a DH algorithm. In this case, the embodiment of the present application also provides a key negotiation method, such as Figure 4 As shown, when applied to the first communication party, the following steps may be included:

[0109] Step S41, obtaining a shared factor between the first communication party and the second communication party, where the shared factor includes a prime number and a primitive root of the prime number;

[0110] Step S42, obtaining the first quantum key generated by the first quantum key distribution server; the same as the above step S31.

[0111] In the embodiment of the present application, the execution order of step S41 and step S42 is not limited.

[0112] Step S43, calculating the first quantum key power number of the primitive root to obtain a first value; taking the first value modulo a prime number to obtain a first public key of the first communication party;

[0113] In the embodiment of the present application, after the first communication party obtains the shared factors (such as the prime number p and the primitive root g of the prime number), the first communication party can use the following formula (1) to calculate the first public key.

[0114] a'=g^a mod(p) (1)

[0115] Among them, a' is the first public key, a is the first quantum key, that is, the first quantum key, g^a is the first value, and mod() is the modulo function.

[0116] Step S44: Send the first public key to the second communication party, so that the second communication party generates a first session key for conducting a session with the first communication party by using the first public key and the private key of the second communication party.

[0117] In the embodiment of the present application, after the second communication party obtains the shared factors (such as the prime number p and the primitive root g of the prime number) and the first public key, the second communication party can use the following formula (2) to calculate the first session key.

[0118] Sb=a'^b mod(p) (2)

[0119] Among them, Sb is the first session key, a' is the first public key, b is the private key of the second communication party, a'^b is the fourth value, p is the prime number included in the shared factor, and mod() is the modulus function.

[0120] In an embodiment of the present application, the first communicating party involves the first quantum key in the DH interaction between the first public key and the first session key, thereby improving the security of the first public key and the first session key, and thereby improving the security of subsequent data transmission.

[0121] In some embodiments, Figure 5 As shown, a key negotiation method is also provided, which may include the following steps:

[0122] Step S51, receiving a second public key sent by a second communication party, where the second public key is a public key generated by the second communication party using the second communication party's private key;

[0123] Step S52: Generate a second session key for conducting a conversation with a second communication party using the second public key and the first quantum key.

[0124] In the technical solution provided by the embodiment of the present application, the first communication party uses the first quantum key to generate the first public key, prompting the second communication party to generate the first session key associated with the first quantum key, and also uses the first quantum key to generate the second session key of this end. At the first communication party end, it is difficult for an eavesdropper to obtain the first quantum key, and then it is difficult to obtain the second session key, which further improves the security of the session key, and then greatly improves the security of data transmission using the session key.

[0125] In the above step S51, while the first communication party generates the first public key using the first quantum key to prompt the second communication party to generate the first session key associated with the first quantum key, the second communication party also generates the second public key using the second communication party's private key. The first communication party and the second communication party exchange public keys.

[0126] Among them, the way in which the second communication party generates the second public key can be found in the relevant description of the above step S32, which will not be repeated here.

[0127] In the above step S52, the second session key is a key used by the first communication party to encrypt and decrypt the session data between the first communication party and the second communication party. After obtaining the second public key, the first communication party generates the second session key using the second public key and the first quantum key.

[0128] The specific manner of generating the second public key and the second session key is related to the key exchange algorithm negotiated by the first communication party and the second communication party.

[0129] In some embodiments, the key exchange algorithm negotiated by the first communication party and the second communication party is a DH algorithm. In this case, the embodiment of the present application also provides a key negotiation method, such as Figure 6 As shown, when applied to the first communication party, the following steps may be included:

[0130] Step S61, obtaining a shared factor between the first communication party and the second communication party, where the shared factor includes a prime number and a primitive root of the prime number;

[0131] Step S62, receiving a second public key sent by the second communication party, where the second public key is a public key generated by the second communication party using the second communication party's private key;

[0132] In the embodiment of the present application, after the second communication party obtains the shared factors (such as the prime number p and the primitive root g of the prime number), the second public key can be calculated using the following formula (3).

[0133] b'=g^b mod(p) (3)

[0134] Wherein, b' is the second public key, b is the private key of the second communication party, g^b is the third value, and mod() is the modulus function.

[0135] Step S63, calculating the first quantum key power of the second public key to obtain a second value; taking the second value modulo a prime number to obtain a second session key for conducting a conversation with the second communication party.

[0136] In the embodiment of the present application, after the first communication party obtains the shared factors (such as the prime number p and the primitive root g of the prime number) and the second public key, the first communication party can use the following formula (4) to calculate the first session key.

[0137] Sa=b'^a mod(p) (4)

[0138] Wherein, Sa is the second session key, b' is the second public key, a is the first quantum key, b'^a is the second numerical value, p is the prime number included in the shared factor, and mod() is the modulo function.

[0139] In an embodiment of the present application, the first communicating party involves the first quantum key in the DH interaction of the second session key, thereby improving the security of the second session key and further improving the security of subsequent data transmission.

[0140] The DH algorithm is a symmetric key exchange algorithm. When the key exchange algorithm negotiated by the first communication party and the second communication party is the DH algorithm, the first session key and the second session key are the same. When the key exchange algorithm negotiated by the first communication party and the second communication party is an asymmetric key exchange algorithm, the first session key and the second session key may also be different. Here, only the DH algorithm is used as an example for explanation, which does not serve as a limitation.

[0141] Corresponding to the key negotiation method applied to the first communication party, the embodiment of the present application also provides a key negotiation method, such as Figure 7 As shown, it is applied to the second communication party and includes the following steps:

[0142] Step S71, receiving a first public key sent by the first communication party, where the first public key is a public key obtained by the first communication party according to any of the above-mentioned key negotiation methods; here, the way in which the first communication party obtains the first public key can be referred to the description of steps S32 and S43.

[0143] Step S72, using the first public key and the private key of the second communication party, generate a first session key for a conversation with the first communication party. For details, please refer to the description of step S33 and step S44. The private key of the second communication party can be a second quantum key generated by a second quantum key distribution server, or a random number.

[0144] In the technical solution provided in the embodiment of the present application, in the key negotiation stage, a quantum key is used to replace a random number as a private key, and the public key is generated by the private key, and then the session key is generated. The generation of quantum keys utilizes the superposition and measurement characteristics of quantum. Any eavesdropping behavior will cause the quantum state to change, which will be detected by the legitimate communicating parties. Therefore, it is difficult for an eavesdropper to obtain the quantum key. In the embodiment of the present application, a quantum key is used to generate a session key, which improves the security of the session key, thereby greatly improving the security of data transmission using the session key.

[0145] In some embodiments, Figure 8 As shown, a key negotiation method is also provided, which may include the following steps:

[0146] Step S81, obtaining the private key of the second communication party;

[0147] In an embodiment of the present application, the private key of the second communication party may be a quantum key or a random number.

[0148] If the private key of the second communication party is a quantum key, the above step S81 can be: obtaining the second quantum key generated by the second quantum key distribution server as the private key of the second communication party, that is, the second communication party interacts with the second quantum key distribution server to obtain the second quantum key, and then uses the second quantum key to replace the random number as the private key.

[0149] The second quantum key distribution server is a quantum key distribution server connected to the second communication party. The second quantum key distribution server is used to generate a quantum key (such as a second quantum key) and distribute the second quantum key to the second communication party.

[0150] If the private key of the second communication party is a random number, the above step S81 may be: using the local random number generation algorithm to generate a random number within a specified random number range as the private key of the second communication party.

[0151] Step S82, using the private key of the second communication party to generate a second public key of the second communication party;

[0152] The second public key is a public key used by the second communication party to generate a session password. After obtaining the second communication party's private key (such as a second quantum key), the second communication party uses the second communication party's private key to generate the second communication party's second public key, and then executes step S83 to send the second public key to the first communication party.

[0153] Step S83: Send the second public key to the first communication party, so that the first communication party generates a second session key for conducting a conversation with the second communication party using the second public key and the first quantum key of the first communication party.

[0154] In the technical solution provided by the embodiment of the present application, the first communication party uses the first quantum key to generate the first public key, prompting the second communication party to generate the first session key associated with the first quantum key, and also uses the first quantum key to generate the second session key of this end. At the first communication party end, it is difficult for an eavesdropper to obtain the first quantum key, and then it is difficult to obtain the second session key, which further improves the security of the session key, and then greatly improves the security of data transmission using the session key.

[0155] The specific manner of generating the first public key, the second public key, the first session key and the second session key is related to the key exchange algorithm negotiated by the first communication party and the second communication party.

[0156] In some embodiments, the key exchange algorithm negotiated by the first communication party and the second communication party is a DH algorithm. In this case, before obtaining the private key of the second communication party, the method further includes: obtaining a shared factor between the first communication party and the second communication party, the shared factor including a prime number and a primitive root of the prime number;

[0157] The above step S82 may be: calculating the power of the private key of the second communication party of the primitive root to obtain a third value; taking the third value modulo a prime number to obtain a second public key of the second communication party;

[0158] The above step S72 may be: calculating the power of the private key of the second communication party of the first public key to obtain a fourth value; taking the fourth value modulo a prime number to obtain a first session key for the conversation with the first communication party. Figure 4 and Figure 6 Description of the part.

[0159] In an embodiment of the present application, the first communicating party involves the first quantum key in the DH interaction of the first session key, thereby improving the security of the first session key and further improving the security of subsequent data transmission.

[0160] The key negotiation method provided in the embodiment of the present application can be applied to the process of establishing an SSH connection, that is, the key negotiation method replaces the key negotiation process in the process of establishing an SSH connection. Figure 9a~Figure 9c The SSH connection establishment process shown in the figure is as follows: Figure 9a The process of establishing an SSH connection using quantum keys on the client side. Figure 9b The process of establishing an SSH connection using quantum keys on the server side. Fig.9c The process of establishing an SSH connection using quantum keys on both the client and the server.

[0161] exist Figure 9a~Figure 9cIn the process of establishing the SSH connection shown, after the TCP connection is established, the process includes a version negotiation phase, a key and algorithm negotiation phase, an authentication phase, a session request phase, and a session interaction phase. For the version negotiation phase, the authentication phase, the session request phase, and the session interaction phase, refer to the prior art.

[0162] In the key and algorithm negotiation phase, such as Figure 9a~Figure 9c As shown, it can be divided into the algorithm negotiation phase and the key negotiation phase. In the algorithm negotiation phase, the server and the client send algorithm negotiation messages to the other end respectively to negotiate the algorithm. The algorithm negotiation message contains the key exchange algorithm list, public key algorithm list, encryption algorithm list, MAC algorithm list, compression algorithm list, etc. that they support. The server and the client derive the final algorithm to be used based on the algorithm list supported by the other end and the client. For details, please refer to the prior art.

[0163] exist Figure 9a In the key negotiation phase shown in the figure, the client interacts with the server to obtain the shared factors, which include the prime number p and the primitive root g of the prime number. <g<p;

[0164] The client interacts with the quantum key distribution server 1, obtains the quantum key Q1, calculates g^Q1 mod(p), obtains the public key Q1', and sends the public key Q1' to the server;

[0165] The server generates a random number b within the specified random number range, calculates g^b mod(p), obtains the public key b', and sends the public key b' to the client;

[0166] The client calculates b'^Q1 mod(p) to obtain the session key Sa, and the server calculates Q1'^b mod(p) to obtain the session key Sb. The session key Sa is the same as the session key Sb.

[0167] exist Figure 9b In the key negotiation phase shown in the figure, the client interacts with the server to obtain the shared factors, which include the prime number p and the primitive root g of the prime number. <g<p;

[0168] The client generates a random number a within the specified random number range, calculates g^a mod(p), obtains the public key a', and sends the public key a' to the server;

[0169] The server interacts with quantum key distribution server 2, obtains quantum key Q2, calculates g^Q2 mod(p), obtains public key Q2', and sends public key Q2' to the client;

[0170] The client calculates Q2'^a mod(p) to obtain the session key Sa, and the server calculates a'^Q2 mod(p) to obtain the session key Sb. The session key Sa is the same as the session key Sb.

[0171] exist Fig.9c In the key negotiation phase shown in the figure, the client interacts with the server to obtain the shared factors, which include the prime number p and the primitive root g of the prime number. <g<p;

[0172] The client interacts with the quantum key distribution server 1, obtains the quantum key Q1, calculates g^Q1 mod(p), obtains the public key Q1', and sends the public key Q1' to the server;

[0173] The server interacts with quantum key distribution server 2, obtains quantum key Q2, calculates g^Q2 mod(p), obtains public key Q2', and sends public key Q2' to the server;

[0174] The client calculates Q2'^Q1 mod(p) to obtain the session key Sa, and the server calculates Q1'^Q2 mod(p) to obtain the session key Sb. The session key Sa is the same as the session key Sb.

[0175] The session key Sa and the session key Sb can be used for encryption and decryption of data between the client and the server during the session interaction phase.

[0176] In the embodiment of the present application, quantum keys can be used on one or both sides of the client and the server according to actual security requirements to improve the security of the private key on one or both sides and improve the security of data transmission. The key negotiation method provided in the embodiment of the present application can also be applied to other connection establishment processes, which is not limited to this.

[0177] Corresponding to the above-mentioned key negotiation method, the embodiment of the present application also provides a key negotiation device, such as Fig.10 As shown, applied to the first communication party, including:

[0178] An acquisition module 101 is used to acquire a first quantum key generated by a first quantum key distribution server;

[0179] A first generating module 102, configured to generate a first public key of a first communication party using a first quantum key;

[0180] The sending module 103 is used to send the first public key to the second communication party, so that the second communication party uses the first public key and the private key of the second communication party to generate a first session key for conducting a session with the first communication party.

[0181] In some embodiments, the key agreement device may further include:

[0182] A receiving module, used to receive a second public key sent by a second communication party, where the second public key is a public key generated by the second communication party using the second communication party's private key;

[0183] The second generating module is used to generate a second session key for conducting a conversation with a second communication party by using the second public key and the first quantum key.

[0184] In some embodiments, the acquisition module 101 may also be used to acquire a shared factor between the first communication party and the second communication party before acquiring the first quantum key generated by the first quantum key distribution server, where the shared factor includes a prime number and a primitive root of the prime number;

[0185] The first generation module 102 may be specifically configured to: calculate the first quantum key power of the primitive root to obtain a first value; modulo the first value with a prime number to obtain a first public key of the first communication party;

[0186] The second generation module can be specifically used to: calculate the first quantum key power number of the second public key to obtain a second value; modulo the second value with a prime number to obtain a second session key for conducting a conversation with a second communication party.

[0187] In some embodiments, the private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

[0188] In the technical solution provided in the embodiment of the present application, in the key negotiation stage, a quantum key is used to replace a random number as a private key, and the public key is generated by the private key, and then the session key is generated. The generation of quantum keys utilizes the superposition and measurement characteristics of quantum. Any eavesdropping behavior will cause the quantum state to change, which will be detected by the legitimate communicating parties. Therefore, it is difficult for an eavesdropper to obtain the quantum key. In the embodiment of the present application, a quantum key is used to generate a session key, which improves the security of the session key, thereby greatly improving the security of data transmission using the session key.

[0189] Corresponding to the above-mentioned key negotiation method, the embodiment of the present application also provides a key negotiation device, such as Fig.11 As shown, applied to the second communication party, including:

[0190] A receiving module 111 is configured to receive a first public key sent by a first communication party, where the first public key is a public key obtained by the first communication party according to any of the above key agreement devices;

[0191] The first generating module 112 is configured to generate a first session key for conducting a session with the first communicating party by using the first public key and the private key of the second communicating party.

[0192] In some embodiments, the key agreement device may further include:

[0193] An acquisition module, used to acquire a private key of a second communication party;

[0194] A second generating module, used to generate a second public key of the second communicating party using the private key of the second communicating party;

[0195] The sending module is used to send a second public key to the first communication party, so that the first communication party uses the second public key and the first quantum key of the first communication party to generate a second session key for conducting a conversation with the second communication party.

[0196] In some embodiments, the acquisition module may also be used to acquire a shared factor between the first communication party and the second communication party before acquiring the private key of the second communication party, the shared factor including a prime number and a primitive root of the prime number;

[0197] The second generation module can be specifically used to: calculate the power of the private key of the second communication party of the primitive root to obtain a third value; modulo the third value with a prime number to obtain the second public key of the second communication party;

[0198] The first generation module 112 can be specifically used to: calculate the power of the private key of the second communication party of the first public key to obtain a fourth value; and take the fourth value modulo a prime number to obtain a first session key for a session with the first communication party.

[0199] In some embodiments, the private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

[0200] In the technical solution provided in the embodiment of the present application, in the key negotiation stage, a quantum key is used to replace a random number as a private key, and the public key is generated by the private key, and then the session key is generated. The generation of quantum keys utilizes the superposition and measurement characteristics of quantum. Any eavesdropping behavior will cause the quantum state to change, which will be detected by the legitimate communicating parties. Therefore, it is difficult for an eavesdropper to obtain the quantum key. In the embodiment of the present application, a quantum key is used to generate a session key, which improves the security of the session key, thereby greatly improving the security of data transmission using the session key.

[0201] The present application also provides a communication device, such as Fig.12 As shown, it includes a processor 121 and a machine-readable storage medium 122, the machine-readable storage medium 122 stores machine-executable instructions that can be executed by the processor 121, and the processor 121 is prompted by the machine-executable instructions to implement any of the above-mentioned key negotiation methods applied to the first communication party.

[0202] The present application also provides a communication device, such as Fig.13As shown, it includes a processor 131 and a machine-readable storage medium 132, the machine-readable storage medium 132 stores machine-executable instructions that can be executed by the processor 131, and the processor 131 is prompted by the machine-executable instructions to implement any of the above-mentioned key negotiation methods applied to the second communication party.

[0203] In an embodiment of the present application, the communication device may further include a communication interface and a communication bus, wherein the processor, the communication interface, and the machine-readable storage medium communicate with each other via the communication bus.

[0204] The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0205] The communication interface is used for communication between the above electronic device and other devices.

[0206] The machine-readable storage medium may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. Optionally, the machine-readable storage medium may also be at least one storage device located away from the aforementioned processor.

[0207] The processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0208] In another embodiment provided in the present application, a computer-readable storage medium is also provided, in which a computer program is stored. When the computer program is executed by a processor, it implements any of the above-mentioned key negotiation methods applied to the first communication party, or implements any of the above-mentioned key negotiation methods applied to the second communication party.

[0209] In another embodiment provided in the present application, a computer program product comprising instructions is also provided. When the computer is run on a computer, the computer executes any of the key negotiation methods applied to the first communication party, or executes any of the key negotiation methods applied to the second communication party.

[0210] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0211] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0212] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, communication equipment, storage medium and program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0213] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A key negotiation method, characterized in that: Applied to a first communication party, the method comprises: Obtaining a first quantum key generated by a first quantum key distribution server; Using the first quantum key, generating a first public key of the first communication party; The first public key is sent to a second communication party, so that the second communication party generates a first session key for conducting a session with the first communication party by using the first public key and a private key of the second communication party.

2. The method according to claim 1, characterized in that The method further comprises: receiving a second public key sent by the second communication party, where the second public key is a public key generated by the second communication party using the second communication party's private key; A second session key for conducting a conversation with the second communicating party is generated using the second public key and the first quantum key.

3. The method according to claim 2, characterized in that Before obtaining the first quantum key generated by the first quantum key distribution server, the method further includes: Acquire a shared factor between the first communication party and the second communication party, wherein the shared factor includes a prime number and a primitive root of the prime number; The generating a first public key of the first communication party by using the first quantum key specifically includes: Calculating the first quantum key power number of the primitive root to obtain a first value; taking the first value modulo the prime number to obtain a first public key of the first communication party; The step of generating a second session key for conducting a conversation with the second communication party by using the second public key and the first quantum key specifically includes: Calculate the first quantum key power of the second public key to obtain a second value; and take the second value modulo the prime number to obtain a second session key for conducting a conversation with the second communication party.

4. The method according to any one of claims 1 to 3, characterized in that: The private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

5. A key negotiation method, characterized in that: Applied to the second communication party, the method comprises: Receiving a first public key sent by the first communication party, where the first public key is a public key obtained by the first communication party according to the method described in any one of claims 1 to 4; A first session key for conducting a session with the first communication party is generated using the first public key and the private key of the second communication party.

6. The method according to claim 5, characterized in that The method further comprises: Obtaining a private key of the second communication party; generating a second public key of the second communication party using the private key of the second communication party; The second public key is sent to the first communication party, so that the first communication party generates a second session key for conducting a conversation with the second communication party by using the second public key and the first quantum key of the first communication party.

7. The method according to claim 6, characterized in that Before obtaining the private key of the second communication party, the method further includes: Acquire a shared factor between the first communication party and the second communication party, wherein the shared factor includes a prime number and a primitive root of the prime number; The step of generating the second public key of the second communication party by using the private key of the second communication party specifically includes: Calculate the power of the private key of the second communication party of the primitive root to obtain a third value; modulo the third value with the prime number to obtain the second public key of the second communication party; The step of generating a first session key for a session with the first communication party by using the first public key and the private key of the second communication party specifically includes: Calculate the power of the private key of the second communication party of the first public key to obtain a fourth value; take the fourth value modulo the prime number to obtain a first session key for conducting a session with the first communication party.

8. The method according to any one of claims 5 to 7, characterized in that: The private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

9. A key agreement device, characterized in that: Applied to a first communication party, the device comprises: An acquisition module, used to acquire a first quantum key generated by a first quantum key distribution server; A first generating module, configured to generate a first public key of the first communicating party using the first quantum key; The sending module is used to send the first public key to the second communication party, so that the second communication party uses the first public key and the private key of the second communication party to generate a first session key for conducting a session with the first communication party.

10. The device according to claim 9, characterized in that The device also includes: A receiving module, used to receive a second public key sent by the second communication party, where the second public key is a public key generated by the second communication party using the private key of the second communication party; The second generating module is used to generate a second session key for conducting a session with the second communicating party by using the second public key and the first quantum key.

11. The device according to claim 10, characterized in that The acquisition module is further configured to acquire a shared factor between the first communication party and the second communication party before acquiring the first quantum key generated by the first quantum key distribution server, wherein the shared factor includes a prime number and a primitive root of the prime number; The first generating module is specifically used to: calculate the first quantum key power number of the primitive root to obtain a first value; take the first value modulo the prime number to obtain the first public key of the first communication party; The second generation module is specifically used to: calculate the first quantum key power number of the second public key to obtain a second value; and take the second value modulo the prime number to obtain a second session key for conducting a conversation with the second communication party.

12. The device according to any one of claims 9 to 11, characterized in that: The private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.

13. A key negotiation device, characterized in that: Applied to a second communication party, the device comprises: A receiving module, configured to receive a first public key sent by the first communication party, where the first public key is a public key obtained by the first communication party according to the apparatus according to any one of claims 9 to 12; The first generating module is used to generate a first session key for conducting a session with the first communicating party by using the first public key and the private key of the second communicating party.

14. The device according to claim 13, characterized in that The device also includes: An acquisition module, used to acquire the private key of the second communication party; A second generating module, used to generate a second public key of the second communicating party by using the private key of the second communicating party; The sending module is used to send the second public key to the first communication party, so that the first communication party uses the second public key and the first quantum key of the first communication party to generate a second session key for conducting a conversation with the second communication party.

15. The device according to claim 14, characterized in that The acquisition module is further configured to acquire a shared factor between the first communication party and the second communication party before acquiring the private key of the second communication party, wherein the shared factor includes a prime number and a primitive root of the prime number; The second generation module is specifically used to: calculate the power of the private key of the second communication party of the primitive root to obtain a third value; modulo the third value with the prime number to obtain the second public key of the second communication party; The first generation module is specifically used to: calculate the power of the private key of the second communication party of the first public key to obtain a fourth value; and take the fourth value modulo the prime number to obtain a first session key for conducting a conversation with the first communication party.

16. The device according to any one of claims 13 to 15, characterized in that: The private key of the second communicating party is a second quantum key generated by a second quantum key distribution server, or a random number.