Encryption and decryption method based on user mode IPSec protocol

By implementing the IPSec protocol in user mode, integrating encryption and decryption equipment into the network card, and combining DPDK and VPP technologies, the performance bottleneck and flexibility issues of traditional kernel mode IPSec are solved, and efficient and flexible data security transmission is achieved, adapting to cloud computing and containers. deployment requirements.

CN118611993APending Publication Date: 2024-09-06ZHONG AN YUNKE TECH DEV (SHANDONG) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411082215.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

The traditional kernel-mode IPSec implementation has performance bottlenecks, limited flexibility, poor scalability, and difficult maintenance, and cannot meet the efficiency and flexibility requirements for data processing in cloud computing and edge computing scenarios.

Method used

Adopting the user-mode IPSec protocol, integrating encryption and decryption equipment into the network card, using high-performance encryption and decryption algorithms to directly encrypt and decrypt data packets, and combining DPDK and VPP technologies to implement user-mode protocol stacks, reducing context switching and System calls make full use of hardware acceleration resources.

Benefits of technology

Significantly improves IPSec forwarding performance, reduces context switching, provides higher flexibility and scalability, allows dynamic adjustment of security policies, facilitates maintenance and troubleshooting, adapts to cloud environments and containerized deployments, and provides more efficient, flexible and reliable data Secure transmission solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118611993A
    Figure CN118611993A
Patent Text Reader

Abstract

The invention discloses an encryption and decryption method based on a user mode IPSec protocol, which relates to the technical field of data communication, and specifically comprises the following steps: integrating encryption and decryption equipment into network card equipment to form an encryption network card, and directly carrying out encryption and decryption operation on a data packet by utilizing a high-performance encryption and decryption algorithm of the encryption and decryption equipment. And after the operation is completed, directly forwarding the data to the IPSec server from the encryption network card, and forwarding the data to the target machine by the IPSec server. According to the encryption and decryption method based on the user mode IPSec protocol, the encryption and decryption operation is adjusted from an ESP protocol processing stage to a data packet receiving and transmitting stage, and the encryption and decryption equipment processes the whole network packet in a data offset manner, so that the concurrency is increased, the IPSec forwarding performance is greatly improved, the processing of an encryption card on a protocol stack is shielded, and the security of the encryption card is improved. In addition, the method can better adapt to the requirements of cloud environment and containerization deployment, and a more efficient, flexible and reliable solution is provided for secure data transmission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data communication, and in particular to an encryption and decryption method based on a user-mode IPSec protocol. Background Art

[0002] With the rapid development of the Internet, data security has become an important issue in network communications. As a mature security protocol, IPSec (Internet Protocol Security) is widely used to ensure the secure transmission of IP layer data. It ensures the confidentiality, integrity and authenticity of data in the network by providing multiple security services such as data encryption, data source verification, and integrity protection. Traditional IPSec implementation usually relies on the support of the operating system kernel, that is, encryption, decryption, and authentication are completed in the kernel state. However, with the rise of cloud computing, data centers, and edge computing, higher requirements are placed on the efficiency, flexibility, and scalability of data processing, and traditional kernel-state IPSec has begun to expose some limitations.

[0003] Defects and shortcomings of existing technology: 1. Performance bottleneck: IPSec processing in kernel mode will cause context switching overhead. Whenever a data packet needs to be encrypted or decrypted, it needs to switch from user mode to kernel mode. This process involves complex system calls, consumes a lot of CPU resources and time, and thus limits the processing speed and throughput of network data.

[0004] 2. Limited flexibility: Kernel-state implementations are difficult to adapt to rapidly changing security requirements and algorithm updates. Security policy adjustments and algorithm upgrades often require restarting the system or kernel module, affecting service continuity and stability.

[0005] 3. Poor scalability: Hardware acceleration resources (such as encryption acceleration cards) are not fully utilized. Kernel-mode IPSec implementations often cannot efficiently utilize the acceleration functions provided by modern hardware, limiting performance scalability in high-load scenarios.

[0006] 4. Difficulty in maintenance and debugging: Code modification and debugging in kernel space are relatively difficult. Any error may cause instability or even crash of the entire system, which increases the complexity of development and maintenance.

[0007] Based on the above defects, it is particularly urgent to develop a user-mode-based IPSec protocol performance improvement solution. User-mode implementation can effectively reduce context switching and improve processing efficiency, while providing higher flexibility and scalability, allowing dynamic adjustment of security policies, better utilization of hardware acceleration resources, and facilitating maintenance and troubleshooting. In addition, the user-mode solution can better adapt to the needs of cloud environments and containerized deployments, providing a more efficient, flexible and reliable solution for secure data transmission. Summary of the invention

[0008] The present invention provides an encryption and decryption method based on the user-mode IPSec protocol, which solves the problems mentioned in the above background technology that the traditional IPSec implementation usually relies on the support of the operating system kernel, has performance bottlenecks, limited flexibility, poor scalability, and is difficult to maintain and debug.

[0009] The present invention provides the following technical solutions: an encryption and decryption method based on the user-mode IPSec protocol, integrating an encryption and decryption device into a network card device to form an encryption network card, using the high-performance encryption and decryption algorithm of the encryption and decryption device to directly perform encryption and decryption operations on data packets, and after the operation is completed, directly forwarding from the encryption network card to the IPSec server, and forwarding from the IPSec server to the target machine, thereby increasing the concurrency of encryption and decryption processing and greatly improving the IPSec forwarding performance; Wherein: the encryption network card includes a transceiver module and a password module, and the transceiver module and the password module interact with each other; the operating system of the IPSec server includes DPDK and VPP; The encryption and decryption method based on the user-mode IPSec protocol includes: A. Business machine 1 sends a plaintext data packet to IPSec server A; B. After receiving the plaintext data, IPSec server A performs ESP protocol plaintext encapsulation on the plaintext data according to IPSec protocol rules. This process does not perform any encryption or decryption operations. At this time, the system obtains the plaintext ESP protocol packet D1. C. IPSec server A adds an IP header and a Mac header to the plaintext ESP protocol packet D1 to form a protocol frame D2, and adds a set of encryption command headers to the protocol frame D2 to obtain a data packet D3; D. IPSec server A forwards data packet D3 to the encryption device port. At this time, the data packet enters the encryption and decryption device to perform encryption operations and returns the encrypted data packet D4. E. IPSec server A sends data packet D4 to peer IPSec server B. F. After receiving the data packet D4, IPSec server B determines that it is the ESP protocol, and then adds a set of decryption command headers D5 to D4, and forwards D5 to the encryption device port. At this time, the data packet enters the encryption and decryption device for decryption operation, and returns the decrypted data packet D6. At this time, D6=D2; G. IPSec server B transfers the D2 data packet to the protocol stack for processing. When processing the ESP protocol, only the protocol header is processed, and the protocol data is still processed as plain text; H. Forward the processed data to business machine 2 to complete a data transmission.

[0010] Preferably, the prerequisite for the encryption and decryption device to perform encryption and decryption operations is that the IKE negotiation has been completed, and the generated working key has been saved to the memory and can be obtained and used by the IPSec service.

[0011] Preferably, the DPDK is responsible for taking over the network card, and provides functions including but not limited to user-mode network card driver, large page memory, and DMA access; the VPP provides a user-mode protocol stack that can handle mainstream layer 2, layer 3, and layer 4 network protocols including IPSec; the encryption network card provides the functions of the network card and encryption module, including network packet sending and receiving and encryption and ESP data decryption functions.

[0012] Preferably, the processing of the data packet is performed in the transceiver module, and the encryption module processes the data packet by means of data offset.

[0013] Preferably, the encryption and decryption operations performed by the encryption and decryption device are: the encryption and decryption device receives the processed data packet; the encryption and decryption device parses the filled Key and Cmd information to perform encryption and decryption operations on the data to be encrypted and decrypted, and returns the result to the protocol stack.

[0014] Preferably, when the data packet is transmitted between the encryption network card and the operating system, the data packet is an ESP plaintext data packet; when the data packet is transmitted between IPSec server A and IPSec server B, the data packet is an ESP ciphertext data packet; when the data packet is transmitted between the IPSec server and the business machine, the data packet is a plaintext data packet.

[0015] Preferably, the offset of the data is the offset of the encrypted data compared to the original data, and the original data is an ESP protocol encapsulation frame of plain text data, including data frame information such as a Mac header, an IP header, and an ESP header.

[0016] Preferably, the encryption and decryption method based on the user-mode IPSec protocol places the protocol stack in the user mode, shields the processing of the protocol stack by the encryption card, and implements the IPSec function in the user mode.

[0017] Preferably, the encryption network card has a dedicated hardware accelerator for accelerating the encryption and decryption process.

[0018] Compared with the prior art, the present invention has the following beneficial effects: 1. This encryption and decryption method based on the user-mode IPSec protocol uses the user-mode protocol stack VPP+DPDK to effectively solve the performance bottleneck of the kernel protocol stack and optimizes performance in the following aspects: 1) CPU core utilization and processor affinity; 2) Optimize IPSec encryption and decryption algorithms; 3) Use acceleration hardware to handle the encryption and decryption process; 4) The memory copy, system call, and interrupt overhead of the IPSec data processing flow in the kernel protocol stack are relatively large, and there are only some upper-layer applications in the user state. This application puts the protocol stack in the user state to reduce the above overhead and implement the IPSec function in the user state; 5) Large memory pages and user space I / O increase cache hit rate.

[0019] 2. This encryption and decryption method based on the user-mode IPSec protocol adjusts the encryption and decryption operation from the ESP protocol processing stage to the data packet sending and receiving stage. By means of data offset, the encryption and decryption device processes the entire network packet, which increases concurrency, greatly improves the IPSec forwarding performance, shields the encryption card's processing of the protocol stack, and enables the encryption and decryption device to be fully utilized.

[0020] 3. This encryption and decryption method based on the user-mode IPSec protocol can effectively reduce context switching, improve processing efficiency, and provide higher flexibility and scalability, allowing dynamic adjustment of security policies, better utilization of hardware acceleration resources, and facilitate maintenance and troubleshooting. In addition, it can better adapt to the needs of cloud environments and containerized deployments, providing a more efficient, flexible and reliable solution for secure data transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is a user-mode IPSec protocol stack framework diagram of the present invention; Figure 2 A schematic diagram of a flow chart of an encryption and decryption method based on the user-mode IPSec protocol proposed by the present invention; Figure 3 Schematic diagram of the frame format of the transceiver module of the present invention; Figure 4 This is a test data diagram after the implementation of the present invention. DETAILED DESCRIPTION

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

[0023] IPSec VPN (tunnel mode) is mainly divided into two phases, IKE and ESP, according to the form of data packets. The IKE phase is mainly used for key negotiation between the two devices, while the ESP phase uses the negotiated key to encrypt data packets for communication. The IKE phase will not affect the business data flow, while the ESP phase is closely related to the overall throughput of IPSec. The encryption and decryption rate of the encryption and decryption equipment, the forwarding performance of network data packets, etc. directly affect the throughput of IPSec. Therefore, this solution only proposes improvements to the ESP protocol acceleration.

[0024] The present invention provides an encryption and decryption method based on the user-mode IPSec protocol, which integrates an encryption and decryption device into a network card device to form an encryption network card, and uses the high-performance encryption and decryption algorithm of the encryption and decryption device to directly perform encryption and decryption operations on data packets. After the operation is completed, it is directly forwarded from the encryption network card to the IPSec server, and then forwarded to the target machine by the IPSec server, thereby increasing the concurrency of encryption and decryption processing and greatly improving the IPSec forwarding performance; Among them: the encryption network card includes a transceiver module and a password module, and the transceiver module and the password module interact with each other; the operating system of the IPSec server includes DPDK and VPP; DPDK is responsible for taking over the network card, and the functions provided include but are not limited to user-mode network card drivers, large page memory, and DMA access; VPP provides a user-mode protocol stack that can handle mainstream layer 2, layer 3, and layer 4 network protocols including IPSec; the encryption network card provides the functions of the network card and encryption module, including network transceiver packets and ESP data encryption and decryption functions. In addition, the encryption network card has a dedicated hardware accelerator to accelerate the encryption and decryption process, which can provide efficient encryption and decryption performance while protecting the security and privacy of sensitive data.

[0025] The encryption and decryption method based on the user-state IPSec protocol provided by the present invention places the protocol stack in the user state, shields the processing of the protocol stack by the encryption card, and realizes the IPSec function in the user state. The framework diagram of the user-state IPSec protocol stack is as follows: Figure 1 shown.

[0026] The present invention provides a method for encryption and decryption based on the user-mode IPSec protocol. Figure 2 As shown, the specific process includes: A. Business machine 1 sends a plaintext data packet to IPSec server A; B. After receiving the plaintext data, IPSec server A performs ESP protocol plaintext encapsulation on the plaintext data according to IPSec protocol rules. This process does not perform any encryption or decryption operations. At this time, the system obtains the plaintext ESP protocol packet D1. C. IPSec server A adds an IP header and a Mac header to the plaintext ESP protocol packet D1 to form a protocol frame D2, and adds a set of encryption command headers to the protocol frame D2 to obtain a data packet D3; D. IPSec server A forwards data packet D3 to the encryption device port. At this time, the data packet enters the encryption and decryption device to perform encryption operations and returns the encrypted data packet D4. E. IPSec server A sends data packet D4 to peer IPSec server B. F. After receiving the data packet D4, IPSec server B determines that it is the ESP protocol, and then adds a set of decryption command headers D5 to D4, and forwards D5 to the encryption device port. At this time, the data packet enters the encryption and decryption device for decryption operation, and returns the decrypted data packet D6. At this time, D6=D2; G. IPSec server B transfers the D2 data packet to the protocol stack for processing. When processing the ESP protocol, only the protocol header is processed, and the protocol data is still processed as plain text; H. Forward the processed data to business machine 2 to complete a data transmission.

[0027] The prerequisite for the above encryption and decryption device to perform encryption and decryption operations is that the IKE negotiation has been completed, and the generated working key has been saved to the memory and can be obtained and used by the ipsec service. The encryption and decryption operations of the encryption and decryption device are as follows: the encryption and decryption device receives the processed data packet; the encryption and decryption device parses the filled Key and Cmd information to perform encryption and decryption operations on the data to be encrypted and decrypted, and returns the result to the protocol stack. In this process, the data packet is processed in the transceiver module, and the encryption module processes the data packet by means of data offset, and the data offset is the offset of the encrypted data compared to the original data, and the original data is the ESP protocol encapsulation frame of the plaintext data, including Mac header, IP header, ESP header and other data frame information.

[0028] Data packets D3 and D5 are processed in the data transceiver module, and their frame formats are as follows: Figure 3As shown in the figure: SM4-KEY and HMAC-KEY are the working keys after IKE negotiation, representing the SM4 key and HMAC key respectively; the Offset field is the offset of the data to be encrypted compared to the original data, Len represents the length of the data to be encrypted, and the Mode field indicates whether the current operation to be performed is encryption or decryption; the original data is a plaintext ESP protocol encapsulation frame, including Mac header, IP header, ESP header and other data frame information.

[0029] After distributing the D3 and D5 packets to the encryption module of the encryption network card, the encryption module parses the filled Key and Cmd information, performs encryption and decryption operations on the data to be encrypted and decrypted, and returns the results to the protocol stack.

[0030] During the entire process, the encryption and decryption operations are adjusted from the ESP protocol processing stage to the data packet sending and receiving stage. Through data offset, the encryption and decryption device processes the entire network packet, which increases concurrency and shields the encryption card's processing of the protocol stack, allowing the encryption and decryption device to be fully utilized.

[0031] When the data packet is transmitted between the encryption network card and the operating system, the data packet is an ESP plaintext data packet; when the data packet is transmitted between IPSec server A and IPSec server B, the data packet is an ESP ciphertext data packet; when the data packet is transmitted between the IPSec server and the business machine, the data packet is a plaintext data packet.

[0032] The test data after the implementation of the encryption and decryption method based on the user-mode IPSec protocol is as follows: Figure 4 As shown in the table, the forwarding performance of various data packets under different packet lengths is tested respectively.

[0033] The IPSec ciphertext data packet performance is the measured IPSec performance data with encryption and decryption functions. It can be seen that by implementing this solution, the IPSec encryption and decryption throughput performance is greatly improved.

[0034] From the above description, it can be seen that the present invention adopts the user-mode protocol stack VPP+DPDK mode to effectively solve the performance bottleneck of the kernel protocol stack, and optimizes performance in the following aspects: 1) CPU core utilization and processor affinity; 2) Optimize IPSec encryption and decryption algorithms; 3) Use acceleration hardware to handle the encryption and decryption process; 4) The memory copy, system call, and interrupt overhead of the IPSec data processing flow in the kernel protocol stack are relatively large, and there are only some upper-layer applications in the user state. This application puts the protocol stack in the user state to reduce the above overhead and implement the IPSec function in the user state; Large memory pages and user space I / O increase cache hit rate.

[0035] The contents not described in detail in this specification belong to the prior art known to professional and technical personnel in the field. Although the embodiments of the present invention have been shown and described, it is understood by ordinary technicians in the field that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principle and spirit of the present invention. The scope of the present invention is defined by the attached claims and their equivalents.

Claims

1. An encryption and decryption method based on the user-mode IPSec protocol. Features: The encryption and decryption device is integrated into the network card device to form an encryption network card. The high-performance encryption and decryption algorithm of the encryption and decryption device is used to directly encrypt and decrypt the data packet. After the operation is completed, it is directly forwarded from the encryption network card to the IPSec server, and then forwarded to the target machine by the IPSec server. This increases the concurrency of encryption and decryption processing and greatly improves the IPSec forwarding performance. Wherein: the encryption network card includes a transceiver module and a password module, and the transceiver module and the password module interact with each other; the operating system of the IPSec server includes DPDK and VPP; The encryption and decryption method based on the user-mode IPSec protocol includes: A. Business machine 1 sends a plaintext data packet to IPSec server A; B. After receiving the plaintext data, IPSec server A performs ESP protocol plaintext encapsulation on the plaintext data according to IPSec protocol rules. This process does not perform any encryption or decryption operations. At this time, the system obtains the plaintext ESP protocol packet D1. C. IPSec server A adds an IP header and a Mac header to the plaintext ESP protocol packet D1 to form a protocol frame D2, and adds a set of encryption command headers to the protocol frame D2 to obtain a data packet D3; D. IPSec server A forwards data packet D3 to the encryption device port. At this time, the data packet enters the encryption and decryption device to perform encryption operations and returns the encrypted data packet D4. E. IPSec server A sends data packet D4 to peer IPSec server B. F. After receiving the data packet D4, IPSec server B determines that it is the ESP protocol, and then adds a set of decryption command headers D5 to D4, and forwards D5 to the encryption device port. At this time, the data packet enters the encryption and decryption device for decryption operation, and returns the decrypted data packet D6. At this time, D6=D2; G. IPSec server B transfers the D2 data packet to the protocol stack for processing. When processing the ESP protocol, only the protocol header is processed, and the protocol data is still processed as plain text; H. Forward the processed data to business machine 2 to complete a data transmission.

2. According to claim 1, a method for encryption and decryption based on user-mode IPSec protocol, Features: The prerequisite for the encryption and decryption device to perform encryption and decryption operations is that the IKE negotiation has been completed, the generated working key has been saved to the memory, and can be obtained and used by the IPSec service.

3. According to claim 1, a method for encryption and decryption based on user-mode IPSec protocol, Features: The DPDK is responsible for taking over the network card, and provides functions including but not limited to user-mode network card driver, large page memory, and DMA access; the VPP provides a user-mode protocol stack that can handle mainstream layer 2, layer 3, and layer 4 network protocols including IPSec; the encryption network card provides the functions of the network card and encryption module, including network packet sending and receiving and ESP data encryption and decryption functions.

4. According to claim 3, a method for encryption and decryption based on user-mode IPSec protocol, Features: The data packet is processed in the transceiver module, and the encryption module processes the data packet by means of data offset.

5. According to claim 4, a method for encryption and decryption based on user-mode IPSec protocol, Features: The encryption and decryption operations of the encryption and decryption device are as follows: the encryption and decryption device receives the processed data packet; the encryption and decryption device parses the filled Key and Cmd information to perform encryption and decryption operations on the data to be encrypted and decrypted, and returns the result to the protocol stack.

6. The encryption and decryption method based on the user-mode IPSec protocol according to claim 1, Features: When the data packet is transmitted between the encryption network card and the operating system, the data packet is an ESP plaintext data packet; when the data packet is transmitted between IPSec server A and IPSec server B, the data packet is an ESP ciphertext data packet; when the data packet is transmitted between the IPSec server and the business machine, the data packet is a plaintext data packet.

7. The encryption and decryption method based on the user-mode IPSec protocol according to claim 4, Features: The data offset is the offset of the encrypted data compared to the original data, and the original data is the ESP protocol encapsulation frame of the plain text data, including data frame information such as Mac header, IP header, ESP header, etc.

8. The encryption and decryption method based on the user-mode IPSec protocol according to claim 1, Features: The encryption and decryption method based on the user-mode IPSec protocol places the protocol stack in the user mode, shields the processing of the protocol stack by the encryption card, and realizes the IPSec function in the user mode.

9. The encryption and decryption method based on the user-mode IPSec protocol according to claim 5, Features: The encryption network card has a dedicated hardware accelerator for accelerating the encryption and decryption process.

Citation Information

Cited By

  • Data encryption and decryption method and device, storage medium and electronic equipment

    CN121256834A