Double-encryption method based on ipsec and quantum key, and encryption gateway
Through the dual encryption method of IPsec and quantum key, data encryption is used to use quantum key distribution centers and security alliances to solve the network bandwidth overhead problems caused by IPSec VPN deployment and improve the security of data transmission in a quantum computing environment.
Patent Information
- Application Number
- PCT/CN2024/120830
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-08
- Filing Date
- 2024-09-24
- Publication Date
- 2025-06-12
AI Technical Summary
The prior art adds additional data encapsulation overhead when deploying through IPSec VPN, resulting in reduced network bandwidth and the risk of traditional key exchange protocols being deciphered in quantum computing environments.
Using a dual encryption method based on IPsec and quantum keys, the encryption gateway uses the quantum key distribution center to register, encrypt or decrypt the tag, and double encryption or decryption is used to use the security alliance and quantum key to ensure that the data is end-to-end encryption without adding additional load encapsulation.
It improves the confidentiality of data packets, avoids the additional overhead of network bandwidth, and enhances the security of data transmission in a quantum computing environment.
Smart Images

Figure CN2024120830_12062025_PF_FP_ABST
Abstract
Description
Dual encryption method based on IPsec and quantum key, encryption gateway
[0001] This application claims priority to the Chinese patent disclosure with application number 202311694033.6, filed with the China Patent Office on December 8, 2023, entitled “Dual encryption method and encryption gateway based on IPsec and quantum key”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the fields of cryptographic applications and network security, and specifically to a dual encryption method and encryption gateway based on IPsec and quantum key. Background Art
[0003] Typically, secure data transmission between branch offices is achieved through VPN (Virtual Native Network) gateways that build IPSec (Internet Protocol Security) tunnels. This ensures the confidentiality, integrity, and authentication of IP layer packets. If branch offices are connected using a carrier's dedicated lines, deploying IPSec VPNs will encapsulate security payloads (ESPs), altering the original structure of data packets. This can add overhead and reduce transmission efficiency for users with limited network bandwidth.
[0004] At the same time, with the improvement of quantum computing capabilities, traditional key exchange protocols will transmit negotiation materials during the negotiation process, and the negotiated session key may be deciphered.
[0005] In related technology, Chinese invention patent application publication number CN116405206A discloses a method for data encryption and decryption in a secure gateway. This scheme uses quantum key encryption and transmits the quantum key's session ID as the SPI (Security Parameter Index) in the encapsulated security payload (ESP) to the peer end for data decryption. However, this scheme also adds additional data encapsulation to the payload data, increasing network bandwidth overhead for users.
[0006] In the related art, the Chinese invention patent application document with application publication number CN115567205A discloses a method for implementing network session data stream encryption and decryption using quantum key distribution. The main features of this scheme are: (1) a mapping relationship is established between the ID of the quantum master key and the 5-tuple network session stream through the quantum distribution network, and the master key identifier is placed in the security message header of the encrypted data message to achieve end-to-end encrypted communication. (2) The functions of establishing, aging, and deleting the flow table are realized. This scheme also adds additional data encapsulation, increases the user's network bandwidth overhead, and is complex to implement.
[0007] Summary of the Invention
[0008] The technical problem to be solved by this application is how to achieve end-to-end encryption of data payloads without adding additional payload encapsulation, thereby improving the confidentiality of data messages without reducing user bandwidth usage.
[0009] This application solves the above technical problems through the following technical means:
[0010] In the first aspect, the present application proposes a dual encryption method based on IPsec and quantum key for encrypting a gateway, comprising the following steps:
[0011] The encryption gateway registers with the quantum key distribution center through a unique identifier. After successful registration, the quantum key distribution center injects quantum keys into the encryption gateway.
[0012] The encryption gateway receives the incoming data message and adds an encryption tag or a decryption tag to the data packet of the incoming data message;
[0013] Use the encryption label or decryption label to create a mount node and send the data packet with the encryption label or decryption label;
[0014] After the data is encrypted once using the security association, the quantum key sa is used to encrypt the data encrypted by the security association again. The double-encrypted data becomes outbound message data and is sent out from the encryption gateway, or the data is double-decrypted to obtain the original ciphertext.
[0015] As a further technical solution, the encryption gateway receives the incoming data message and adds an encryption tag or a decryption tag to the data packet of the incoming data message, including the following steps:
[0016] The data packet enters the stack;
[0017] Match outbound security policies based on the five-tuple information.
[0018] Determine whether the outbound security policy matches successfully.
[0019] If the outbound security policy matches, the incoming data packet is encrypted and the corresponding security association is checked based on the outbound security policy.
[0020] If a security association exists, the security association information is saved in the data message;
[0021] If an SA does not exist, the IKE protocol is used to negotiate an SA and store the SA information in the data packet.
[0022] If the outbound security policy fails to match, the source and destination addresses of the incoming data packet are swapped, and the inbound security policy is matched based on the five-tuple information.
[0023] Determine whether the inbound security policy matches successfully.
[0024] If the inbound security policy matches successfully, the incoming data packet is tagged with a decryption tag.
[0025] If the inbound security policy fails to match, the incoming data packet cannot match either the outbound or inbound security policy and is discarded.
[0026] As a further technical solution, after the data is encrypted once using the security association, the data encrypted by the security association is encrypted again using the quantum key sa. The double-encrypted data becomes the outbound message data and is sent out from the encryption gateway, or the data is double-decrypted to obtain the ciphertext. Specifically, the following steps are performed:
[0027] Receive data with encryption or decryption tags;
[0028] Determine whether it is an outbound label or an inbound label;
[0029] If it is an outgoing label, the data message is encrypted using the security association through the encryption label;
[0030] Obtain the quantum key sa, and use the quantum key sa to re-encrypt the data encrypted by the security association;
[0031] The data processed by the data encryption and decryption module becomes outbound message data and is sent out from the encryption gateway;
[0032] If it is an incoming tag, the quantum key sa is obtained by decrypting the tag, and the quantum key sa is used to decrypt the data;
[0033] The data message is decrypted using the security association to obtain the original data message.
[0034] As a further technical solution, data encryption adopts the CBC+ mode. The encryption tag and the security association are used to encrypt the data message, which specifically include:
[0035] For data length greater than one encryption block, take an integer multiple of the encryption block and perform CBC encryption to obtain ciphertext data 1;
[0036] If the remaining length is less than that of the data of one encrypted block, take the ciphertext of the previous block as the IV value, encrypt the IV with the session key K, use the SM4 algorithm, and the ECB encryption mode to obtain the Kiv, truncate the Kiv to make its length equal to the plaintext data length, and then XOR it with the plaintext data to obtain the ciphertext data 2;
[0037] Concatenate ciphertext data 1 and ciphertext data 2 to obtain the complete ciphertext;
[0038] The decryption process of using the security association to decrypt the data message to obtain the original data message specifically includes:
[0039] For data length greater than one decryption block, take an integer multiple of the encrypted block for CBC decryption to obtain plaintext data 1;
[0040] If the remaining length is less than that of an encrypted data block, take the ciphertext of the previous block before decryption as the IV value, decrypt the IV using the session key K, use the SM4 decryption algorithm, and use the ECB decryption mode to obtain the Kiv. Truncate the Kiv so that its length equals the ciphertext data length, and then XOR it with the ciphertext data to obtain the plaintext data 2.
[0041] Concatenate plaintext data 1 and plaintext data 2 to obtain the complete plaintext.
[0042] As a further technical solution, the step of obtaining the quantum key sa and re-encrypting the data encrypted by the security association using the quantum key sa specifically includes:
[0043] The quantum key ID is calculated using the SPI of the initiator and responder in the security association. The quantum key ID calculated using SPI is unique.
[0044] Obtain the quantum key sa through the quantum key ID in the quantum key pool;
[0045] The data encrypted by IPSec sa is encrypted again using the quantum key sa. The encryption method is the same as that in S403.
[0046] The process of obtaining the quantum key sa by decrypting the tag and decrypting the data using the quantum key sa specifically includes:
[0047] The quantum key ID is calculated using the SPI of the initiator and responder in the security association. The quantum key ID calculated using SPI is unique.
[0048] Obtain the quantum key sa through the quantum key ID in the quantum key pool;
[0049] The quantum key sa is used to decrypt the data encrypted by IPSec sa. The decryption method is the same as that in S407.
[0050] In a second aspect, the present application further provides an encryption gateway for executing a dual encryption method based on IPsec and quantum key described in any of the above technical solutions, comprising:
[0051] The quantum key module is used for the encryption gateway to register with the quantum key distribution center through a unique identifier. After successful registration, the quantum key distribution center injects quantum keys into the quantum key module of the encryption gateway;
[0052] The xfrm module is used to receive incoming data packets and call the encryption and decryption tags of the iptables module to add encryption tags or decryption tags to the incoming data packets;
[0053] The iptables module creates encryption and decryption labels in advance, sets rules in the POSTROUTING chain of the mangel table, creates a mount node using the encryption or decryption labels, and sends the data packets marked with the encryption or decryption labels to the encryption and decryption modules.
[0054] The data encryption and decryption module uses the security alliance to encrypt the data once, and then uses the quantum key sa to encrypt the data encrypted by the security alliance again. The double-encrypted data becomes the out-stack message data and is sent out from the encryption gateway, or the data is double-decrypted to obtain the original ciphertext.
[0055] As a further technical solution, the xfrm module specifically includes:
[0056] xfrm module entry unit: used to push data packets into the xfrm module;
[0057] Outbound security policy matching unit: used to match outbound security policies based on quintuple information;
[0058] The first judgment unit is used to judge whether the matching of the outbound security policy is successful;
[0059] Security Association Lookup Unit: If the outbound security policy matches successfully, it adds an encryption tag to the incoming data packet and searches for the corresponding security association based on the outbound security policy.
[0060] Encryption tag unit: When a security association exists, the security association information is saved in the data message;
[0061] Security Association Negotiation Unit: When an SA does not exist, it is used to negotiate an SA through the IKE protocol and save the SA information in the data message.
[0062] Inbound security policy matching unit: When an outbound security policy match fails, it swaps the source and destination addresses of incoming data packets and matches the inbound security policy based on the five-tuple information.
[0063] The second judgment unit is used to judge whether the inbound security policy is matched successfully;
[0064] Decryption tagging unit: If the inbound security policy is successfully matched, the incoming data packet is tagged with a decryption tag.
[0065] Discard unit: If the incoming data packet does not match the outbound security policy or the inbound security policy, it is discarded.
[0066] As a further technical solution, the data encryption and decryption module specifically includes:
[0067] Data receiving unit: receives data with encryption or decryption tags;
[0068] Direction label determination unit: determines whether it is an outgoing label or an incoming label;
[0069] The encryption unit, if it is an outgoing label, encrypts the data message using the security association through the encryption label;
[0070] The re-encryption unit is used to obtain the quantum key sa and use the quantum key sa to re-encrypt the data encrypted by the security association;
[0071] The sending unit is used to convert the re-encrypted data into outbound message data and send it out from the encryption gateway;
[0072] The decryption unit, if it is an inbound tag, obtains the quantum key sa through the decryption tag and uses the quantum key sa to decrypt the data;
[0073] The decryption unit decrypts the data message again using the security association to obtain the original data message.
[0074] As a further technical solution, the data encryption adopts the CBC+ mode, which specifically includes:
[0075] For data length greater than one encryption block, take an integer multiple of the encryption block and perform CBC encryption to obtain ciphertext data 1;
[0076] If the remaining length is less than that of the data of one encrypted block, take the ciphertext of the previous block as the IV value, encrypt the IV with the session key K, use the SM4 algorithm, and the ECB encryption mode to obtain the Kiv, truncate the Kiv to make its length equal to the plaintext data length, and then XOR it with the plaintext data to obtain the ciphertext data 2;
[0077] Concatenate ciphertext data 1 and ciphertext data 2 to obtain the complete ciphertext;
[0078] The decryption process specifically includes:
[0079] For data length greater than one decryption block, take an integer multiple of the encrypted block for CBC decryption to obtain plaintext data 1;
[0080] If the remaining length is less than that of an encrypted data block, take the ciphertext of the previous block before decryption as the IV value, decrypt the IV using the session key K, use the SM4 decryption algorithm, and use the ECB decryption mode to obtain the Kiv. Truncate the Kiv so that its length equals the ciphertext data length, and then XOR it with the ciphertext data to obtain the plaintext data 2.
[0081] Concatenate plaintext data 1 and plaintext data 2 to obtain the complete plaintext.
[0082] In a third aspect, the present application further provides a dual encryption method based on IPsec and quantum key, which is applicable to message data transmitted from a first encryption gateway to a second encryption gateway, wherein the first encryption gateway and the second encryption gateway adopt the mechanism described in any one of claims 6 to 9, and the encryption method comprises the following steps:
[0083] The first encryption gateway registers with the quantum key distribution center through the unique identifier and the unique identifier of the second encryption gateway. After successful registration, the quantum key distribution center injects the first quantum key into the quantum key module of the first encryption gateway. The second encryption gateway registers with the quantum key distribution center through the unique identifier and the unique identifier of the first encryption gateway. After successful registration, the quantum key distribution center injects the second quantum key into the quantum key module of the second encryption gateway. The identifiers registered by the first encryption gateway and the second encryption gateway quantum to the key distribution center are the same, forming the same quantum key pool, that is, the first quantum key and the second quantum key are the same;
[0084] The first encryption gateway receives the incoming data message and adds an encryption tag to the data packet of the incoming data message through the xfrm module;
[0085] The iptables module of the first encryption gateway sends the encrypted labeled data packet in S2 to the encryption and decryption module through the hook node created by the encryption label;
[0086] The data encryption and decryption module of the first encryption gateway uses the encryption tag and the security alliance stored in the data message to encrypt the data message, obtains the quantum key sa from the quantum key pool, and uses the quantum key sa to encrypt the data encrypted by the security alliance again before sending it out;
[0087] After receiving the ciphertext data from the first encryption gateway, the second encryption gateway swaps the source and destination addresses, matches the outbound security policy in the xfrm module using the five-tuple information, and obtains the security association corresponding to the security policy. At the same time, it adds a decryption tag to the incoming data message.
[0088] The iptables module of the second encryption gateway uses the hook node created by the decryption label to send the data packet marked with the decryption label in step S5 to the encryption and decryption module;
[0089] The second encryption gateway obtains the quantum key sa from the quantum key pool of the quantum encryption module and uses the quantum key sa to decrypt the data;
[0090] The data encryption and decryption module of the second encryption gateway decrypts the data message again using the security association stored in the data message through the decryption tag to obtain the original text of the data message.
[0091] In a fourth aspect, the present application proposes a computing and processing device, comprising: a memory storing computer-readable code; and one or more processors. When the computer-readable code is executed by the one or more processors, the computing and processing device executes the authentication method based on double quantum random number protection as described above.
[0092] In a fifth aspect, the present application proposes a computer program, which includes a computer-readable code. When the computer-readable code is run on a computing processing device, it causes the computing processing device to execute any one of the authentication methods based on double quantum random number protection as described above.
[0093] In a sixth aspect, the present application proposes a computer-readable medium in which the computer program described above is stored.
[0094] This method uses quantum key distribution, xfrm, and iptables modules to encrypt the payload data behind the IP header. The main innovations are:
[0095] (1) Using IPSec SA and Quantum SA to double encrypt data, security is improved;
[0096] (2) Data encapsulation does not require additional payload encapsulation and does not change the original structure of the data packet. It is applicable to a wider range of network environments. No matter how complex the intermediate network environment is, the data packet can be transmitted normally in the network without incurring additional overhead on the user's network bandwidth.
[0097] (3) There is a quantum SA for each security policy. As long as the security policy subnet is configured to a 32-bit mask, one-level-one-key can be achieved, increasing data security.
[0098] This method not only meets the networking environment of traditional VPN, but also provides a data encryption mechanism based on the 2-layer network (data link layer), realizing a safer and more efficient encrypted transmission method. In addition, the link is completely transparent and the connection is extremely easy to deploy. BRIEF DESCRIPTION OF THE DRAWINGS
[0099] FIG1 is a block diagram of a data encryption system based on quantum key according to an embodiment of the present application;
[0100] FIG2 is a block diagram of the connection structure of the encryption gateway and the quantum key distribution system in an embodiment of the present application;
[0101] FIG3 is a flow chart of data processing of the xfrm module in the encryption gateway in an embodiment of the present application;
[0102] FIG4 is a flow chart of data processing in a data encryption and decryption module in an encryption gateway according to an embodiment of the present application;
[0103] FIG5 is a flowchart of the interaction between encryption gateways in an embodiment of the present application;
[0104] FIG6 is a schematic diagram of the structure of a computing and processing device proposed in an embodiment of the present application;
[0105] FIG7 is a schematic structural diagram of a storage unit for program code proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0106] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0107] 2 and 5 , the present application provides a dual encryption method based on IPsec and quantum key for an encryption gateway, the encryption gateway comprising:
[0108] Stacked data message: data message received by the encrypted gateway;
[0109] Outbound data message: data message after encryption or decryption;
[0110] The xfrm module implements the addition, deletion, modification, and query of security policies (sp), negotiates and ages security associations (sa), matches incoming data packets against security policies, and tags them for encryption and decryption based on the matching policy.
[0111] Among them, xfrm stands for Transform, which is part of the IPsec protocol stack.
[0112] iptables (firewall) module: creates encryption and decryption tags, sets rules in the POSTROUTING chain of the mangel table, creates hooks using encryption and decryption tags, and uses the hook mechanism to send data matching the encryption and decryption tags to the data encryption and decryption module.
[0113] Among them, iptables is a firewall and network address translation tool, mangel is used to modify specific fields of the data packet, and POSTROUTING is used to process the data packet after the routing decision.
[0114] Data encryption and decryption module: Encrypts or decrypts data packets by judging the labels of data packets. The encryption and decryption keys come from IKE key negotiation and quantum key distribution.
[0115] The double encryption method comprises the following steps:
[0116] S10: The encryption gateway registers with the quantum key distribution center using a unique identifier. After successful registration, the quantum key distribution center injects quantum keys into the quantum key module of the encryption gateway. The identifiers registered by each communicating encryption gateway to the quantum key distribution center are consistent, forming the same quantum key pool.
[0117] S20: The encryption gateway receives the incoming data message and adds an encryption tag or a decryption tag to the data packet of the incoming data message through the xfrm module. Referring to FIG3 , which is a flow chart of data processing by the xfrm module in the encryption gateway in an embodiment of the present application, step S20 specifically includes:
[0118] S201: The data packet is pushed into the xfrm module;
[0119] S202: The xfrm module matches the outbound security policy (sp) according to the five-tuple information (source IP address, destination IP address, source port, destination port, protocol);
[0120] S203: Determine whether the matching of the directional security policy (sp) is successful. If successful, proceed to S204. If not, proceed to S207.
[0121] S204: The outbound security policy (sp) matches successfully. The xfrm module calls the encryption label of the iptables module to add an encryption label to the incoming data packet. The xfrm module checks whether the corresponding security association (IPSec sa) exists according to the outbound security policy (sp). If so, the process proceeds to S205. If not, the process proceeds to S206.
[0122] S205: The security association (IPSec sa) exists, and the IPSec sa information is saved in the data message;
[0123] S206: The security association (IPSec sa) does not exist. The xfrm module negotiates the security association (IPSec sa) through the IKE protocol and saves the IPSec sa information in the data message.
[0124] S207: If the outbound security policy (sp) fails to match, the xfrm module swaps the source address and destination address of the incoming data packet and uses the xfrm module to match the inbound security policy (sp) based on the five-tuple information (source IP address, destination IP address, source port, destination port, protocol).
[0125] S208: Determine whether the inbound security policy (sp) is matched successfully. If so, proceed to S209; if not, proceed to S210.
[0126] S209: The xfrm module calls the decryption tag of the iptables module to add a decryption tag to the incoming data packet;
[0127] S210: If the incoming data packet does not match the outgoing security policy (sp) or the incoming security policy (sp), it is discarded.
[0128] S30: The iptables module of the encryption gateway creates a mount node using the encryption label or the decryption label, and sends the data packet marked with the encryption label or the decryption label in S204 or S209 to the encryption and decryption module.
[0129] Step S40: The data encryption and decryption module encrypts the data into outbound message data and sends it out from the encryption gateway, or decrypts the data to obtain the original ciphertext. Referring to Figure 4, which is a data processing flow chart of the data encryption and decryption module in the encryption gateway in an embodiment of the present application, step S40 specifically includes:
[0130] Step S401: The incoming message data enters the data encryption and decryption module according to the encryption or decryption tag;
[0131] Step S402: Determine whether it is an outgoing label or an incoming label. If it is an outgoing label, proceed to steps S403 to S405; if it is an incoming label, proceed to step S406.
[0132] Step S403: The data encryption and decryption module of the encryption gateway encrypts the data message using the IPSec sa stored in the data message through the encryption tag. The data encryption adopts the CBC+ (CBC, Cipher Block Chaining) mode, which specifically includes:
[0133] For data length greater than one encryption block (16 bytes), take data that is an integer multiple of 16 bytes and perform CBC encryption to obtain ciphertext data 1;
[0134] For data with a length less than 16 bytes, use the ciphertext from the previous block as the IV value. Encrypt the IV using the session key K, using the SM4 algorithm and the ECB (Electronic Codebook) encryption mode to obtain the Kiv (Key and Initialization Vector). Truncate the Kiv to make it equal to the plaintext length, then XOR it with the plaintext to obtain the ciphertext data 2.
[0135] The ciphertext data 1 and ciphertext data 2 are concatenated to obtain the complete ciphertext. The complete ciphertext does not add any additional encapsulation to the original data, thus achieving the goal of not changing the original message structure.
[0136] Step S404: The encryption gateway obtains the quantum key sa from the quantum key pool of the quantum encryption module, and uses the quantum key sa to re-encrypt the data encrypted by IPSec sa, which specifically includes:
[0137] S4041. The data encryption and decryption module calculates the quantum key ID using the SPIs of the initiator and responder in the IPSec SA. Since the SPI (Security Parameter Index) is used to uniquely identify the IPSec SA, the quantum key ID calculated using the SPI is also unique.
[0138] S4042. The data encryption and decryption module obtains the quantum key sa from the quantum key pool through the quantum key ID;
[0139] S4043. The data encryption and decryption module uses the quantum key sa to re-encrypt the data encrypted by IPSec sa. The encryption method is the same as that in S403.
[0140] Step S405: The data processed by the data encryption and decryption module becomes outbound message data and is sent out from the encryption gateway;
[0141] Step S406: The data encryption and decryption module of the encryption gateway obtains the quantum key sa from the quantum key pool of the quantum encryption module through the decryption tag, and uses the quantum key sa to decrypt the data. The decryption principle is the same as step S404, specifically including:
[0142] S4061. Calculate the quantum key ID using the SPIs of the initiator and responder in the security association. The quantum key ID calculated using the SPI is unique.
[0143] S4062. Obtain the quantum key sa from the quantum key pool using the quantum key ID;
[0144] S4063. Decrypt the data encrypted by IPSec sa using the quantum key sa. The decryption method is the same as that in S407.
[0145] Step S407: decrypt the data message again using the IPSec sa stored in the data message to obtain the original data message, which specifically includes the following:
[0146] For data length greater than one decryption block (16 bytes), take data that is an integer multiple of 16 bytes and perform CBC decryption to obtain plaintext data 1;
[0147] For data with a length less than 16 bytes, use the ciphertext of the previous block before decryption as the IV value. Decrypt the IV using the session key K, using the SM4 algorithm and ECB decryption mode to obtain Kiv. Truncate Kiv to make it equal to the ciphertext length, then XOR it with the ciphertext to obtain plaintext data 2.
[0148] Concatenate plaintext data 1 and plaintext data 2 to obtain the complete plaintext.
[0149] As shown in Figure 1, this embodiment provides a quantum key-based data encryption system, including a first encryption gateway, a second encryption gateway, and a quantum key center. The first and second encryption gateways are both connected to the quantum key center. Key negotiation is performed between the first and second encryption gateways. The first and second encryption gateways submit registration applications to the quantum key distribution center, which then distributes quantum keys to the first and second encryption gateways.
[0150] The first encryption gateway and the second encryption gateway have the same structure and adopt the encryption gateway structure and encryption method described in Example 1. Quantum key module: obtains batches of quantum keys from the quantum key distribution center. Each set of keys has a unique ID.
[0151] This application provides a dual encryption method based on IPsec and quantum key encryption, which is applicable to message data transmitted from a first encryption gateway to a second encryption gateway. The dual encryption method includes the following steps:
[0152] S1: The first encryption gateway registers with the quantum key distribution center using its unique identifier and the unique identifier of the second encryption gateway. After successful registration, the quantum key distribution center injects the first quantum key into the quantum key module of the first encryption gateway. The second encryption gateway registers with the quantum key distribution center using its unique identifier and the unique identifier of the first encryption gateway. After successful registration, the quantum key distribution center injects the second quantum key into the quantum key module of the second encryption gateway.
[0153] Among them, the identifiers registered by the first encryption gateway and the second encryption gateway quantum to the key distribution center are the same, which will form the same quantum key pool, that is, the first quantum key and the second quantum key are the same;
[0154] S2: The first encryption gateway receives the incoming data message and adds an encryption tag to the data packet of the incoming data message through the xfrm module. This is a data processing flow chart of the xfrm module in the encryption gateway in the embodiment of the present application. Step S2 specifically includes:
[0155] Step S201: Push data packets into the xfrm module;
[0156] Step S202: The xfrm module matches the outbound security policy (sp) according to the five-tuple information (source IP address, destination IP address, source port, destination port, protocol);
[0157] Step S203: Determine whether the outbound security policy (sp) matches successfully. If so, the xfrm module calls the encryption label of the iptables module to add an encryption label to the incoming data message, and then proceeds to S204.
[0158] Step S204: The xfrm module checks whether the corresponding security association (IPSec sa) exists according to the outbound security policy (sp). If it exists, it proceeds to S205. If it fails, it proceeds to S206.
[0159] Step S205: Save the IPSec sa information in the data message;
[0160] Step S206: The xfrm module negotiates a security association (IPSec sa) through the IKE protocol and saves the IPSec sa information in the data message;
[0161] S3: The iptables module of the first encryption gateway uses the hook node created by the encryption label to send the encrypted labeled data in S2 to the encryption and decryption module;
[0162] S4: The data encryption and decryption module encrypts the data into outbound message data, which is then sent out from the encryption gateway. Step S4 specifically includes:
[0163] Step S401: the incoming message data enters the data encryption and decryption module according to the encryption tag;
[0164] Step S402: Determine whether it is an outbound label or an inbound label. In this embodiment, if it is an outbound label, proceed to step S403.
[0165] Step S403: Data encryption processing is performed. The data encryption and decryption module of the first encryption gateway encrypts the data message using the IPSec sa stored in the data message through the encryption tag. The data encryption adopts the CBC+ mode, which specifically includes:
[0166] For data length greater than one encryption block (16 bytes), take data that is an integer multiple of 16 bytes and perform CBC encryption to obtain ciphertext data 1;
[0167] For data with a length less than 16 bytes, use the ciphertext of the previous block as the IV value. Encrypt the IV using the session key K, using the SM4 algorithm and ECB encryption mode to obtain Kiv. Truncate Kiv to make it equal to the length of the plaintext data, and then XOR it with the plaintext data to obtain ciphertext data 2.
[0168] The ciphertext data 1 and ciphertext data 2 are concatenated to obtain the complete ciphertext. The complete ciphertext does not add any additional encapsulation to the original data, thus achieving the goal of not changing the original message structure.
[0169] S404: The first encryption gateway obtains the quantum key sa from the quantum key pool of the quantum encryption module, and uses the quantum key sa to re-encrypt the data encrypted by IPSec sa. This step S404 specifically includes:
[0170] Step S4041: The data encryption and decryption module calculates the quantum key ID using the SPIs of the initiator and responder in the IPSec SA. Since the SPI (Security Parameter Index) is used to uniquely identify the IPSec SA, the quantum key ID calculated using the SPI is also unique.
[0171] Step S4042: The data encryption and decryption module obtains the quantum key sa from the quantum key pool through the quantum key ID;
[0172] Step S4043: The data encryption and decryption module uses the quantum key sa to re-encrypt the data encrypted by IPSec sa. The encryption method is the same as that in S403.
[0173] Step S405: The data processed by the data encryption and decryption module becomes outbound message data and is sent out from the first gateway;
[0174] S5: After receiving the ciphertext data from the first encryption gateway, the second encryption gateway swaps the source address and destination address, matches the outbound security policy (sp) in the xfrm module using the five-tuple information (source IP address, destination IP address, source port, destination port, protocol), and obtains the IPSec sa corresponding to sp. At the same time, the incoming data packet is labeled with a decryption tag. This process specifically includes the following steps:
[0175] Step S501: Push data packets into the xfrm module;
[0176] Step S502: The xfrm module matches the outbound security policy (sp) according to the five-tuple information (source IP address, destination IP address, source port, destination port, protocol);
[0177] Step S503: determining that the direction security policy (sp) fails to match, and proceeding to step S504;
[0178] Step S504: The xfrm module swaps the source address and destination address of the incoming data message, and uses the xfrm module to match the inbound security policy (sp) based on the five-tuple information (source IP address, destination IP address, source port, destination port, protocol);
[0179] Step S505: The inbound security policy (sp) is matched successfully.
[0180] Step S506: the xfrm module calls the decryption tag of the iptables module to add a decryption tag to the incoming data packet;
[0181] Step S6: The hook node created by the second encryption gateway using the decryption tag sends the data packet marked with the decryption tag in step S506 to the encryption and decryption module;
[0182] Step S7: The second encryption gateway obtains the quantum key sa from the quantum key pool of the quantum encryption module and uses the quantum key sa to decrypt the data. Step S7 specifically includes:
[0183] Step S701: The data encryption and decryption module calculates the quantum key ID using the SPIs of the initiator and responder in the IPSec SA. Since the SPI (Security Parameter Index) is used to uniquely identify the IPSec SA, the quantum key ID calculated using the SPI is also unique.
[0184] Step S702: The data encryption and decryption module obtains the quantum key sa from the quantum key pool through the quantum key ID;
[0185] Step S703: The data encryption and decryption module decrypts the data decrypted by IPSec sa using the quantum key sa;
[0186] Step S8: The data encryption and decryption module of the second encryption gateway decrypts the data message again using the IPSec sa stored in the data message through the decryption tag to obtain the original data message, which specifically includes the following;
[0187] For data length greater than one decryption block (16 bytes), take data that is an integer multiple of 16 bytes and perform CBC decryption to obtain plaintext data 1;
[0188] For data with a length less than 16 bytes, use the ciphertext of the previous block before decryption as the IV value. Decrypt the IV using the session key K, using the SM4 algorithm and ECB decryption mode to obtain Kiv. Truncate Kiv to make it equal to the ciphertext length, then XOR it with the ciphertext to obtain plaintext data 2.
[0189] Concatenate plaintext data 1 and plaintext data 2 to obtain the complete plaintext.
[0190] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0191] The various component embodiments of the present application can be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components in the computing processing equipment according to the embodiment of the present application. The application can also be implemented as a device or apparatus program (for example, a computer program and a computer program product) for performing a part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0192] For example, FIG6 illustrates a computing device that can implement the methods according to the present application. The computing device typically includes a processor 1010 and a computer program product or computer-readable medium in the form of a memory 1020. Memory 1020 can be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, a hard disk, or ROM. Memory 1020 has storage space 1030 for program code 1031 for executing any of the method steps described above. For example, storage space 1030 for program code can include individual program codes 1031 for implementing various steps in the method described above. These program codes can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards, or floppy disks. Such computer program products are typically portable or fixed storage units, as described with reference to FIG7 . This storage unit can have storage segments, storage space, and the like arranged similarly to memory 1020 in the computing device of FIG6 . The program code can, for example, be compressed in a suitable form. Typically, the storage unit includes computer-readable codes 1031 ′, ie, codes that can be read by a processor such as 1010 , which, when executed by a computing device, cause the computing device to perform the steps of the method described above.
[0193] References herein to "one embodiment," "an embodiment," or "one or more embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Furthermore, please note that instances of the phrase "in one embodiment" do not necessarily all refer to the same embodiment.
[0194] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.
[0195] In the claims, any reference signs placed between brackets shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0196] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A dual encryption method based on IPsec and quantum key, applied to encryption gateway, wherein: The method comprises the following steps: S10: The encryption gateway registers with the quantum key distribution center through the unique identifier. After successful registration, the quantum key distribution center injects quantum keys into the encryption gateway; S20: The encryption gateway receives the incoming data message and adds an encryption tag or a decryption tag to the data packet of the incoming data message; S30: Create a mounting node using the encryption label or the decryption label, and send out the data packet marked with the encryption label or the decryption label; S40: After the data is encrypted once using the security alliance, the data encrypted by the security alliance is encrypted again using the quantum key sa. The double-encrypted data becomes outbound message data and is sent out from the encryption gateway, or the data is double-decrypted to obtain the original ciphertext.
2. A dual encryption method based on IPsec and quantum key as claimed in claim 1, wherein: The S20 includes the following steps: S201: the data packet enters the stack; S202: Matching an outbound security policy according to the five-tuple information; S203: Determine whether the matching of the directional security policy is successful, if successful, proceed to S204, if failed, proceed to S207; S204: If the outbound security policy matches successfully, the incoming data message is encrypted and the corresponding security alliance is checked according to the outbound security policy. If it exists, the process proceeds to S205. If it fails, the process proceeds to S206. S205: The security association exists, and the information of the security association is saved in the data message; S206: If the security association does not exist, the security association is negotiated through the IKE protocol, and the information of the security association is saved in the data message; S207: If the outbound security policy fails to match, the source address and the destination address of the incoming data packet are swapped, and the inbound security policy is matched according to the five-tuple information; S208: Determine whether the inbound security policy is matched successfully. If successful, proceed to step S209; if not, proceed to step S210; S209: Add a decryption tag to the incoming data message; S210: The incoming data message cannot match the outbound security policy or the inbound security policy, and is discarded.
3. A dual encryption method based on IPsec and quantum key as claimed in claim 2, wherein: Step S40 specifically includes: S401: receiving data with an encryption tag or a decryption tag; S402: Determine whether it is an outbound label or an inbound label. If it is an outbound label, proceed to step S403 to step S405. If it is an inbound label, proceed to step S406. S403: Encrypt the data message using the security association through the encryption tag; S404: Obtain the quantum key sa, and use the quantum key sa to encrypt the data encrypted by the security association again; S405: The data processed by the data encryption and decryption module becomes outbound message data and is sent out from the encryption gateway; S406: Obtain the quantum key sa by decrypting the tag, and use the quantum key sa to decrypt the data; S407: Decrypt the data message using the security association to obtain the original data message.
4. A dual encryption method based on IPsec and quantum key as claimed in claim 3, wherein: In step S403, data encryption adopts the CBC+ mode, which specifically includes: For data whose length is greater than one encryption block, take data of an integer multiple of the encryption block for CBC encryption to obtain ciphertext data 1; If the remaining length is less than one encrypted data block, take the encrypted ciphertext of the previous block as the IV value, encrypt IV with the session key K, use SM4 as the encryption algorithm, use ECB as the encryption mode, obtain Kiv, intercept Kiv to make its length equal to the length of plaintext data, and then XOR it with the plaintext data to obtain ciphertext data 2; Concatenate ciphertext data 1 and ciphertext data 2 to obtain the complete ciphertext; The decryption process in step S407 specifically includes: For data whose length is greater than one decryption block, take data of an integer multiple of the encryption block for CBC decryption to obtain plaintext data 1; If the remaining length is less than that of an encrypted data packet, take the ciphertext of the previous packet before decryption as the IV value, use the session key K to decrypt the IV, use the decryption algorithm SM4, and the decryption mode ECB to obtain Kiv, truncate Kiv to make its length equal to the ciphertext data length, and then XOR it with the ciphertext data to obtain plaintext data 2; Concatenate plaintext data 1 and plaintext data 2 to obtain the complete plaintext.
5. A dual encryption method based on IPsec and quantum key as claimed in claim 3, wherein: Step S404 specifically includes: S4041. Calculate the quantum key ID using the SPI of the initiator and the responder in the security alliance. The quantum key ID calculated using the SPI is unique. S4042. Obtaining a quantum key sa from a quantum key pool through a quantum key ID; S4043, using the quantum key sa to encrypt the data encrypted by IPSec sa again, the encryption method is the same as the encryption method in S403; Step S406 specifically includes: S4061. Calculate the quantum key ID using the SPI of the initiator and the responder in the security alliance. The quantum key ID calculated using the SPI is unique. S4062. Obtaining a quantum key sa from a quantum key pool through a quantum key ID; S4063. Decrypt the data encrypted by IPSec sa using the quantum key sa. The decryption method is the same as that of S407.
6. An encryption gateway for executing a dual encryption method based on IPsec and quantum key according to any one of claims 1 to 5, wherein: include: The quantum key module is used for the encryption gateway to register with the quantum key distribution center through a unique identifier. After successful registration, the quantum key distribution center injects quantum keys into the quantum key module of the encryption gateway; The xfrm module is used to receive the incoming data message and call the encryption and decryption label of the iptables module to add an encryption label or a decryption label to the incoming data message; The iptables module creates encryption labels and decryption labels in advance, sets rules in the POSTROUTING chain of the mangel table, creates a mount node using encryption labels or decryption labels, and sends the data packets marked with encryption labels or decryption labels to the encryption and decryption module; The data encryption and decryption module uses the security alliance to encrypt the data once, and then uses the quantum key sa to encrypt the data encrypted by the security alliance again. The double-encrypted data becomes the outbound message data and is sent out from the encryption gateway, or the data is double-decrypted to obtain the original ciphertext.
7. An encryption gateway based on a dual encryption method of IPsec and quantum key as claimed in claim 6, wherein: The xfrm module specifically includes: xfrm module entry unit: used to push data packets into the xfrm module; Outbound security policy matching unit: used to match outbound security policies according to quintuple information; The first judgment unit is used to judge whether the matching of the outbound security policy is successful; Security association search unit: If the outbound security policy is matched successfully, it is used to add an encryption tag to the incoming data message and search for the corresponding security association according to the outbound security policy. Encryption tag unit: When a security association exists, the security association information is stored in the data message; Security Association Negotiation Unit: When a security association does not exist, it is used to negotiate a security association through the IKE protocol and save the security association information in the data message; Inbound security policy matching unit: when outbound security policy matching fails, it is used to swap the source address and destination address of the incoming data packet and match the inbound security policy according to the five-tuple information; The second judgment unit is used to judge whether the matching of the inbound security policy is successful; Decryption labeling unit: If the inbound security policy is successfully matched, the incoming data packet is labeled with a decryption label; Discard unit: If the incoming data packet cannot match the outbound security policy or the inbound security policy, it will be discarded.
8. An encryption gateway based on a dual encryption method of IPsec and quantum key as claimed in claim 6, wherein: The data encryption and decryption module specifically includes: Data receiving unit: receiving data with encryption or decryption tags; Direction label judgment unit: judges whether it is an outgoing direction label or an incoming direction label; Encryption unit, if it is an outgoing label, uses the security association to encrypt the datagram through the encryption label Encrypt the text; A re-encryption unit, used to obtain the quantum key sa, and use the quantum key sa to re-encrypt the data encrypted by the security association; The sending unit is used to convert the re-encrypted data into outbound message data and send it out from the encryption gateway; The decryption unit, if it is an incoming tag, obtains the quantum key sa through the decryption tag, and uses the quantum key sa to decrypt the data; The decryption unit decrypts the data message again using the security association to obtain the original data message.
9. An encryption gateway based on a dual encryption method of IPsec and quantum key as claimed in claim 8, wherein: The data encryption adopts the CBC+ mode, which specifically includes: For data whose length is greater than one encryption block, take data of an integer multiple of the encryption block for CBC encryption to obtain ciphertext data 1; If the remaining length is less than one encrypted data block, take the encrypted ciphertext of the previous block as the IV value, encrypt IV with the session key K, use SM4 as the encryption algorithm, use ECB as the encryption mode, obtain Kiv, intercept Kiv to make its length equal to the length of plaintext data, and then XOR it with the plaintext data to obtain ciphertext data 2; Concatenate ciphertext data 1 and ciphertext data 2 to obtain the complete ciphertext; The decryption process specifically includes: For data whose length is greater than one decryption block, take data of an integer multiple of the encryption block for CBC decryption to obtain plaintext data 1; If the remaining length is less than that of an encrypted data packet, take the ciphertext of the previous packet before decryption as the IV value, use the session key K to decrypt the IV, use the decryption algorithm SM4, and the decryption mode ECB to obtain Kiv, truncate Kiv to make its length equal to the ciphertext data length, and then XOR it with the ciphertext data to obtain plaintext data 2; Concatenate plaintext data 1 and plaintext data 2 to obtain the complete plaintext.
10. A dual encryption method based on IPsec and quantum key, applied to the transmission of message data from a first encryption gateway to a second encryption gateway, wherein: The first encryption gateway and the second encryption gateway adopt the dual encryption gateway described in any one of claims 6 to 9, and the encryption method comprises the following steps: S1: The first encryption gateway registers with the quantum key distribution center through the unique identifier and the unique identifier of the second encryption gateway. After successful registration, the quantum key distribution center injects the first quantum key into the quantum key module of the first encryption gateway. The second encryption gateway registers with the quantum key distribution center through the unique identifier and the unique identifier of the first encryption gateway. After successful registration, the quantum key distribution center injects the second quantum key into the quantum key module of the second encryption gateway. The identifiers registered by the first encryption gateway and the second encryption gateway quantum to the key distribution center are consistent, forming the same quantum key pool, that is, the first quantum key and the second quantum key are the same; S2: The first encryption gateway receives the incoming data message and sends the data packet of the incoming data message to Add encryption tags through the xfrm module; S3: The iptables module of the first encryption gateway sends the data packet with the encryption label in S2 to the encryption and decryption module through the hook node created by the encryption label; S4: The data encryption and decryption module of the first encryption gateway encrypts the data message by using the security alliance stored in the data message through the encryption tag, obtains the quantum key sa from the quantum key pool, and uses the quantum key sa to encrypt the data encrypted by the security alliance again and sends it out; S5: After receiving the ciphertext data from the first encryption gateway, the second encryption gateway swaps the source address and the destination address, matches the outbound security policy in the xfrm module through the five-tuple information, and obtains the security alliance corresponding to the security policy; at the same time, the stacked data message is marked with a decryption tag; S6: The iptables module of the second encryption gateway uses the hook node created by the decryption label to send the data packet marked with the decryption label in step S5 to the encryption and decryption module; S7: The second encryption gateway obtains the quantum key sa from the quantum key pool of the quantum encryption module, and uses the quantum key sa to decrypt the data; S8: The data encryption and decryption module of the second encryption gateway decrypts the data message again by using the security association stored in the data message through the decryption tag to obtain the original data message.
11. A computing device, wherein: include: a memory having computer readable code stored therein; One or more processors, when the computer-readable code is executed by the one or more processors, the computing processing device performs a dual encryption method based on IPsec and quantum key as described in any one of claims 1-5.
12. A computer program, comprising a computer readable code, which, when executed on a computing processing device, causes the computing processing device to execute a dual encryption method based on IPsec and quantum key according to any one of claims 1 to 5.
13. A computer readable medium having stored therein the computer program according to claim 12.
Citation Information
Patent Citations
Multi-protocol industrial communication safety gateway and communication method with gateway applied
CN104320332A
Data sending end, data receiving end, data transmission method and data transmission system
CN108075890A
Data transmission method and device, electronic equipment and machine readable storage medium
CN110190956A
Virtual private network implementation method and device, equipment and medium
CN111147344A
Method and system for realizing encryption and decryption of network session data stream by adopting quantum key distribution
CN115567205A
Cited By
Communication session key negotiation method, device, equipment and medium
CN120658389A