A quantum key-based network security encryption system and method
Patent Information
- Application Number
- CN202311312109.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-11
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2043-10-11
AI Technical Summary
但是现有的量子保密通信网络系统在传输数据抗干扰能力较弱,传输成本较高
[0080] This invention, through the integration of quantum-secure encryption machines, quantum key management machines, quantum key distribution and management equipment, and quantum key management service center software with existing communication networks, enables high-security, high-capacity, and interference-resistant data transmission. This invention is compatible with existing Ethernet networks and supports all network data transmission based on the IP protocol. It supports multiple encryption modes, including one-time pad cryptography for unconditionally secure quantum communication in an information theory sense, and quantum key + Chinese national cryptographic algorithms for high-speed, high-security network transmission due to the relatively low quantum key generation rate. Furthermore, the quantum key relay technology employed in this invention allows any node in the network to act as a relay, significantly reducing construction costs compared to point-to-point quantum key distribution.
Smart Images

Figure CN117375812B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of network security encryption technology, specifically relating to a network security encryption system and method based on quantum keys. Background Technology
[0002] Quantum secure communication is an interdisciplinary field that combines the fundamental principles of quantum mechanics with information communication theory, possessing the advantages of both disciplines. Quantum communication, based on the principles of the difficulty in measuring quantum states and the inability to be cloned, ensures greater security for communication.
[0003] In recent years, quantum encryption technology has gradually become more practical, and it has already shown good application value in government, finance, enterprise networks, and big data security protection in my country. With the industrialization of quantum secure communication technology, it will gradually become a key technology for ensuring the security of communication networks. This technology will inevitably move towards networking, practical application, and industrialization, providing the most powerful and reliable network security guarantee for the contemporary information and communication environment. However, existing quantum secure communication network systems have weak anti-interference capabilities and high transmission costs. Summary of the Invention
[0004] To address the technical problems of existing quantum secure communication network systems, such as weak anti-interference capability and high transmission cost, this invention provides a highly secure, low-cost, and highly anti-interference-capable quantum key-based network security encryption system and method.
[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0006] A quantum key-based network security encryption system includes a quantum secure encryption machine, a quantum key management machine, a quantum key distribution and management device, and quantum key management service center software. The quantum key distribution and management device provides quantum keys, the quantum key management machine manages the keys provided by the quantum key distribution and management device, the quantum secure encryption machine obtains keys from the quantum key management machine and uses the keys to perform encryption and decryption functions, and the quantum key management service center software manages the quantum key distribution and management device, the quantum secure encryption machine, and the quantum key management machine.
[0007] A quantum key-based network security encryption method includes the following steps:
[0008] S1. Encrypt IP data packets;
[0009] S2. IP packet forwarding of the quantum encryption machine, which is developed based on Linux;
[0010] S3. The quantum key is stored and used in the encryption machine;
[0011] S4. After sending the data packet from the kernel layer to the user layer using netfilter_queue, the data packet is encrypted and decrypted in the user layer.
[0012] S5. Obtain the key stream;
[0013] S6. An encryption expansion key based on SM4 is adopted, with the quantum key generated by QKD as the master key. A large number of keys are generated through the CTR mode of SM4, and the generated keys are used for encryption.
[0014] S7. When the key management machine obtains a key sequence, if it obtains it from the current node, the key sequence does not need to be encrypted during transmission; if it obtains it from other nodes, it must be transmitted in encrypted form.
[0015] The method for encrypting IP data packets in S1 is as follows:
[0016] S1.1 The IP header only changes the protocol type, setting it to a custom value, while leaving everything else unchanged;
[0017] S1.2 Add an encryption header after the IP header to store encryption-related information;
[0018] S1.3. Encrypt the IP packet and then recalculate the checksum;
[0019] S1.4 The encryption method adopts one-word-one-key or SM4 CTR mode.
[0020] The encrypted IP data packet format in S1 is: IP header, encryption header, encrypted IP data packet, and verification information; the encryption header format is: IP packet protocol, quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information, encryption mode and node address, and QKD group ID information.
[0021] The IP packet protocol: records the original IP packet protocol;
[0022] The quantum key synchronization information: records the synchronization information with the key, corresponds to the key stream generated in QKD, and points to each key stream with a length of 1MByte;
[0023] The quantum key verification information records the key verification information, which is obtained from the QKD key stream. When the encryption and decryption ends have the same synchronization information, the verification information should also be the same; if they are different, it proves that the key streams of the two parties are inconsistent and need to be discarded or processed.
[0024] The quantum key offset information: records the offset information of the key, pointing to the offset in each key stream;
[0025] The SM4 counter synchronization information: records the SM4 encryption counter value.
[0026] The encryption mode and node address are as follows:
[0027] bit0 is used to indicate the encryption mode, where 0 represents 1 word 1 key and 1 represents SM4.
[0028] Bit 1 is reserved and not used.
[0029] Bits 2-7, a total of 6 bits, represent the address, with 0 indicating the central node and 1-63 representing the addresses of other nodes; this node is the node where encryption takes place.
[0030] The QKD group ID information: records the ID of the QKD group; for example... Figure 1 The quantum key distribution and management device 1A and the quantum key distribution and management device 1B are a set of QKDs, and the key generated is quantum key sequence 1, which corresponds to the id of the QKD group here as 1.
[0031] The IP packet forwarding method of the quantum encryption machine in S2 is as follows:
[0032] Implemented based on netfilter; Netfilter manifests as a series of hook points in the Linux kernel and allows Linux kernel modules to register callback functions at these hook points. The Linux kernel modules then use these callback functions to perform related operations on network packets. Netfilter provides five hook points: Prerouting, Input, Forward, Output, and Postrouting.
[0033] Transparent transmission is achieved through network bridging (Bridge).
[0034] The encryption machine has at least four network ports, namely:
[0035] eth0: Key management port; connects to the quantum key manager; used to obtain key information, and managed by the quantum key manager through this port, such as obtaining status information;
[0036] eth1: Reserved management port; optional; after connection, it can be managed via SSH; requires one IP address.
[0037] eth2: Encrypted port; connects to an encrypted fiber optic link, no IP address assigned;
[0038] eth3-ethn: Service ports; connect to PCs, multiple PCs can be connected simultaneously, or multiple PCs can be connected through a switch, without IP address assignment; if multiple network ports need to be configured, they can all be configured as service ports; n is a natural number;
[0039] Specifically, eth0, eth2, and eth3-ethn are set as bridges to achieve bridging; each bridge is configured with a single IP address; decryption is performed at the entry point, and encryption is performed at the exit point.
[0040] In Netfilter, two hook points are taken over: Prerouting and Postrouting. In Prerouting, all packets from eth2 are decrypted; in Postrouting, all packets sent to eth2 are encrypted.
[0041] The method for storing and using the quantum key in the encryption machine in S3 is as follows:
[0042] In the encryption machine, the quantum key obtained from the key management machine is stored in a quantum key queue; each quantum key sequence in the network system corresponds to a quantum key queue in the encryption machine; each element in the quantum key queue includes five parts: validity flag, quantum key synchronization information, quantum key verification information, quantum key generation time, and quantum key block; wherein: the validity flag indicates whether the current element is valid; the quantum key synchronization information in the queue is a series of integers, that is, the quantum key synchronization information of a certain element plus 1 will definitely be the quantum key synchronization information of the next element; the quantum key block is a fixed-length memory block that stores the quantum key uniquely identified by the quantum key synchronization information; during encryption and decryption, the starting position of the required quantum key can be obtained through the quantum key synchronization information and the quantum key offset information; wherein, the quantum key offset information is the position of the quantum key required for encryption and decryption in the quantum key block;
[0043] The quantum key queue is a fixed-length circular queue; the queue has three pointers: PH, PT, and PE; PH points to the head of the circular queue, i.e., the first element; PT points to the tail of the circular queue, i.e., the position of the next element to be added; PE points to the position where the quantum key is obtained during encryption; three functional modules in the encryption machine modify the quantum key queue.
[0044] The encryption machine comprises three functional modules: a quantum key communication module, an encryption module, and a decryption module.
[0045] The quantum key communication module is used to obtain quantum keys from the key management machine and place them into the quantum queue. Each time the module obtains a quantum key, it forms an element in the quantum key queue. The module modifies the quantum key queue according to the following rules: if the quantum key queue is not full, elements are continuously added to the quantum key queue in sequence; if the queue is full, it waits until the first element is deleted, the validity flag is set to False, the queue becomes less full, and then elements are added again. The method for adding an element each time is: the element is placed at the position pointed to by PT, and then PT is incremented by 1. The condition for determining that the queue is full is: PT equals PH, and the element pointed to by PH is valid.
[0046] The encryption module obtains the quantum key from the element pointed to by PE; each quantum key is used only once; when the encryption module obtains the quantum key again, it starts from the end of the previous quantum key; if all the keys in the quantum key block of the element pointed to by PE are used up, PE is automatically incremented by 1, and then the quantum key in the element pointed to by PE is used again; if the position difference between PE and PH exceeds a certain number, the validity flag of the first element in the queue is automatically set to False, and PH is incremented by 1.
[0047] The input to the decryption module includes the position information of the quantum key, namely the quantum key synchronization information and the quantum key offset information. The decryption module uses this information to obtain the required quantum key from the quantum key queue. If the position of the quantum key synchronization information in the quantum key queue exceeds the PE, then the PE should be pointed to that position.
[0048] The method for implementing encryption at the user layer in S4 is as follows:
[0049] S4.1.1, IP packet received;
[0050] S4.1.2 Select a quantum key queue according to a certain rule; the rule can support the following two forms: random selection; or selecting the quantum key queue with a larger remaining key quantity based on the amount of remaining quantum keys.
[0051] S4.1.3. Based on the data length in the IP packet and the pre-set encryption strategy, obtain a key stream of the same length from the quantum key queue, and at the same time obtain the quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information and other information required for decryption.
[0052] S4.1.4. XOR the obtained key stream with the data in the IP packet bitwise to form a ciphertext data packet. Generate an encryption header based on the pre-set encryption policy, encryption machine address, QKD group ID, and the relevant parameters of quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, and quantum key offset information obtained in the previous step.
[0053] S4.1.5. Regenerate the IP packet using the encrypted data packet and encrypted header;
[0054] S4.1.6. Send the IP packet to the kernel layer, where the kernel layer will perform the packet forwarding.
[0055] The method for decryption implemented at the user layer in S4 is as follows:
[0056] S4.2.1, Data packet received;
[0057] S4.2.3. Parse the data packet and obtain the quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information, encryption strategy, encryption machine address, QKD group ID, etc. from the encryption header; and determine the quantum key queue where the key is located based on the QKD group ID.
[0058] S4.2.4 Obtain a key stream of the same length as the data packet from the selected quantum key queue;
[0059] S4.2.5. XOR the obtained key stream with the data in the IP packet bitwise to form a plaintext data packet;
[0060] S4.2.6. Regenerate the IP packet using plaintext data; the IP packet at this time is exactly the same as the IP packet before encryption.
[0061] S4.2.7. Send the IP packet to the kernel layer, where the kernel layer will perform the packet forwarding.
[0062] The method for obtaining the key stream in S5 is as follows:
[0063] S5.1 Key stream acquisition refers to obtaining the quantum key from the quantum key stack and converting the quantum key when needed to form the key stream required for encryption and decryption; the acquisition method differs in different encryption strategies;
[0064] S5.2 When the encryption strategy is one-word-one-key, the key stream can be obtained directly from the quantum key queue. The quantum key synchronization information and quantum key offset information in the encryption header record the position of the key stream in the quantum key queue.
[0065] S5.3 When the encryption strategy is in SM4 mode, only 24 bytes are taken from the quantum key queue, and these 24 bytes are used to generate the key stream required for encryption and decryption; the quantum key synchronization information and quantum key offset information in the encryption header record the position of the above 24 bytes in the quantum key queue; the SM4 counter synchronization information in the encryption header records the value of the counter required for SM4 encryption;
[0066] S5.4 When the encryption strategy is in smart mode, it will automatically select one-word-one-key mode or SM4 mode based on the amount of remaining quantum keys in the quantum key queue, and obtain the key stream using the above method.
[0067] The encryption method in S6 is as follows:
[0068] S6.1 Define a value MAXCNT, which is the number of times a set of quantum keys is used for encryption;
[0069] S6.2 It is agreed that each quantum key consists of 24 bytes, with the first 16 bytes serving as the SM4 master key and the last 8 bytes serving as the encryption vector IV;
[0070] S6.3 For the same set of quantum keys, set an 8-byte counter CNT; the initial value of CNT is 0, and the value is incremented by 1 after each encryption; when the counter value reaches MAXCNT, the quantum key needs to be changed.
[0071] S6.4 Each encryption will generate 16-byte ciphertext, which will form the key stream.
[0072] S6.5 For data packets longer than 16 bytes, multiple encryptions can be performed, but the SM4 counter synchronization information in the encryption header only stores the CNT value used for the first encryption of this data packet;
[0073] S6.6 Obtain the quantum key from the quantum key queue to get the master key, vector IV, and counter CNT;
[0074] S6.7 Assuming the data packet length is L, then Ne = (int)(L / 16+1) encryptions are required. Each encryption outputs a 16-byte ciphertext, and CNT is incremented by 1 after each encryption. The encryption method is as follows: combine the vector IV (8 bytes) and the counter CNT (8 bytes) into a 16-byte array as input, encrypt it using the SM4 encryption algorithm and the master key, and output a 16-byte ciphertext.
[0075] S6.8 Combine the ciphertexts obtained from Ne encryptions in sequence, and take the first L sections to obtain the key stream.
[0076] The method for encrypted transmission in S7 is as follows:
[0077] When node A's key management machine obtains key sequence 2 from node B's key management machine, it needs to encrypt it. Let key sequence 1 be K1, key sequence 2 be K2, and ^ be the XOR operation. The XOR result of K1 and K2 is K12. Then K12 = K1^K2, K2 = K1^K2^K1 = K12^K1. When node A obtains the key from node B's key management machine, node B's key management machine first XORs K1 and K2 to obtain K12, and then sends K12 to node A's key management machine. After obtaining K12, node A's key management machine XORs it with K1 to obtain K2.
[0078] During the XOR process, a situation may arise where the lengths of key sequence 1 and key sequence 2 are different. Let the lengths of key sequence 1 and key sequence 2 be L1 and L2 respectively, and L1 > L2. In this case, the encryption method used by the program is as follows: for the first L2 part of K1, XOR it directly with K2; for the part of K1 that exceeds L2, XOR it again starting from the beginning of K2; if L1 > n * L2 (n > 1), that is, L1 is greater than multiple times L2, this operation is repeated until all XOR operations are completed.
[0079] Compared with the prior art, the beneficial effects of this invention are:
[0080] This invention, through the integration of quantum-secure encryption machines, quantum key management machines, quantum key distribution and management equipment, and quantum key management service center software with existing communication networks, enables high-security, high-capacity, and interference-resistant data transmission. This invention is compatible with existing Ethernet networks and supports all network data transmission based on the IP protocol. It supports multiple encryption modes, including one-time pad cryptography for unconditionally secure quantum communication in an information theory sense, and quantum key + Chinese national cryptographic algorithms for high-speed, high-security network transmission due to the relatively low quantum key generation rate. Furthermore, the quantum key relay technology employed in this invention allows any node in the network to act as a relay, significantly reducing construction costs compared to point-to-point quantum key distribution. Attached Figure Description
[0081] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0082] The structures, proportions, sizes, etc. illustrated in this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed herein, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.
[0083] Figure 1 A schematic diagram of the quantum secure communication network architecture of this invention;
[0084] Figure 2 This is a schematic diagram illustrating the working principle of the NetFilter of this invention.
[0085] Figure 3 This is a schematic diagram of the XOR encryption of the key sequence of the present invention. Detailed Implementation
[0086] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. These descriptions are only for further illustrating the features and advantages of the present invention, and not for limiting the claims of the present invention. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0087] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0088] In this embodiment, as Figure 1 As shown, the quantum key distribution and management device is used to provide quantum keys, the quantum key management machine is used to manage the keys provided by the quantum key distribution and management device, the quantum security encryption machine obtains the keys from the quantum key management machine and uses the keys to complete the encryption and decryption functions, and the quantum key management service center software manages the quantum key distribution and management device, the quantum security encryption machine, and the quantum key management machine.
[0089] I. Data Packet Encryption Technology Solution
[0090] 1) Only change the protocol type in the IP header, set it to a custom value, such as 141, and leave everything else unchanged;
[0091] 2) Add an encryption header after the IP header to store encryption-related information;
[0092] 3) Encrypt the IP packet and then recalculate the checksum;
[0093] 4) The encryption method adopts one-word key or SM4 CTR mode.
[0094] The encrypted IP packet format is:
[0095] IP header, encryption header, encrypted IP data packet, and verification information.
[0096] The encryption header has the following format:
[0097] IP packet protocol (1 Byte), quantum key synchronization information (4 Bytes), quantum key verification information (4 Bytes), SM4 counter synchronization information (4 Bytes), quantum key offset information (4 Bytes), encryption mode and node address (1 Byte), QKD group ID information (1 Byte).
[0098] IP packet protocol (1 byte): Records the original IP packet protocol
[0099] Quantum key synchronization information (4 Bytes): Records the synchronization information with the key, corresponding to the key stream generated in QKD, pointing to each key stream with a length of 1 MBytes.
[0100] Quantum Key Verification Information (4 Bytes): Records key verification information, which is obtained from the QKD keystream. When the encryption and decryption ends have the same synchronization information, the verification information should also be identical. If they differ, it proves that the keystreams of both parties are inconsistent, and the key should be discarded or otherwise processed.
[0101] Quantum key offset information (4 bytes): Records the offset information of the key, pointing to the offset in each key stream.
[0102] SM4 Counter Synchronization Information (4 Bytes): Records the SM4 encrypted counter value.
[0103] Encryption mode and node address (1 Byte):
[0104] bit0 is used to indicate the encryption mode, where 0 represents 1 word 1 key and 1 represents SM4.
[0105] Bit 1 is reserved and not used.
[0106] Bits 2-7, a total of 6 bits, represent the address. 0 indicates the central node (node B), and 1-63 represent the addresses of other nodes. This node is the one where encryption takes place.
[0107] QKD group ID information (1 Byte): Records the ID of the QKD group. For example... Figure 1The quantum key distribution and management device 1A and the quantum key distribution and management device 1B are a set of QKDs, and the key generated is quantum key sequence 1, which corresponds to the id of the QKD group here as 1.
[0108] II. IP Packet Forwarding Technology Route of Quantum Encryption Machine
[0109] The quantum encryption machine is developed based on Linux.
[0110] Implemented based on netfilter. Netfilter manifests as a series of hook points in the Linux kernel, allowing Linux kernel modules to register callback functions at these hook points. The Linux kernel modules then use these callback functions to perform operations on network packets. Netfilter provides five hook points: Prerouting, Input, Forward, Output, and Postrouting. Figure 2 As shown.
[0111] Transparent transmission can be achieved through network bridging.
[0112] The encryption machine has more than 4 network ports. Taking 6 network ports as an example, they are:
[0113] eth0: Key management port. Connects to the quantum key manager. Used to obtain key information, and managed by the quantum key manager through this port, such as obtaining status information.
[0114] eth1: Reserved for management. Optional. After connection, it can be managed via SSH. Requires one IP address.
[0115] eth2: Encrypted port. Connects to an encrypted fiber optic link; no IP address is assigned.
[0116] eth3-eth5: Service ports. Connect to PCs; multiple PCs can be connected simultaneously, or multiple PCs can be connected via a switch. No IP address is assigned. If multiple network ports need to be configured, they can all be configured as service ports.
[0117] Specifically, eth0, eth2, and eth3-eth5 (and possibly more service ports) are configured as bridges to achieve bridging. Each bridge is assigned a single IP address. Decryption is performed at the ingress port, and encryption is performed at the egress port.
[0118] In Netfilter, two hook points are taken over: Prerouting and Postrouting. In Prerouting, all packets from eth2 are decrypted; in Postrouting, all packets sent to eth2 are encrypted.
[0119] III. How Quantum Keys are Stored and Used in Encryption Machines
[0120] In the encryption machine, the quantum key obtained from the key management machine is stored in a quantum key queue. Each quantum key sequence in the network system corresponds to a quantum key queue in the encryption machine. For example... Figure 1 In the structure, there are two quantum key sequences. Therefore, the encryption machines of nodes A, B, and C each have two quantum key queues. Each element in the queue includes at least five parts: a validity flag, quantum key synchronization information, quantum key verification information, quantum key generation time, and a quantum key block. Specifically: 1) The validity flag indicates whether the current element is valid; 2) The quantum key synchronization information in the queue is a series of consecutive integers, meaning that the quantum key synchronization information of one element plus 1 will be the quantum key synchronization information of the next element; 3) The quantum key block is a fixed-length (e.g., 1048576 bytes) memory block that stores the quantum key uniquely identified by the quantum key synchronization information. During encryption and decryption, the starting position of the required quantum key can be obtained through the quantum key synchronization information and the quantum key offset information. The quantum key offset information indicates the position of the required quantum key within the quantum key block.
[0121] The quantum key queue is a fixed-length circular queue. This queue has three pointers: PH, PT, and PE. PH points to the head of the circular queue, i.e., the first element; PT points to the tail of the circular queue, i.e., the position of the next element to be added; and PE points to the position where the quantum key is obtained during encryption. Three functional modules in the encryption machine modify the quantum key queue.
[0122] 1. Quantum Key Communication Module. The quantum key communication module retrieves quantum keys from the key management machine and places them into the quantum key queue. Each time, the quantum key retrieved by this module constitutes an element in the quantum key queue. The module modifies the quantum key queue according to the following rules: if the quantum key queue is not full, elements are continuously added to the quantum key queue in sequence; if the queue is full, it waits until the first element is deleted (the "validity flag" is set to False), the queue becomes less full again, and then elements are added. Each time an element is added, it is placed at the position pointed to by PT, and then PT is incremented by 1. The condition for determining that the queue is full is: PT equals PH, and the element pointed to by PH is valid.
[0123] 2. Encryption Module. The encryption module retrieves the quantum key from the element pointed to by PE. Each quantum key is used only once. When retrieving a quantum key next time, the encryption module starts retrieving from the end of the previous quantum key. If all the keys in the quantum key block pointed to by PE are used up, PE is automatically incremented by 1, and the quantum key in the element pointed to by PE continues to be used. If the position difference between PE and PH exceeds a certain number (this value can be set in the configuration file), the "validity flag" of the first element in the queue is automatically set to False, and PH is incremented by 1.
[0124] 3. Decryption Module. The input to the decryption module includes the quantum key's position information, namely, quantum key synchronization information and quantum key offset information. Using this information, the decryption module retrieves the required quantum key from the quantum key queue. If the position corresponding to the quantum key synchronization information in the quantum key queue exceeds the PE (Pressure Pointer) position, then the PE should be adjusted to that position.
[0125] IV. Data Packet Encryption Scheme
[0126] The encryption / decryption software is implemented on Linux. It uses netfilter_queue to send data packets from the kernel layer to the user layer, where the packets are then encrypted or decrypted.
[0127] 1. The encryption process implemented at the user level is as follows:
[0128] 1) Received IP packet.
[0129] 2) Select a quantum key queue according to a certain rule. The rule can support the following two forms: a) random selection; b) select the quantum key queue with the larger remaining key quantity based on the amount of remaining quantum keys.
[0130] 3) Based on the data length in the IP packet and the pre-set encryption strategy, obtain a key stream of the same length from the quantum key queue, and at the same time obtain the quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information and other information required for decryption.
[0131] 4) XOR the obtained key stream with the data in the IP packet bitwise to form a ciphertext data packet, and generate an encryption header based on the pre-set encryption policy, encryption machine address, QKD group ID, and related parameters such as quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, and quantum key offset information obtained in the previous step.
[0132] 5) Regenerate the IP packet using the encrypted data packet and encrypted header.
[0133] 6) Send the IP packet to the kernel layer, where the kernel layer will handle the packet forwarding.
[0134] 2. The decryption process implemented at the user level is as follows:
[0135] 1) Data packet received.
[0136] 3) Parse the data packet to obtain quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information, encryption strategy, encryption machine address, QKD group ID, etc. from the encryption header. Then, determine the quantum key queue where the key resides based on the QKD group ID.
[0137] 3) Obtain a key stream of the same length as the data packet from the selected quantum key queue.
[0138] 4) XOR the obtained key stream with the data in the IP packet bitwise to form a plaintext data packet.
[0139] 5) Regenerate the IP packet using plaintext data. The resulting IP packet is identical to the original IP packet.
[0140] 6) Send the IP packet to the kernel layer, where the kernel layer will handle the packet forwarding.
[0141] V. Methods for Obtaining the Keystream
[0142] Key stream acquisition refers to obtaining the quantum key from the quantum key pool and converting the quantum key as needed to form the key stream required for encryption and decryption. The acquisition method differs in different encryption strategies.
[0143] When the encryption strategy is one key per word, the key stream can be obtained directly from the quantum key queue. The quantum key synchronization information and quantum key offset information in the encryption header record the position of the key stream in the quantum key queue.
[0144] When the encryption strategy is in SM4 mode, only 24 bytes are taken from the quantum key queue, and these 24 bytes are used to generate the key stream required for encryption and decryption. The quantum key synchronization information and quantum key offset information in the encryption header record the position of the above 24 bytes in the quantum key queue; the SM4 counter synchronization information in the encryption header records the value of the counter required for SM4 encryption.
[0145] When the encryption strategy is in smart mode, it will automatically select either the 1-word-1-key mode or the SM4 mode based on the amount of remaining quantum keys in the quantum key queue, and obtain the key stream using the above method.
[0146] VI. SM4 Encryption Scheme
[0147] This system supports QKD devices with quantum key generation rates up to 100Kbps, but the network transmission rate needs to accommodate bandwidths exceeding 100Mbps, a significant difference. To ensure both high bandwidth compatibility and high security during network transmission while maintaining a relatively low quantum key generation rate, this system employs an SM4-based encryption augmented key approach. The principle is to use the quantum key generated by QKD as the master key, and then generate a large number of keys using SM4's CTR mode (counter mode), using these generated keys for encryption. The method is as follows.
[0148] 1. Agreement:
[0149] 1) Define a value MAXCNT, which is the number of times a set of quantum keys is used for encryption.
[0150] 2) It is agreed that each quantum key consists of 24 bytes, with the first 16 bytes serving as the SM4 master key and the last 8 bytes serving as the encryption vector IV.
[0151] 3) For the same set of quantum keys, set an 8-byte counter CNT. The initial value of CNT is 0, and the value is incremented by 1 after each encryption. When the counter value reaches MAXCNT, the quantum key needs to be changed.
[0152] 4) Each encryption will generate 16-byte ciphertext, which together form the key stream.
[0153] 5) For data packets longer than 16 bytes, multiple encryptions can be performed, but the SM4 counter synchronization information in the encryption header only stores the CNT value used for the first encryption of this data packet.
[0154] 2. Steps for generating the keystream:
[0155] 1) Obtain the quantum key from the quantum key queue to get the master key, vector IV and counter CNT.
[0156] 2) Assuming the data packet length is L, then Ne = (int)(L / 16+1) encryptions are required. Each encryption outputs a 16-byte ciphertext, and CNT is incremented by 1 after each encryption. The encryption method is as follows: combine the vector IV (8 bytes) and the counter CNT (8 bytes) into a 16-byte array, use it as input, encrypt it using the SM4 encryption algorithm and the master key, and output a 16-byte ciphertext.
[0157] 3) Combine the ciphertexts obtained from Ne encryptions in sequence, and take the first L sections to obtain the key stream.
[0158] VII. Key Relay Encrypted Transmission Scheme
[0159] When the key management machine obtains a key sequence, if it obtains it from the current node, the key sequence does not need to be encrypted during transmission; if it obtains it from another node, it must be encrypted. The encryption method is as follows.
[0160] by Figure 1 Taking node A as an example. When node A's key management machine obtains key sequence 2 from node B's key management machine, it needs to encrypt it. Let key sequence 1 be K1, key sequence 2 be K2, and ^ be the XOR operation. The XOR result of K1 and K2 is K12. Then K12 = K1^K2, K2 = K1^K2^K1 = K12^K1. According to this method, when node A obtains the key from node B's key management machine, node B's key management machine first XORs K1 and K2 to obtain K12, and then sends K12 to node A's key management machine. After obtaining K12, node A's key management machine XORs it with K1 to obtain K2.
[0161] During the XOR process, situations may arise where key sequence 1 (K1) and key sequence 2 (K2) have different lengths. For example... Figure 3 As shown, let the lengths of key sequence 1 and key sequence 2 be L1 and L2 respectively, where L1 > L2. The encryption method used by the program is as follows: for the first L2 parts of K1, XOR directly with K2; for the parts of K1 that exceed L2, XOR again starting from the beginning of K2. If L1 > n * L2 (n > 1), that is, L1 is greater than a multiple of L2, this operation is repeated until all XOR operations are completed.
[0162] The above description only illustrates the preferred embodiments of the present invention. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention, and all such changes should be included within the protection scope of the present invention.
Claims
1. A network security encryption method based on quantum key distribution, characterized in that: Includes the following steps: S1. Encrypt IP data packets; S2. IP packet forwarding of the quantum encryption machine, which is developed based on Linux; S3. The quantum key is stored and used in the encryption machine; In the encryption machine, the quantum key obtained from the key management machine is stored in the quantum key queue; each quantum key sequence in the network system corresponds to a quantum key queue in the encryption machine. The quantum key queue is a fixed-length circular queue; it has three pointers: PH, PT, and PE; PH points to the head of the circular queue, i.e., the first element; PT points to the tail of the circular queue, i.e., the position of the next element to be added; PE points to the position where the quantum key is obtained during encryption. The quantum key communication module is used to obtain quantum keys from the key management machine and place them into the quantum queue. Each time the module obtains a quantum key, it forms an element in the quantum key queue. The module modifies the quantum key queue according to the following rules: if the quantum key queue is not full, elements are continuously added to the quantum key queue in sequence; if the queue is full, it waits until the first element is deleted, the validity flag is set to False, the queue becomes less full, and then elements are added again. The method for adding an element each time is: the element is placed at the position pointed to by PT, and then PT is incremented by 1. The condition for determining that the queue is full is: PT equals PH, and the element pointed to by PH is valid. The encryption module retrieves the quantum key from the element pointed to by PE; each quantum key is used only once; when the encryption module retrieves a quantum key next time, it starts from the end of the previous quantum key; if all the keys in the quantum key block of the element pointed to by PE are used up, PE is automatically incremented by 1, and then the quantum key in the element pointed to by PE is used again; if the difference between the positions of PE and PH exceeds a threshold, the validity flag of the first element in the queue is automatically set to False, and PH is incremented by 1. The input to the decryption module includes the position information of the quantum key, namely the quantum key synchronization information and the quantum key offset information. The decryption module obtains the required quantum key from the quantum key queue using the quantum key synchronization information and the quantum key offset information. If the position of the quantum key synchronization information in the quantum key queue exceeds the PE, then the PE should be pointed to the position of the quantum key synchronization information in the quantum key queue. S4. After sending the data packet from the kernel layer to the user layer using netfilter_queue, the data packet is encrypted and decrypted in the user layer. S5. Obtain the key stream; S6. An encryption expansion key based on SM4 is adopted, with the quantum key generated by QKD as the master key. A large number of keys are generated through the CTR mode of SM4, and the generated keys are used for encryption. S7. When the key management machine obtains a key sequence, if it obtains it from the current node, the key sequence does not need to be encrypted during transmission; if it obtains it from other nodes, it must be transmitted in encrypted form.
2. The quantum key-based network security encryption method according to claim 1, characterized in that: The method for encrypting IP data packets in S1 is as follows: S1.1 The IP header only changes the protocol type, setting it to a custom value, while leaving everything else unchanged; S1.2 Add an encryption header after the IP header to store encryption-related information; S1.
3. Encrypt the IP packet and then recalculate the checksum; S1.4 The encryption method adopts one-word-one-key or SM4 CTR mode.
3. The quantum key-based network security encryption method according to claim 1, characterized in that: The encrypted IP data packet format in S1 is: IP header, encryption header, encrypted IP data packet, and verification information; the encryption header format is: IP packet protocol, quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information, encryption mode and node address, and QKD group ID information. The IP packet protocol: records the original IP packet protocol; The quantum key synchronization information: records the synchronization information with the key, corresponds to the key stream generated in QKD, and points to each key stream with a length of 1MByte; The quantum key verification information records the key verification information, which is obtained from the QKD key stream. When the encryption and decryption ends have the same synchronization information, the verification information should also be the same; if they are different, it proves that the key streams of the two parties are inconsistent and should be discarded. The quantum key offset information: records the offset information of the key, pointing to the offset in each key stream; The SM4 counter synchronization information: records the SM4 encryption counter value. The encryption mode and node address are as follows: bit0 is used to indicate the encryption mode, where 0 represents 1 word 1 key and 1 represents SM4. bit1 is reserved and not used; Bits 2-7, a total of 6 bits, represent the address, with 0 indicating the central node and 1-63 representing the addresses of other nodes; this node is the node where encryption takes place. The QKD group ID information records the id of the QKD group; Quantum key distribution and management device 1A and quantum key distribution and management device 1B are a QKD group, and the generated key is quantum key sequence 1, corresponding to the id of the QKD group here being 1.
4. The network security encryption method based on quantum key distribution according to claim 1, characterized in that: The IP packet forwarding method of the quantum encryption machine in S2 is as follows: Implemented based on netfilter; Netfilter manifests as a series of hook points in the Linux kernel, allowing Linux kernel modules to register callback functions at these hook points. The Linux kernel modules then process network packets through these callback functions; Netfilter provides five hook points: Prerouting, Input, Forward, Output, and Postrouting. Transparent transmission is achieved through network bridging (Bridge). The encryption machine has at least four network ports, namely: eth0: Key management port; connects to the quantum key manager; Used to obtain key information, and managed by the quantum key management machine through the key management port to obtain status information; eth1: Reserved management port; after connection, management is via SSH; requires one IP address. eth2: Encrypted port; Connect to an encrypted fiber optic link; no IP address is assigned. eth3-ethn: Service ports; connect to PCs, connect multiple PCs simultaneously, or connect multiple PCs through a switch, without assigning IP addresses; if multiple network ports need to be configured, configure them as service ports; n is a natural number; Specifically, eth0, eth2, and eth3-ethn are set as bridges to achieve bridging; each bridge is configured with a single IP address; decryption is performed at the entry point, and encryption is performed at the exit point. In Netfilter, two hook points are taken over: Prerouting and Postrouting. In Prerouting, all packets from eth2 are decrypted; in Postrouting, all packets sent to eth2 are encrypted.
5. A network security encryption method based on quantum key distribution according to claim 1, characterized in that: The method for storing and using the quantum key in the encryption machine in S3 is as follows: Each element in the quantum key queue comprises five parts: a validity flag, quantum key synchronization information, quantum key verification information, quantum key generation time, and a quantum key block. The validity flag indicates whether the current element is valid. The quantum key synchronization information in the queue consists of consecutive integers; that is, the quantum key synchronization information of one element plus 1 gives the quantum key synchronization information of the next element. The quantum key block is a fixed-length memory block that stores the quantum key uniquely identified by the quantum key synchronization information. During encryption and decryption, the starting position of the required quantum key can be obtained through the quantum key synchronization information and the quantum key offset information. The quantum key offset information indicates the position of the required quantum key within the quantum key block. Three functional modules in the encryption machine modify the quantum key queue; The encryption machine has three functional modules: a quantum key communication module, an encryption module, and a decryption module.
6. The quantum key-based network security encryption method according to claim 1, characterized in that: The method for implementing encryption at the user layer in S4 is as follows: S4.1.1, IP packet received; S4.1.2 Select a quantum key queue according to two rules; the two rules include: random selection; and selecting a quantum key queue with a remaining key quantity greater than a set threshold based on the amount of remaining quantum keys. S4.1.
3. Based on the data length in the IP packet and the pre-set encryption strategy, obtain a key stream of the same length from the quantum key queue, and at the same time obtain the quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, and quantum key offset information required for decryption. S4.1.
4. XOR the obtained key stream with the data in the IP packet bitwise to form a ciphertext data packet. Generate an encryption header based on the pre-set encryption policy, encryption machine address, QKD group ID, and the relevant parameters of quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, and quantum key offset information obtained in the previous step. S4.1.
5. Regenerate the IP packet using the encrypted data packet and encrypted header; S4.1.
6. Send the IP packet to the kernel layer, where the kernel layer will perform the packet forwarding. The method for decryption implemented at the user layer in S4 is as follows: S4.2.1, Data packet received; S4.2.
3. Parse the data packet and obtain the quantum key synchronization information, quantum key verification information, SM4 counter synchronization information, quantum key offset information, encryption strategy, encryption machine address, and QKD group ID information from the encryption header; and determine the quantum key queue where the key is located based on the QKD group ID. S4.2.4 Obtain a key stream of the same length as the data packet from the selected quantum key queue; S4.2.
5. XOR the obtained key stream with the data in the IP packet bitwise to form a plaintext data packet; S4.2.
6. Regenerate the IP packet using plaintext data; the IP packet at this time is exactly the same as the IP packet before encryption. S4.2.
7. Send the IP packet to the kernel layer, where the kernel layer will perform the packet forwarding.
7. A quantum key-based network security encryption method according to claim 1, characterized in that: The method for obtaining the key stream in S5 is as follows: S5.1 Key stream acquisition refers to obtaining the quantum key from the quantum key stack and converting the quantum key when needed to form the key stream required for encryption and decryption; the acquisition method differs in different encryption strategies; S5.2 When the encryption strategy is one-word-one-key, the key stream is obtained directly from the quantum key queue. The quantum key synchronization information and quantum key offset information in the encryption header record the position of the key stream in the quantum key queue. S5.3 When the encryption strategy is in SM4 mode, only 24 bytes are taken from the quantum key queue, and these 24 bytes are used to generate the key stream required for encryption and decryption; the quantum key synchronization information and quantum key offset information in the encryption header record the position of the above 24 bytes in the quantum key queue; the SM4 counter synchronization information in the encryption header records the value of the counter required for SM4 encryption; S5.4 When the encryption strategy is in smart mode, it will automatically select either the one-word-one-key mode or the SM4 mode based on the amount of remaining quantum keys in the quantum key queue, and use the selected mode to obtain the key stream.
8. A network security encryption method based on quantum key distribution according to claim 1, characterized in that: The encryption method in S6 is as follows: S6.1 Define a value MAXCNT, where MAXCNT represents the number of times a quantum key is used for encryption; S6.2 It is agreed that each quantum key consists of 24 bytes, with the first 16 bytes serving as the SM4 master key and the last 8 bytes serving as the encryption vector IV; S6.3 For the same set of quantum keys, set a counter CNT with a length of 8 bytes; the initial value of CNT is 0, and the value of CNT is incremented by 1 after each encryption; when the counter value reaches MAXCNT, the quantum key needs to be changed. S6.4 Each encryption will generate 16-byte ciphertext, which will form the key stream. S6.
5. For data packets longer than 16 bytes, perform multiple encryptions, but the SM4 counter synchronization information in the encryption header only stores the CNT value used for the first encryption of this data packet; S6.6 Obtain the quantum key from the quantum key queue to get the master key, vector IV, and counter CNT; S6.7 Assuming the data packet length is L, then Ne = (int)(L / 16+1) encryptions are required. Each encryption outputs a 16-byte ciphertext, and CNT is incremented by 1 after each encryption. The encryption method is as follows: combine the 8-byte vector IV and the 8-byte counter CNT into a 16-byte array, use it as input, encrypt it using the SM4 encryption algorithm and the master key, and output a 16-byte ciphertext. S6.8 Combine the ciphertexts obtained from Ne encryptions in sequence, and take the first L sections to obtain the key stream.
9. A quantum key-based network security encryption method according to claim 1, characterized in that: The method for encrypted transmission in S7 is as follows: When the key management machine of node A obtains key sequence 2 from the key management machine of node B, it needs to encrypt it; let key sequence 1 be K1 and key sequence 2 be K2. The result of the XOR operation is K12, where K1 and K2 are XORed. , When node A obtains a key from node B's key management machine, node B's key management machine first XORs K1 and K2 to get K12, and then sends K12 to node A's key management machine; after obtaining K12, node A's key management machine XORs it with K1 to get K2. During the XOR process, a situation may arise where the lengths of key sequence 1 and key sequence 2 are different. Let the lengths of key sequence 1 and key sequence 2 be L1 and L2 respectively, and L1 > L2. The encryption method used in this case is as follows: for the first L2 part of K1, XOR it directly with K2; for the part of K1 that exceeds L2, XOR it again starting from the beginning of K2; if L1 > n * L2, n > 1, that is, L1 is greater than multiple times L2, then this operation is repeated until all XOR operations are completed.
10. A quantum key-based network security encryption system, the system being used to execute a quantum key-based network security encryption method according to any one of claims 1-9, characterized in that: The system includes a quantum-secure encryption machine, a quantum key management machine, a quantum key distribution and management device, and quantum key management service center software. The quantum key distribution and management device provides quantum keys, the quantum key management machine manages the keys provided by the quantum key distribution and management device, the quantum-secure encryption machine obtains keys from the quantum key management machine and uses the keys to perform encryption and decryption functions, and the quantum key management service center software manages the quantum key distribution and management device, the quantum-secure encryption machine, and the quantum key management machine.
Citation Information
Patent Citations
Transparent encryption device and method free of IP configuration
CN116389132A
QoS cloud host communication queue assurance system for quantum computing equipment
CN116781642A