Secure communication implementation method and network equipment using software and hardware collaborative encryption
Through the software and hardware collaborative encryption method, the collaborative work of the XFRM module and the PL hardware module is used to reduce the processor resource consumption in the IPSec security protection process, achieving resource saving and performance improvement.
Patent Information
- Application Number
- CN202410832813.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-06-25
AI Technical Summary
The IPSec security protection process consumes a large amount of processor resources, resulting in high resource usage.
Using the software and hardware collaborative encryption method, the XFRM module is used to obtain and record the corresponding relationship between the message identification information and the SA information, and the encapsulated network packet is sent to the PL hardware module for IPSec security protection.
It reduces the processor resource consumption in the IPSec security protection process, saves resource overhead, and uses the high-performance computing of the PL hardware module to reduce the processor load.
Smart Images

Figure CN118381684B
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method and network device for implementing secure communication with software and hardware collaborative encryption. Background Art
[0002] IPSec (Internet Protocol Security) is a security and confidentiality architecture that uses cryptography to protect IP layer communications. It is a protocol suite that protects the IP protocol's network transmission protocol suite (a collection of interrelated protocols) by encrypting and authenticating IP protocol packets. IPSec can achieve the following four functions: Data confidentiality, the IPSec sender encrypts the network packet before sending it. Data integrity, the IPSec receiver verifies the network packet to ensure that the network packet has not been changed during transmission. Data authentication, the IPSec receiver identifies the origin of the network packet. Anti-replay, the IPSec receiver checks and refuses to replay the network packet.
[0003] IPSec is mainly composed of the following protocols: Authentication Header (AH), which is the encapsulation mode of IPSec, provides connectionless data integrity, message authentication, and anti-replay attack protection for network packets. Encapsulating Security Payload (ESP), which is the encapsulation mode of IPSec, provides confidentiality, data source authentication, connectionless integrity, anti-replay, and traffic-flow confidentiality for network packets. Security Association (SA), which provides algorithms and data packets, and provides the parameters required for AH and ESP operations. Internet Key Exchange (IKE), a communication protocol used to establish SA, is used for the survival and exchange of symmetric keys required for ESP / AH encapsulation.
[0004] During the IPSec processing, SA information is required to perform IPSec security protection on network packets. However, the IPSec security protection process of network packets consumes a large amount of processor resources and occupies a high amount of resources. Summary of the invention
[0005] In view of this, the present application proposes a secure communication implementation method and network device for software-hardware collaborative encryption, which can reduce the processor resources consumed by the IPSec security protection process and save resource overhead.
[0006] The present application provides a method for implementing secure communication by collaborative encryption of software and hardware, which is applied to a network device, wherein the network device includes an XFRM module and a PL hardware module, and the method includes:
[0007] The XFRM module obtains the message identification information and SA information corresponding to the first network packet, and records the corresponding relationship between the message identification information and the SA information in a mapping table;
[0008] After receiving the first network packet, the XFRM module queries the mapping table through the message identification information of the first network packet to obtain the SA information corresponding to the message identification information; encapsulates the SA information in the first network packet, and sends the encapsulated first network packet to the PL hardware module;
[0009] After receiving the encapsulated first network packet, the PL hardware module parses the SA information from the encapsulated first network packet, performs IPSec security protection on the first network packet based on the SA information, obtains the protected first network packet, and sends the protected first network packet.
[0010] The present application provides a network device, the network device comprising:
[0011] An XFRM module is used to obtain the message identification information and SA information corresponding to the first network packet, and record the corresponding relationship between the message identification information and the SA information in a mapping table;
[0012] And, after receiving the first network packet, query the mapping table through the message identification information of the first network packet to obtain the SA information corresponding to the message identification information; encapsulate the SA information in the first network packet, and send the encapsulated first network packet to the PL hardware module;
[0013] The PL hardware module is used to parse the SA information from the encapsulated first network packet after receiving it, perform IPSec security protection on the first network packet based on the SA information, obtain the first network packet after security protection, and send the first network packet after security protection.
[0014] It can be seen from the above technical solution that in the embodiment of the present application, the IPSec processing process is implemented through the collaboration of software and hardware, that is, the XFRM module is implemented by software, and the PL hardware module is implemented by hardware. The operations that consume a lot of resources in the IPSec processing process (IPSec security protection of network packets based on SA information) are placed in the PL hardware module to complete, and the remaining operations are placed in the XFRM module to complete, thereby reducing the processor resources consumed by the IPSec security protection process (the XFRM module uses processor resources), saving resource overhead, and being able to utilize the high-performance computing of the PL hardware module to reduce the load on processor resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flowchart of a method for implementing secure communication using software and hardware collaborative encryption;
[0016] Figure 2 is a schematic diagram of the structure of a network device in one embodiment of the present application;
[0017] Figure 3 It is a schematic diagram of the XFRM module and the PL hardware module synchronously maintaining the mapping table;
[0018] Figure 4A is a schematic diagram of the processing process of the XFRM module in one embodiment of the present application;
[0019] Figure 4B is a schematic diagram of a driving framework of PHY1 in one embodiment of the present application;
[0020] Figure 4C is a schematic diagram of an improved driving framework of PHY1 in one embodiment of the present application;
[0021] Figure 5A is a schematic diagram of the IPSec processing process for the first network packet;
[0022] Figure 5B is a schematic diagram of the processing process of the XFRM module in one embodiment of the present application;
[0023] Figure 5C is a schematic diagram of the xfrm_output_one process in one implementation of the present application;
[0024] Figure 6 is a schematic diagram of the structure of a PL hardware module in one embodiment of the present application;
[0025] Fig. 7A is a schematic diagram of the IPSec processing process for the second network packet;
[0026] Figure 7B is a schematic diagram of the processing process of the XFRM module in one embodiment of the present application;
[0027] Figure 8 It is a structural diagram of a secure communication implementation device with software and hardware collaborative encryption. DETAILED DESCRIPTION
[0028] In the embodiment of the present application, a method for implementing secure communication with software and hardware collaborative encryption is proposed, which can be applied to a network device, which can be used as an IPSec sender or an IPSec receiver. The network device may include an XFRM (eXtensible Flow Representation and Marking) module and a PL (Programmable Logic) hardware module. The XFRM module can be implemented by software, and the PL hardware module can be implemented by hardware. Figure 1 As shown, it is a flowchart of the method for implementing the secure communication of the software and hardware collaborative encryption, and the method may include:
[0029] Step 101: The XFRM module obtains the message identification information and SA information corresponding to the first network packet, and records the corresponding relationship between the message identification information and the SA information in a mapping table.
[0030] Step 102: After receiving the first network packet, the XFRM module queries the mapping table through the message identification information of the first network packet to obtain the SA information corresponding to the message identification information; encapsulates the SA information in the first network packet, and sends the encapsulated first network packet to the PL hardware module.
[0031] Step 103: After receiving the encapsulated first network packet, the PL hardware module parses the SA information from the encapsulated first network packet, performs IPSec security protection on the first network packet based on the SA information, obtains the protected first network packet, and sends the protected first network packet.
[0032] Exemplarily, after the XFRM module queries the mapping table through the message identification information of the first network packet and obtains the SA information corresponding to the message identification information, it may also include: the XFRM module checks whether the offload function is turned on; wherein, turning on the offload function means disabling IPSec security protection, and turning off the offload function means enabling IPSec security protection. If not, the XFRM module can perform IPSec security protection on the first network packet based on the SA information, obtain the first network packet after security protection, and send the first network packet after security protection. If yes, the XFRM module can perform the operation of encapsulating the SA information in the first network packet and sending the encapsulated first network packet to the PL hardware module.
[0033] Exemplarily, the PL hardware module performs IPSec security protection on the first network packet based on the SA information to obtain the first network packet after security protection, which may include but is not limited to: the PL hardware module performs MAC (Media Access Control) analysis on the first network packet to obtain the MAC address and the first inner message behind the MAC address; the PL hardware module performs IP analysis on the first inner message to obtain the IP address and the second inner message behind the IP address. If the first network packet is an AH network packet or an ESP network packet, the PL hardware module performs SA analysis on the second inner message to obtain the SA information and the payload message behind the SA information; if the SA information includes symmetric key information and message authentication code key information, the PL hardware module uses the symmetric key information to encrypt the payload message to obtain a ciphertext payload message, and uses the message authentication code key information to calculate the message authentication code corresponding to the ciphertext payload message; the PL hardware module splices the ciphertext payload message, the message authentication code, the MAC address and the IP address to obtain the first network packet after security protection.
[0034] Exemplarily, after the XFRM module obtains the message identification information and SA information corresponding to the first network packet, it may also include: the XFRM module sends the message identification information and SA information to the PL hardware module, and the PL hardware module records the correspondence between the message identification information and the SA information in a mapping table.
[0035] After the PL hardware module sends the first network packet after security protection, the method may further include: after the PL hardware module receives the second network packet in response to the first network packet, the PL hardware module queries the mapping table through the message identification information of the second network packet to obtain the SA information. The PL hardware module performs IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, and sends the second network packet after security protection to the XFRM module so that the XFRM module processes the received second network packet.
[0036] Exemplarily, the PL hardware module performs IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, which may include but is not limited to: the PL hardware module performs MAC resolution on the second network packet to obtain the MAC address and the first inner message following the MAC address; the PL hardware module performs IP resolution on the first inner message to obtain the IP address and the second inner message following the IP address. If the SA information includes symmetric key information and message authentication code key information, the PL hardware module can use the message authentication code key information to calculate the message authentication code corresponding to the second inner message, and determine the authentication operation result of the second network packet based on the message authentication code; the PL hardware module uses the symmetric key information to decrypt the second inner message to obtain a plaintext payload message. The PL hardware module splices the plaintext payload message, the authentication operation result, the MAC address and the IP address to obtain the second network packet after security protection.
[0037] Exemplarily, the XFRM module processes the received second network packet, which may include but is not limited to: the XFRM module checks whether the offload function is turned on; if so, and the second network packet is an AH network packet or an ESP network packet, the XFRM module can parse the identification operation result from the received second network packet; wherein the identification operation result may indicate that the second network packet passes the message identification, or the second network packet fails the message identification. If the identification operation result indicates that the second network packet passes the message identification, the XFRM module forwards the second network packet through the physical network port; or, if the identification operation result indicates that the second network packet fails the message identification, the XFRM module may discard the second network packet.
[0038] Exemplarily, the XFRM module sends the message identification information and the SA information to the PL hardware module, and the PL hardware module records the correspondence between the message identification information and the SA information in the mapping table, which may include but is not limited to: if the SA information is newly added SA information for the message identification information, the XFRM module may send a state addition command to the PL hardware module, and the state addition command may carry the message identification information and the newly added SA information; the PL hardware module may record the correspondence between the message identification information and the newly added SA information in the mapping table based on the state addition command. Alternatively, if the SA information is updated SA information for the message identification information, the XFRM module may send a state deletion command and a state addition command to the PL hardware module, and the state deletion command may carry the message identification information, and the state addition command may carry the message identification information and the updated SA information; the PL hardware module deletes the correspondence between the message identification information and the SA information from the mapping table based on the state deletion command, and the PL hardware module records the correspondence between the message identification information and the newly added SA information in the mapping table based on the state addition command.
[0039] It can be seen from the above technical solution that in the embodiment of the present application, the IPSec processing process is implemented through the collaboration of software and hardware, that is, the XFRM module is implemented by software, and the PL hardware module is implemented by hardware. The operations that consume a lot of resources in the IPSec processing process (IPSec security protection of network packets based on SA information) are placed in the PL hardware module to complete, and the remaining operations are placed in the XFRM module to complete, thereby reducing the processor resources consumed by the IPSec security protection process (the XFRM module uses processor resources), saving resource overhead, and being able to utilize the high-performance computing of the PL hardware module to reduce the load on processor resources.
[0040] The above technical solutions of the embodiments of the present application are described below in combination with specific application scenarios.
[0041] IPSec can achieve the following four functions: Data confidentiality, the IPSec sender encrypts the network packet and sends it. Data integrity, the IPSec receiver verifies the network packet to ensure that the network packet has not been changed during transmission. Data authentication, the IPSec receiver identifies the origin of the network packet. Anti-replay, the IPSec receiver checks and refuses to replay the network packet. IPSec is mainly composed of the following protocols: Authentication Header (AH), which is the encapsulation mode of IPSec, provides connectionless data integrity, message authentication and anti-replay attack protection for network packets. Encapsulating Security Payload (ESP), which is the encapsulation mode of IPSec, provides confidentiality, data source authentication, connectionless integrity, anti-replay and transport stream confidentiality for network packets. Security Association (SA), provides algorithms and data packets, and provides the parameters required for AH operation and ESP operation. Internet Key Exchange Protocol (IKE), a communication protocol used to establish SA, is used for the survival and exchange of symmetric keys required for ESP / AH encapsulation.
[0042] During the IPSec processing, SA information is required to perform IPSec security protection on network packets. However, the IPSec security protection process of network packets consumes a large amount of processor resources and occupies a high amount of resources.
[0043] In response to the above findings, a method for implementing secure communication with software-hardware collaborative encryption is proposed in an embodiment of the present application. The XFRM module can be implemented by software, and the PL hardware module can be implemented by hardware. The IPSec processing process is realized through the software-hardware collaboration of the XFRM module and the PL hardware module.
[0044] See also Figure 2The figure shows a schematic diagram of the structure of a network device, and the network device is any type of device, such as a router or a switch. The network device can act as an IPSec sender or an IPSec receiver. For example, assume that the physical network port 0 of the network device is connected to the security domain, and the physical network port 1 of the network device is connected to the non-security domain. For the network packet from the security domain to the non-security domain (referred to as the first network packet), the network device performs an encryption operation on the first network packet, and for the processing of the first network packet, the network device acts as an IPSec sender. For the network packet from the non-security domain to the security domain (referred to as the second network packet), the network device performs a decryption operation on the second network packet, and for the processing of the second network packet, the network device acts as an IPSec receiver.
[0045] See also Figure 2 As shown, the network device includes physical network port 0, and the network device is connected to the security domain through physical network port 0. The network device includes PHY0 (Physical), that is, port physical layer 0. Electrical signals can be transmitted between PHY0 and physical network port 0, that is, data packets need to be converted into electrical signals for transmission. The network device includes GMAC Contronller (controller), and the MDIO (Management Data Input Output) signal / MDC (Management Data Clock) signal can be used between GMAC Contronller and PHY0, and the GMII (Gigabit Media Independent) signal can be used between GMAC Contronller and PHY0.
[0046] See also Figure 2 As shown, the network device may further include a PS (Processing System) module and a PL (Programmable Logic) hardware module. The PS module and the PL hardware module may be implemented by the same device, or by different devices.
[0047] The PS module may include a GMAC Driver, which is connected to a GMAC Contronller, and network packets may be transmitted between the GMAC Driver and the GMAC Contronller.
[0048] The PS module may include an XFRM module, which is also called an XFRM framework module. The XFRM module is the "infrastructure" of IPSec. This "infrastructure" is independent of the protocol cluster and includes common parts that can be applied to both IPv4 and IPv6, that is, the IPSec security protection process can be implemented through the XFRM module. In this embodiment, the function of the XFRM module can be improved, and some functions of the XFRM module can be placed in the PL hardware module, so as to reduce the processor resources consumed by the IPSec security protection process.
[0049] The XFRM module can be implemented through software, that is, the XFRM module can call processor resources to implement the IPSec security protection process. The XFRM module is connected to the GMAC Driver and can receive network packets from the GMAC Driver. The XFRM module can also send network packets to the GMAC Driver.
[0050] The PS module may include an EthernetDriver, which may also be an EthernetMAC Driver. The EthernetDriver is connected to the SAD module of the PL hardware module via an Advanced eXtensible Interface (AXI). In this way, the XFRM module and the PL hardware module (such as the SAD module) may communicate via AXI. The process may be described in subsequent embodiments.
[0051] The PS module can include PhyDriver (physical layer driver) and MII (Medium Independent Interface, media independent interface, i.e. media independent interface) Bus Driver (public driver). The Ethernet frame processing module of the PhyDriver PL hardware module can be GMII signal, and the Ethernet frame processing module of the MII Bus Driver and the PL hardware module can be MDIO / MDC signal. Obviously, the XFRM module and the PL hardware module (such as the Ethernet frame processing module) can transmit GMII signals (i.e., through EthernetDriver and PhyDriver in sequence), or the XFRM module and the Ethernet frame processing module can transmit MDIO / MDC signals (i.e., through EthernetDriver, PhyDriver, and MII BusDriver in sequence to achieve communication).
[0052] See also Figure 2As shown, the PL hardware module may include a SAD module and an Ethernet frame processing module, the AXI signal is between the SAD module and the XFRM module, the GMII signal is between the Ethernet frame processing module and the XFRM module, or the MDIO / MDC signal is between the Ethernet frame processing module and the XFRM module.
[0053] The PL hardware module can be implemented through hardware, that is, additional hardware is configured in the network device to implement the PL hardware module. The PL hardware module can be configured in any programmable logic device without restriction.
[0054] See also Figure 2 As shown, the network device includes a physical network port 1, and the network device is connected to the non-security domain through the physical network port 1. The network device includes PHY1, that is, port physical layer 1, and electrical signals can be transmitted between PHY1 and physical network port 1, that is, data packets need to be converted into electrical signals for transmission. The Ethernet frame processing module of the PL hardware module and PHY1 can be an MDIO signal / MDC signal, and the Ethernet frame processing module of the PL hardware module and PHY1 can also be an RGMII signal.
[0055] from Figure 2 It can be seen that the PL hardware module as a whole has IOs including MDC / MDIO, AXI, and RGMII / GMII. The electrical signal in physical network port 0 is converted into a digital signal by PHY0, and the PS module controls PHY0 through the GMAC Driver to complete the communication of physical network port 0. The electrical signal in physical network port 1 is converted into a digital signal by PHY1 and transmitted to the PL hardware module. The PL hardware module parses and repackages the Ethernet frame, serving as an intermediate transfer layer between the PS module and PHY1.
[0056] from Figure 2 It can be seen that the network port of the PL hardware module can be used as the computing offload network port (part of the functions of the XFRM module can be migrated to the PL hardware module to achieve this), and the PL hardware module and the PS module can be connected based on the Ethernet-PHY-MDIO / MII driver framework, so that the network port can be called normally by the Linux kernel. In this way, the process of network packet protection is also shortened, and the entire process can be completed by only passing through the network port of the PL hardware module -> PS processing -> PL hardware module network port, which greatly shortens the interface delay.
[0057] In subsequent embodiments, the processing of the PL hardware module and the XFRM module will be described in detail. The processing of other components of the network device is not limited in this embodiment.
[0058] In the above application scenario, the following process may be involved in the embodiment of the present application:
[0059] First, the XFRM module and the PL hardware module synchronously maintain a mapping table, which is used to record the correspondence between the message identification information and the SA information. The message identification information can be the identification information of the network packet, such as the address information of the network packet (such as the source IP address and the destination IP address), and there is no restriction on this message identification information.
[0060] SA information is information used to perform IPSec security protection on network packets. SA information may include symmetric key information and message authentication code key information. Symmetric key information may include symmetric key and encryption algorithm type. The encryption algorithm type indicates which encryption algorithm is used to encrypt the network packet, such as SM4 encryption algorithm, etc. The symmetric key indicates the key used when the encryption algorithm is used to encrypt the network packet, that is, when the SM4 encryption algorithm is used to encrypt the network packet, the symmetric key is used to encrypt the network packet.
[0061] The message authentication code key information may include a message authentication code key and an integrity algorithm type. The integrity algorithm type indicates which integrity algorithm is used to perform integrity processing on the network packet, such as the SM3 algorithm, etc. The message authentication code key indicates the key used when the integrity algorithm is used to process the network packet, that is, when the SM3 algorithm is used to process the network packet, the message authentication code key is used to process the network packet.
[0062] Of course, the above is only an example of SA information, and the content of the SA information is not limited in this embodiment.
[0063] See also Figure 3 As shown, it is a schematic diagram of the XFRM module and the PL hardware module synchronously maintaining the mapping table.
[0064] Step 301: The XFRM module obtains the message identification information and SA information corresponding to the first network packet, and records the corresponding relationship between the message identification information and the SA information in a mapping table.
[0065] Exemplarily, the first network packet is a data packet from physical network port 0 (security domain) to physical network port 1 (non-security domain). After creating or renegotiating IKE, the upper layer application can send an SA request to the XFRM module through netlink, and the SA request can carry the message identification information and SA information corresponding to the first network packet.
[0066] After receiving the SA request, the XFRM module may parse the message identification information and the SA information from the SA request, and record the corresponding relationship between the message identification information and the SA information in a mapping table.
[0067] Step 302, the XFRM module checks whether the offload function is enabled. If the offload function is enabled, IPSec security protection is disabled, that is, the XFRM module is prohibited from enabling IPSec security protection. In this case, IPSec security protection needs to be enabled in the PL hardware module. If the offload function is disabled, IPSec security protection is enabled, that is, the XFRM module enables IPSec security protection. In this case, IPSec security protection does not need to be enabled in the PL hardware module, that is, the PL hardware module does not need to participate in the IPSec security protection of network packets.
[0068] If not, the process ends, and the XFRM module does not need to send the message identification information and the SA information to the PL hardware module, nor does it need to record the correspondence between the message identification information and the SA information in the mapping table of the PL hardware module. If yes, the XFRM module can execute step 303.
[0069] Step 303: The XFRM module sends the message identification information and the SA information to the PL hardware module.
[0070] Step 304: After receiving the message identification information and the SA information, the PL hardware module records the corresponding relationship between the message identification information and the SA information in a mapping table.
[0071] In one possible implementation, see Figure 4A As shown, it is a schematic diagram of the processing process of the XFRM module. The upper layer application can be IKE software. The IKE software can send an SA request to the XFRM module through netlink. The SA request can carry message identification information and SA information. In addition, the XFRM module can support the xfrmdev_ops (device operation) function, and the xfrmdev_ops function can include but is not limited to three sub-functions such as xdo_dev_offload_ok, xdo_dev_state_add and xdo_dev_state_delete.
[0072] Based on the xdo_dev_offload_ok subfunction, the XFRM module can check whether the offload function is enabled. If so, the xdo_dev_state_add subfunction or the xdo_dev_state_delete subfunction is triggered.
[0073] If the SA information is newly added SA information for the message identification information, that is, the PL hardware module has not recorded the SA information corresponding to the message identification information, and the SA information is newly added SA information, the xdo_dev_state_add sub-function can be triggered. Based on the xdo_dev_state_add sub-function, the XFRM module sends a state addition command (i.e., the xdo_dev_state_add command) to the SAD module of the PL hardware module. The state addition command carries the message identification information and the newly added SA information. The state addition command is an AXI-based command.
[0074] After receiving the state adding command, the SAD module may parse out the message identification information and the newly added SA information, and record the corresponding relationship between the message identification information and the newly added SA information in a mapping table.
[0075] If the SA information is the updated SA information for the message identification information, that is, the PL hardware module has recorded the SA information corresponding to the message identification information, and the SA information is the updated SA information, the xdo_dev_state_delete sub-function and the xdo_dev_state_add sub-function can be triggered at the same time.
[0076] Based on the xdo_dev_state_delete sub-function, the XFRM module sends a state deletion command (i.e., the xdo_dev_state_delete command) to the SAD module of the PL hardware module. The state deletion command may carry the message identification information, and the state deletion command may be an AXI-based command. After receiving the state deletion command, the SAD module may parse the message identification information and delete the corresponding relationship between the message identification information and the SA information from the mapping table, i.e., delete the existing table entry of the message identification information.
[0077] Based on the xdo_dev_state_add sub-function, the XFRM module sends a state add command to the SAD module. The state add command carries the message identification information and the updated SA information. The state add command can be an AXI-based command. After receiving the state add command, the SAD module can parse the message identification information and the updated SA information, and record the corresponding relationship between the message identification information and the updated SA information in the mapping table.
[0078] In a possible implementation, in order to perform protection processing on network packets, the driver framework of PHY1 can be modified, and the SAD module of the PL hardware module can be modified using AXI, so that the XFRM module can support sub-functions such as xdo_dev_offload_ok, xdo_dev_state_add, and xdo_dev_state_delete.
[0079] See also Figure 4B The figure shows the schematic diagram of the driver framework of PHY1. The driver framework of PHY1 can include ethernet_diver_probe (Ethernet driver detection) and phy_diver_probe (physical driver detection). In the ethernet_diver_probe process, the following functions can be implemented: create and register net_device (network device), set phy_device (physical layer device), apply for queue and dma.
[0080] During the phy_diver_probe process, the following functions can be implemented: create and register MDIO devices, create and register phy devices, interrupt mapping, and add phy devices to phy_map.
[0081] After improving the driver framework of PHY1, see Figure 4C , which is a schematic diagram of an improved driving framework of PHY1. The improved driving framework of PHY1 may include ethernet_diver_probe, phy_diver_probe, and init_IPSec_offload (initialization of the offload function of IPSec).
[0082] In the ethernet_diver_probe process, in addition to creating and registering net_device, setting phy_device, applying for queues and dma, ethernet_diver_probe can also implement the following functions: IPSec_offload initialization, associating IPSec_offload and net_device. The function of IPSec_offload initialization can correspond to init_IPSec_offload. For associating IPSec_offload and net_device, the IPSec related members of net_device can be set, thereby associating IPSec_offload and IPSec related members of net_device.
[0083] During the phy_diver_probe process, functions such as creating and registering MDIO devices, creating and registering phy devices, interrupt mapping, and adding phy devices to phy_map may still be involved.
[0084] During the init_IPSec_offload process, a new linuxSA database can be created, space can be allocated for the linuxSA database (that is, the mapping table is maintained through the space, and the correspondence between the message identification information and the SA information is recorded in the mapping table), and a request is sent to the SAD module through AXI. The request is used to clear all data in the SAD module. In this way, the SAD module can also maintain the mapping table.
[0085] In the init_IPSec_offload process, a processing function can be bound, and the xfrmdev_ops related methods can be added and bound through the processing function, that is, the XFRM module implements the xfrmdev_ops function through the processing function, and the xfrmdev_ops function can include two sub-functions such as xdo_dev_state_add and xdo_dev_state_delete. The implementation of the above two sub-functions can refer to the above embodiment. Two IPSec processing processes IPSec_rx / IPSec_tx can also be added to the data receiving function and data sending function of the Ethernet layer to facilitate the addition and reception of special data fields required by the PL hardware module to process IPSec.
[0086] During the init_IPSec_offload process, net_dev offload related attributes may be set. By setting the net_dev offload related attributes, the XFRM module implements the xfrmdev_ops function, and the xfrmdev_ops function may include sub-functions such as xdo_dev_offload_ok. For the implementation of the above sub-functions, refer to the above embodiments.
[0087] From the above, it can be seen that by improving the driver framework of PHY1, the XFRM module can implement the xfrmdev_ops function, and the xfrmdev_ops function can include xdo_dev_offload_ok, xdo_dev_state_add and xdo_dev_state_delete. xfrmdev_ops includes processing such as adding SA information and deleting SA information. In xdo_dev_state_add, the AXI interface is used to send the SA add request to the SAD module. In xdo_dev_state_delete, the AXI interface is used to send the SA delete request to the SAD module. In xdo_dev_offload_ok, it is mainly detected whether the current SA can be unloaded.
[0088] Second, for the IPSec processing process of the first network packet (ie, the protection process of the first network packet), the first network packet is a data packet from physical network port 0 (security domain) to physical network port 1 (non-security domain).
[0089] See also Figure 5A FIG. 4 is a schematic diagram of the IPSec processing process for the first network packet.
[0090] Step 501: The XFRM module receives a first network packet.
[0091] Step 502: After receiving the first network packet, the XFRM module searches the mapping table through the message identification information of the first network packet to obtain the SA information corresponding to the message identification information.
[0092] Step 503: The XFRM module checks whether the offload function is enabled.
[0093] Exemplarily, the offload function is turned off, which means that IPSec security protection is enabled, that is, the XFRM module enables IPSec security protection. At this time, it is not necessary to enable IPSec security protection in the PL hardware module, that is, the PL hardware module does not need to participate in the IPSec security protection of the network packet. Based on this, if the offload function is not enabled (that is, the offload function is turned off), step 504 can be executed. The offload function is turned on, which means that IPSec security protection is disabled, that is, the XFRM module is prohibited from enabling IPSec security protection. At this time, IPSec security protection needs to be enabled in the PL hardware module. Based on this, if the offload function is enabled, step 505 can be executed.
[0094] For example, if the offload function is turned off, the calculation is not offloaded, and IPSec security protection can be performed by the XFRM module instead of the PL hardware module. If the offload function is turned on, the calculation is offloaded, and IPSec security protection is not performed by the XFRM module, but by the PL hardware module.
[0095] Step 504: The XFRM module performs IPSec security protection on the first network packet based on the SA information, obtains the first network packet after security protection, and sends the first network packet after security protection.
[0096] Exemplarily, if the SA information includes symmetric key information and message authentication code key information, the XFRM module can use the symmetric key information to encrypt the first network packet to obtain an encrypted network packet, use the message authentication code key information to calculate the message authentication code corresponding to the encrypted network packet, and encapsulate the message authentication code in the encrypted network packet to obtain the first network packet after security protection. There is no restriction on this process. The XFRM module can send the first network packet after security protection to the external device through the physical network port 1. Obviously, in the above process, the PL hardware module is not required to perform IPSec security protection on the first network packet.
[0097] In a possible implementation, the processing of the XFRM module can be found in Figure 5B shown.
[0098] For the first network packet received from physical network port 0, since the destination IP address of the first network packet is not the local machine, after IPv4 or IPv6 forwarding is enabled, it will be forwarded from other network ports (such as physical network port 1) and enter the sending process. The sending process corresponds to Figure 5B udp_sendmsg in.
[0099] The XFRM module can query the mapping table through the message identification information of the first network packet to obtain the SA information. This process corresponds to Figure 5B xfrm_lookup_route and xfrm_lookup in. xfrm_lookup_route means to query the mapping table through the message identification information, and xfrm_lookup means to obtain the SA information.
[0100] Entering the protection process of the first network packet, based on xfrm_output and xfrm_output2, means that the first network packet enters the protection process, based on xfrm_output, xfrm_output_gso and xfrm_output2, means that the first network packet is first fragmented, and then each fragmented network packet enters the protection process.
[0101] Then, enter the xfrm_output_one process, see Figure 5C The following is a schematic diagram of the xfrm_output_one process. In the xfrm_output_one process, the XFRM module needs to check whether the offload function is enabled. If not, it can return to Figure 5B The xfrm_outer_mode_output process.
[0102] In the xfrm_outer_mode_output process, the XFRM module needs to determine the output mode of the first network packet, which can be a transmission mode or a tunnel mode. If the output mode of the first network packet is the transmission mode, the forwarding process of the transmission mode is executed (corresponding to xfrm4_transport_output), and the first network packet can be IPSec-protected based on the SA information to obtain the first network packet after security protection. If the first network packet is an AH network packet, the AH network packet is sent (corresponding to ah_output). If the first network packet is an ESP network packet, the ESP network packet is sent (corresponding to esp_output).
[0103] If the output mode of the first network packet is tunnel mode, the tunnel information can be obtained (used to encapsulate the tunnel header for the first network packet, corresponding to xfrm4_prepare_output), and then the forwarding process of the tunnel mode can be executed (corresponding to xfrm4_mode_tunnel_output), and the first network packet can be IPSec-protected based on the SA information, and the tunnel information can be encapsulated for the first network packet to obtain the first network packet after security protection. If the first network packet is an AH network packet, the AH network packet is sent (corresponding to ah_output). If the first network packet is an ESP network packet, the ESP network packet is sent (corresponding to esp_output).
[0104] Step 505: The XFRM module encapsulates the SA information in the first network packet.
[0105] Step 506: The XFRM module sends the encapsulated first network packet to the PL hardware module.
[0106] For example, for the first network packet received from physical network port 0, it will go through udp_sendmsg, xfrm_lookup_route, xfrm_lookup, xfrm_output, xfrm_output_gso, xfrm_output2 and other processes, and then enter the xfrm_output_one process. In the xfrm_output_one process, the XFRM module needs to check whether the offload function is enabled. If yes, continue to see Figure 5C As shown, it is necessary to enter the type_offload->encap process. In the type_offload->encap process, the XFRM module needs to encapsulate the SA information in the first network packet to obtain the encapsulated first network packet.
[0107] See also Figure 5CAs shown, when encapsulating SA information in the first network packet, the skb_push() method can be called to expand skb->data after the ESP / AH header (ie, skb_mac_header) of the first network packet, and add SA information to skb->data, where the SA information includes symmetric key information and message authentication code key information, etc.
[0108] After obtaining the encapsulated first network packet, the XFRM module also needs to send the encapsulated first network packet to the PL hardware module. For example, the XFRM module can go through the processes such as linuxnet core_dev_queue_xmit->validate_xmit_xfrm->esp_xmit, and then be sent to the PL hardware module after being processed by the Ethernet driver function IPSec_tx. There is no restriction on this sending process.
[0109] Exemplarily, in the xfrm_output_one process, before the XFRM module checks whether the offload function is enabled, it can also perform an expiration check and a replay number setting. For example, the expiration check refers to checking whether the first network packet is expired. If so, the first network packet is discarded and the subsequent process is no longer executed. If not, it checks whether the offload function is enabled. The replay number setting refers to setting a replay number for the first network packet.
[0110] Step 507: After receiving the encapsulated first network packet, the PL hardware module parses the SA information from the encapsulated first network packet, performs IPSec security protection on the first network packet based on the SA information, obtains the protected first network packet, and sends the protected first network packet.
[0111] Exemplarily, the PL hardware module can perform IPSec security protection on the first network packet based on the SA information, and send the first network packet through the physical network port 1 to complete the protection of the first network packet.
[0112] In one possible implementation, see Figure 6 As shown, it is a structural diagram of the PL hardware module. The PS module (such as the XFRM module) can send an AXI message to the PL hardware module, such as the above-mentioned state deletion command and state addition command. The PL hardware module performs AXI protocol processing on the AXI message and parses out the message identification information and SA information. Based on the message identification information and SA information, the mapping table of the SAD module is subjected to SA addition, deletion, modification, and query operations. The process can be referred to the above-mentioned embodiment and will not be repeated here.
[0113] Except for AXI protocol processing, SA addition, deletion, modification and query, and SAD modules, the rest of the PL hardware module belongs to the functional part of the Ethernet frame processing module. For example, the receiving / transmitting module of the network frame processing module can receive the first network packet of Ethernet after encapsulation from the PS module (such as the XFRM module). The receiving / transmitting module can send the first network packet after encapsulation to the MAC parsing module based on the GMII interface.
[0114] The MAC parsing module can perform MAC parsing on the encapsulated first network packet to obtain the MAC address (MAC header) and the first inner message after the MAC address (the content after the MAC address is called the first inner message), send the first inner message to the IP parsing module, and send the MAC address to the splicing module. After the MAC parsing module performs MAC parsing on the first network packet, it can also verify the CRC value (such as CRC32 value). If the verification is successful, the first inner message is sent to the IP parsing module, and the MAC address is sent to the splicing module. If the verification fails, the first network packet is discarded.
[0115] The IP parsing module can perform IP parsing on the first inner layer message, obtain the IP address (IP header) and the second inner layer message after the IP address (the content after the IP address can be called the second inner layer message), send the second inner layer message to the algorithm module, and send the IP address to the splicing module. The IP parsing module can also determine whether the first network packet is an AH network packet or an ESP network packet. If the first network packet is an AH network packet or an ESP network packet, the second inner layer message is sent to the algorithm module. Otherwise, if the first network packet is not an AH network packet and is not an ESP network packet, the second inner layer message no longer passes through the algorithm module.
[0116] The comprehensive input of the algorithm module is the second inner layer message, and the algorithm module can perform SA analysis on the second inner layer message to obtain the SA information and the payload message behind the SA information. For example, the SA information can be located behind the IP address and in front of the payload data, so the front of the second inner layer message is the SA information, and the algorithm module can parse the SA information and the payload message behind the SA information from the second inner layer message.
[0117] If the SA information includes symmetric key information, the algorithm module can use the symmetric key information to encrypt the payload message to obtain a ciphertext payload message. For example, the symmetric key information can include a symmetric key and an encryption algorithm type. Taking the encryption algorithm type as an example, the SM4 encryption algorithm, the SM4 multi-core unit of the algorithm module can use the SM4 encryption algorithm to encrypt the payload message. When the SM4 encryption algorithm is used to encrypt the payload message, the SM4 multi-core unit can use the symmetric key to encrypt the payload message.
[0118] If the SA information includes message authentication code key information, the algorithm module can also use the message authentication code key information to calculate the message authentication code corresponding to the ciphertext payload message. For example, the message authentication code key information can include a message authentication code key and an integrity algorithm type. Taking the integrity algorithm type as an example, the SM3 integrity algorithm, the SM3 multi-core unit of the algorithm module can use the SM3 integrity algorithm to calculate the message authentication code corresponding to the ciphertext payload message. When using the SM3 integrity algorithm to calculate the message authentication code corresponding to the ciphertext payload message, the SM3 multi-core unit can use the message authentication code key to calculate the message authentication code.
[0119] The comprehensive output of the algorithm module may include a ciphertext payload message and a message authentication code, and thus the algorithm module may output the ciphertext payload message and the message authentication code to the splicing module.
[0120] In summary, the splicing module can obtain the ciphertext payload message, the message authentication code, the MAC address and the IP address. Therefore, the splicing module can splice the ciphertext payload message, the message authentication code, the MAC address and the IP address to obtain the first network packet after security protection. For example, the MAC address is located in front of the IP address, the IP address is located in front of the ciphertext payload message, and the message authentication code is located behind the ciphertext payload message.
[0121] Exemplarily, the CRC generation module can also generate a CRC result corresponding to the first network packet, and the splicing module can obtain the CRC result from the CRC generation module, and splice the ciphertext payload message, message authentication code, CRC result, MAC address and IP address to obtain the first network packet after security protection.
[0122] After obtaining the first network packet after security protection, the splicing module sends the first network packet after security protection to the GMII to RGMII module, and the GMII to RGMII module sends the first network packet out.
[0123] At this point, the sending process of the first network packet is completed, and the first network packet is successfully protected and sent.
[0124] Third, for the IPSec processing of the second network packet (the deprotection process of the second network packet), the second network packet is a data packet from physical network port 1 (non-security domain) to physical network port 0 (security domain), the second network packet is a response to the first network packet, the source IP address of the second network packet is the destination IP address of the first network packet, and the destination IP address of the second network packet is the source IP address of the first network packet. The SA information corresponding to the message identification information of the second network packet is the same as the SA information corresponding to the message identification information of the first network packet.
[0125] See also Fig. 7AFIG. 4 is a schematic diagram of the IPSec processing process for the second network packet.
[0126] Step 701: The PL hardware module receives a second network packet.
[0127] Step 702: After receiving the second network packet, the PL hardware module searches the mapping table through the message identification information of the second network packet to obtain the SA information corresponding to the message identification information.
[0128] Exemplarily, since the PL hardware module has maintained a mapping table, and the mapping table maintained by the PL hardware module is the same as the mapping table maintained by the XFRM module, after the PL hardware module obtains the SA information corresponding to the message identification information, the SA information of the deprotection process is the same as the SA information of the protection process.
[0129] For the deprotection process, the PL hardware module queries the SA information from the mapping table. For the protection process, the PL hardware module parses the SA information from the first network packet instead of querying the SA information from the mapping table. This saves the query process of the SA information and improves the processing efficiency of the network packets.
[0130] Step 703: The PL hardware module performs IPSec security protection (such as IPSec deprotection) on the second network packet based on the SA information to obtain the second network packet after security protection (ie, the deprotected second network packet).
[0131] Step 704: The PL hardware module sends the second network packet after security protection to the XFRM module.
[0132] In one possible implementation, see Figure 6 As shown in FIG. 1 , it is a schematic diagram of the structure of the PL hardware module.
[0133] PHY1 can receive an electrical signal from physical network port 1 and convert the electrical signal into an RGMII timing signal or an MDIO / MDC timing signal. The GMII to RGMII module obtains a second network packet based on the RGMII timing signal or the MDIO / MDC timing signal and sends the second network packet to the MAC parsing module.
[0134] The MAC parsing module can perform MAC parsing on the second network packet to obtain the MAC address (MAC header) and the first inner message following the MAC address (the content following the MAC address is called the first inner message), send the first inner message to the IP parsing module, and send the MAC address to the splicing module.
[0135] After the MAC parsing module performs MAC parsing on the second network packet, it can also check the CRC value (such as CRC32 value). If the check succeeds, the first inner layer message is sent to the IP parsing module, and the MAC address is sent to the splicing module. If the check fails, the second network packet is discarded.
[0136] The IP parsing module can perform IP parsing on the first inner layer message, obtain the IP address (IP header) and the second inner layer message after the IP address (the content after the IP address can be called the second inner layer message), send the second inner layer message to the algorithm module, and send the IP address to the splicing module. The IP parsing module can also determine whether the second network packet is an AH network packet or an ESP network packet. If the second network packet is an AH network packet or an ESP network packet, the second inner layer message is sent to the algorithm module. Otherwise, if the second network packet is not an AH network packet and is not an ESP network packet, the second inner layer message no longer passes through the algorithm module.
[0137] The IP resolution module performs IP resolution on the first inner layer message. After obtaining the IP address, the IP resolution module can also query the mapping table in the SAD module through the message identification information of the second network packet (that is, the IP address), obtain the SA information corresponding to the message identification information, and send the SA information to the algorithm module.
[0138] The comprehensive input of the algorithm module is the second inner layer message (i.e., the payload message) and the SA information. If the SA information includes the message authentication code key information, the algorithm module uses the message authentication code key information to calculate the message authentication code corresponding to the second inner layer message, and determines the authentication operation result of the second network packet based on the message authentication code.
[0139] For example, the message authentication code key information may include a message authentication code key and an integrity algorithm type. Taking the integrity algorithm type as the SM3 integrity algorithm as an example, the SM3 multi-core unit of the algorithm module may use the SM3 integrity algorithm to calculate the message authentication code A corresponding to the second inner message. When the SM3 integrity algorithm is used to calculate the message authentication code A, the SM3 multi-core unit may use the message authentication code key to calculate the message authentication code A. If the message authentication code A is the same as the message authentication code B carried by the second network packet, the authentication operation result of the second network packet is that the message authentication is passed. If the message authentication code A is different from the message authentication code B carried by the second network packet, the authentication operation result of the second network packet is that the message authentication is not passed.
[0140] If the SA information includes symmetric key information, the algorithm module uses the symmetric key information to decrypt the second inner layer message (i.e., the ciphertext payload message) to obtain the plaintext payload message. For example, the symmetric key information may include a symmetric key and an encryption algorithm type. For example, if the encryption algorithm type is the SM4 encryption algorithm, the SM4 multi-core unit of the algorithm module may use the decryption algorithm corresponding to the SM4 encryption algorithm to decrypt the second inner layer message. During decryption, the SM4 multi-core unit may use the symmetric key for decryption.
[0141] The comprehensive output of the algorithm module may include the plaintext payload message and the authentication operation result of the second network packet. Therefore, the algorithm module may output the plaintext payload message and the authentication operation result to the splicing module.
[0142] In summary, the splicing module obtains the plaintext payload message, the authentication operation result, the MAC address and the IP address. Therefore, the splicing module splices the plaintext payload message, the authentication operation result, the MAC address and the IP address to obtain the second network packet after security protection. For example, the MAC address is located in front of the IP address, the IP address is located in front of the authentication operation result, and the authentication operation result is located in front of the plaintext payload message. The IP address can also be located in front of the plaintext payload message, and the authentication operation result is located behind the plaintext payload message.
[0143] Exemplarily, the CRC generation module can also generate a CRC result corresponding to the second network packet, and the splicing module can obtain the CRC result from the CRC generation module, and splice the plaintext payload message, authentication operation result, CRC result, MAC address and IP address to obtain a second network packet after security protection.
[0144] The splicing module may send the second network packet after security protection to the receiving / sending module, and the receiving / sending module may send the second network packet after security protection to the PS module (such as the XFRM module).
[0145] At this point, the sending process of the second network packet is completed (ie, the second network packet is sent from the PL hardware module to the XFRM module of the PS module), and the second network packet is successfully deprotected and sent.
[0146] Step 705: The XFRM module receives the second network packet after security protection.
[0147] Step 706: The XFRM module checks whether the offload function is enabled.
[0148] Exemplarily, turning off the offload function means that the XFRM module enables IPSec security protection, that is, the XFRM module performs IPSec security protection (such as IPSec deprotection) on the second network packet based on the SA information, such as using the message authentication code key information to calculate the message authentication code, determining the authentication operation result of the second network packet based on the message authentication code, and using the symmetric key information to decrypt. This process will not be described in detail.
[0149] The offload function is enabled, indicating that the XFRM module does not enable IPSec security protection, and has enabled IPSec security protection in the PL hardware module. After the XFRM module receives the second network packet, it does not need to perform IPSec security protection on the second network packet. Based on this, if the offload function is enabled, step 707 is executed.
[0150] For example, the CRYPTO_DONE flag of the xfrm_offload structure can be set to 1, indicating that the offload function is enabled. If the CRYPTO_DONE flag is set to 0, it indicates that the offload function is disabled.
[0151] Step 707: If the second network packet is an AH network packet or an ESP network packet, the XFRM module parses the received second network packet to obtain an authentication result; wherein the authentication result may indicate that the second network packet passes the message authentication, or that the second network packet fails the message authentication.
[0152] For example, since the second network packet may include an authentication operation result, such as the authentication operation result is located in front of the plaintext payload message of the second network packet, or the authentication operation result is located behind the plaintext payload message of the second network packet, the XFRM module can parse the authentication operation result from the second network packet.
[0153] Step 708: If the authentication operation result indicates that the second network packet passes the message authentication, the XFRM module forwards the second network packet (i.e., the second network packet with the authentication operation result removed) through the physical network port (e.g., physical network port 0). Alternatively, if the authentication operation result indicates that the second network packet fails the message authentication, the XFRM module discards the second network packet, i.e., no longer forwards the second network packet through the physical network port.
[0154] In a possible implementation, the processing of the XFRM module can be found in Figure 7B shown.
[0155] After the XFRM module receives the second network packet, it enters the ip_rcv_finish process. In the ip_rcv_finish process, it is necessary to determine whether the second network packet is forwarded or uploaded on the local protocol stack. If it is forwarded, it is necessary to ensure the output network device and the address of the next receiving stack. It is also necessary to parse and process some IP options.
[0156] Enter the ip_local_deliver process and ip_local_deliver_finish process. For example, if the IP message (i.e., the second network packet) needs to be sent to the local machine according to the routing result, ip_local_deliver is called to process the message, i.e., ip_local_deliver is called to send the second network packet to the upper layer protocol. ip_local_deliver_finish indicates that the second network packet has been processed by the upper layer protocol and the processed second network packet is obtained.
[0157] Enter the ip_protocol_deliver_rcu process. In the ip_protocol_deliver_rcu process, you can use the IP protocol number to call the ip_protocol_deliver_rcu function to process the data packet.
[0158] If the second network packet is an AH network packet or an ESP network packet, the xfrm4_rcv process is entered. If the second network packet is neither an AH network packet nor an ESP network packet, the tcp_v4_rcv, udp_rcv process is entered. In the tcp_v4_rcv, udp_rcv process, the second network packet can be forwarded using the TCP protocol or the UDP protocol.
[0159] In the xfrm4_rcv process, it indicates that the IPSec packet receiving process has begun, that is, the XFRM module receives the AH network packet or the ESP network packet and starts to process the AH network packet or the ESP network packet.
[0160] Then, enter the xfrm4_rcv_spi process, in which the second network packet can be parsed to obtain the message identification information, SPI, protocol type (such as AH or ESP, etc.), and query the SA information.
[0161] Then, the xfrm_input process is entered, in which processes such as security check and decapsulation can be performed. The security check refers to the expiration check and replay number check of the second network packet. Decapsulation refers to decapsulating the second network packet and removing the identification operation result and other contents of the second network packet.
[0162] Before entering the xfrm_input process, you can also check whether the offload function is turned on. If the offload function is turned on, parse the identification operation result from the second network packet; if the identification operation result indicates that the second network packet passes the message identification, enter the xfrm_input process, otherwise, discard the second network packet.
[0163] If the offload function is not enabled, the XFRM module needs to perform IPSec security protection on the second network packet based on the SA information. In this way, after the xfrm_input process, the xfrm_state_lookup process and the __xfrm_state_lookup process can be entered. In the xfrm_state_lookup process and the __xfrm_state_lookup process, the SA information can be queried and the second network packet can be protected by IPSec based on the SA information.
[0164] If the offload function is turned on, after the xfrm_input process, the xfrm_inner_mode_input process is entered. In the xfrm_inner_mode_input process, the XFRM module needs to determine the output mode of the second network packet, which can be a transmission mode or a tunnel mode. If the output mode of the second network packet is the transmission mode, the forwarding process of the transmission mode is executed (corresponding to xfrm4_transport_input), and ip_local_deliver can be called to forward the second network packet. If the output mode of the second network packet is the tunnel mode, the tunnel information can be obtained (used to encapsulate the tunnel header for the second network packet, corresponding to xfrm_prepare_input), and then the forwarding process of the tunnel mode is executed (corresponding to xfrm_extract_header, that is, the second network packet encapsulates the tunnel header), and ip_local_deliver can be called to forward the second network packet. Obviously, after completing the XFRM process, ip_local_deliver is entered, the inner layer message is exposed, and forwarded to physical network port 0 according to the routing rules.
[0165] It can be seen from the above technical scheme that in the embodiment of the present application, the IPSec processing process is implemented through the collaboration of software and hardware, that is, the XFRM module is implemented through software, and the PL hardware module is implemented through hardware. The operation that consumes a lot of resources in the IPSec processing process (IPSec security protection of network packets based on SA information) is placed in the PL hardware module for completion, and the remaining operations are placed in the XFRM module for completion, thereby reducing the processor resources consumed by the IPSec security protection process (the XFRM module uses processor resources), saving resource overhead, and being able to use the high-performance computing of the PL hardware module to reduce the load of processor resources. By placing the computing tasks in the PL hardware module for implementation, and placing the tasks such as message format checking, anti-replay checking, and routing in the PS module (XFRM module) that is more suitable for branch processing, the stability of message delay can be improved, and the high-performance computing of the PL hardware module can be used to reduce the CPU load. It is compatible with the XFRM structure, and high-performance security message processing can be achieved with the help of the XFRM architecture. In the PL hardware module, by splicing SA information with messages, the process of finding SA information is omitted, which can save storage space, reduce processing cycles, and improve processing rate. The network card driver is modified based on the offload architecture of XFRM, and the high-performance implementation of XFRM in the kernel is used to complete protocol goals such as anti-replay and security checks.
[0166] Based on the same application concept as the above method, a network device is proposed in an embodiment of the present application, and the network device includes: an XFRM module, used to obtain message identification information and SA information corresponding to a first network packet, and record the correspondence between the message identification information and the SA information in a mapping table; the XFRM module is used to query the mapping table through the message identification information of the first network packet after receiving the first network packet, and obtain the SA information corresponding to the message identification information; encapsulate the SA information in the first network packet, and send the encapsulated first network packet to the PL hardware module; the PL hardware module is used to parse the SA information from the encapsulated first network packet after receiving the encapsulated first network packet, perform IPSec security protection on the first network packet based on the SA information, obtain the first network packet after security protection, and send the first network packet after security protection.
[0167] Exemplarily, the PL hardware module performs IPSec security protection on the first network packet based on the SA information, and when obtaining the first network packet after security protection, is specifically used to: perform MAC resolution on the first network packet to obtain a MAC address and a first inner layer message following the MAC address; perform IP resolution on the first inner layer message to obtain an IP address and a second inner layer message following the IP address;
[0168] If the first network packet is an AH network packet or an ESP network packet, perform SA parsing on the second inner layer message to obtain SA information and a payload message following the SA information; if the SA information includes symmetric key information and message authentication code key information, use the symmetric key information to encrypt the payload message to obtain a ciphertext payload message, and use the message authentication code key information to calculate a message authentication code corresponding to the ciphertext payload message; concatenate the ciphertext payload message, the message authentication code, the MAC address, and the IP address to obtain a securely protected first network packet.
[0169] Exemplarily, the XFRM module is further used to send the message identification information and the SA information to the PL hardware module; the PL hardware module is further used to record the correspondence between the message identification information and the SA information in a mapping table. The PL hardware module is further used to query the mapping table through the message identification information of the second network packet after receiving the second network packet in response to the first network packet to obtain the SA information; perform IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, and send the second network packet after security protection to the XFRM module; the XFRM module is further used to process the received second network packet.
[0170] Exemplarily, the XFRM module is also used to check whether the offload function is turned on; wherein, turning on the offload function indicates disabling IPSec security protection, and turning off the offload function indicates enabling IPSec security protection; if not, performing IPSec security protection on the first network packet based on the SA information, obtaining the first network packet after security protection, and sending the first network packet after security protection; if yes, encapsulating the SA information in the first network packet, and sending the encapsulated first network packet to the PL hardware module.
[0171] Exemplarily, the PL hardware module performs IPSec security protection on the second network packet based on the SA information, and when obtaining the second network packet after security protection, is specifically used to: perform MAC resolution on the second network packet to obtain a MAC address and a first inner layer message following the MAC address; perform IP resolution on the first inner layer message to obtain an IP address and a second inner layer message following the IP address;
[0172] If the SA information includes symmetric key information and message authentication code key information, the message authentication code key information is used to calculate the message authentication code corresponding to the second inner layer message, and the authentication operation result of the second network packet is determined based on the message authentication code; the second inner layer message is decrypted using the symmetric key information to obtain a plaintext payload message; the plaintext payload message, the authentication operation result, the MAC address and the IP address are concatenated to obtain a second network packet after security protection.
[0173] Exemplarily, when processing the received second network packet, the XFRM module is specifically used to: check whether the offload function is turned on; if so, and the second network packet is an AH network packet or an ESP network packet, parse the identification operation result from the received second network packet; the identification operation result indicates that the second network packet passes the message authentication, or the second network packet fails the message authentication; if the identification operation result indicates that the second network packet passes the message authentication, forward the second network packet through the physical network port; or, if the identification operation result indicates that the second network packet fails the message authentication, discard the second network packet.
[0174] Exemplarily, if the SA information is newly added SA information for the message identification information, the XFRM module is further used to send a state addition command to the PL hardware module, and the state addition command carries the message identification information and the newly added SA information; the PL hardware module is further used to record the correspondence between the message identification information and the newly added SA information in a mapping table based on the state addition command; or, if the SA information is updated SA information for the message identification information, the XFRM module is further used to send a state deletion command and a state addition command to the PL hardware module, and the state deletion command carries the message identification information, and the state addition command carries the message identification information and the updated SA information; the PL hardware module is further used to delete the correspondence between the message identification information and the SA information from the mapping table based on the state deletion command, and record the correspondence between the message identification information and the newly added SA information in the mapping table based on the state addition command.
[0175] Based on the same application concept as the above method, a secure communication implementation device for software and hardware collaborative encryption is proposed in the embodiment of the present application, see Figure 8 As shown, it is a schematic diagram of the structure of the device, comprising:
[0176] The XFRM module 81 is used to obtain the message identification information and SA information corresponding to the first network packet, and record the corresponding relationship between the message identification information and the SA information in a mapping table;
[0177] The XFRM module 81 is configured to query the mapping table through the message identification information of the first network packet after receiving the first network packet, and obtain the SA information corresponding to the message identification information; encapsulate the SA information in the first network packet, and send the encapsulated first network packet to the PL hardware module;
[0178] The PL hardware module 82 is used to parse the SA information from the encapsulated first network packet after receiving it, perform IPSec security protection on the first network packet based on the SA information, obtain the protected first network packet, and send the protected first network packet.
[0179] Exemplarily, the PL hardware module 82 performs IPSec security protection on the first network packet based on the SA information, and when obtaining the first network packet after security protection, is specifically used to: perform MAC resolution on the first network packet to obtain a MAC address and a first inner layer message following the MAC address; perform IP resolution on the first inner layer message to obtain an IP address and a second inner layer message following the IP address;
[0180] If the first network packet is an AH network packet or an ESP network packet, perform SA parsing on the second inner layer message to obtain SA information and a payload message following the SA information; if the SA information includes symmetric key information and message authentication code key information, use the symmetric key information to encrypt the payload message to obtain a ciphertext payload message, and use the message authentication code key information to calculate a message authentication code corresponding to the ciphertext payload message; concatenate the ciphertext payload message, the message authentication code, the MAC address, and the IP address to obtain a securely protected first network packet.
[0181] Exemplarily, the XFRM module 81 is also used to send the message identification information and the SA information to the PL hardware module; the PL hardware module 82 is also used to record the correspondence between the message identification information and the SA information in a mapping table; after receiving a second network packet in response to the first network packet, query the mapping table through the message identification information of the second network packet to obtain the SA information; perform IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, and send the second network packet after security protection to the XFRM module; the XFRM module 81 is also used to process the received second network packet.
[0182] Based on the same application concept as the above method, an electronic device is proposed in an embodiment of the present application, including: a processor and a machine-readable storage medium, wherein the machine-readable storage medium 82 stores machine-executable instructions that can be executed by the processor 81; the processor 81 is used to execute machine-executable instructions to implement the secure communication implementation method of software and hardware collaborative encryption disclosed in the above example of the present application.
[0183] Based on the same application concept as the above method, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the secure communication implementation method of software and hardware collaborative encryption in the above example of the present application can be implemented.
[0184] The above-mentioned machine-readable storage medium may be any electronic, magnetic, optical or other physical storage device, which may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.
[0185] Based on the same application concept as the above method, an embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the secure communication implementation method of the above-mentioned software and hardware collaborative encryption in the above-mentioned example of the present application.
[0186] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0187] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for implementing secure communication using software and hardware collaborative encryption, characterized in that: Applied to a network device, the network device includes an XFRM module and a PL hardware module, and the method includes: The XFRM module obtains the message identification information and the SA information corresponding to the first network packet, and records the corresponding relationship between the message identification information and the SA information in a first mapping table; the XFRM module sends the message identification information and the SA information to the PL hardware module, and the PL hardware module records the corresponding relationship between the message identification information and the SA information in a second mapping table; After receiving the first network packet, the XFRM module queries the first mapping table through the message identification information of the first network packet to obtain the SA information corresponding to the message identification information; encapsulates the SA information in the first network packet, and sends the encapsulated first network packet to the PL hardware module; After receiving the encapsulated first network packet, the PL hardware module parses the SA information from the encapsulated first network packet, performs IPSec security protection on the first network packet based on the SA information, obtains the protected first network packet, and sends the protected first network packet.
2. The method according to claim 1, characterized in that: After the XFRM module queries the first mapping table through the message identification information of the first network packet and obtains the SA information corresponding to the message identification information, the method further includes: The XFRM module checks whether the offload function is enabled; wherein, enabling the offload function means disabling IPSec security protection, and disabling the offload function means enabling IPSec security protection; If not, the XFRM module performs IPSec security protection on the first network packet based on the SA information to obtain the first network packet after security protection, and sends the first network packet after security protection; If yes, the XFRM module performs the operation of encapsulating the SA information in the first network packet and sending the encapsulated first network packet to the PL hardware module.
3. The method according to claim 1, characterized in that The PL hardware module performs IPSec security protection on the first network packet based on the SA information to obtain the first network packet after security protection, including: The PL hardware module performs MAC analysis on the first network packet to obtain a MAC address and a first inner message following the MAC address; the PL hardware module performs IP analysis on the first inner message to obtain an IP address and a second inner message following the IP address; If the first network packet is an AH network packet or an ESP network packet, the PL hardware module performs SA analysis on the second inner layer message to obtain SA information and a payload message following the SA information; If the SA information includes symmetric key information and message authentication code key information, the PL hardware module uses the symmetric key information to encrypt the payload message to obtain a ciphertext payload message, and uses the message authentication code key information to calculate a message authentication code corresponding to the ciphertext payload message; The PL hardware module concatenates the ciphertext payload message, the message authentication code, the MAC address and the IP address to obtain a first network packet after security protection.
4. The method according to claim 1, characterized in that: After the PL hardware module sends the first network packet after security protection, it also includes: After receiving the second network packet in response to the first network packet, the PL hardware module queries the second mapping table through the message identification information of the second network packet to obtain the SA information; The PL hardware module performs IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, and sends the second network packet after security protection to the XFRM module so that the XFRM module processes the received second network packet.
5. The method according to claim 4, characterized in that The PL hardware module performs IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, including: The PL hardware module performs MAC analysis on the second network packet to obtain a MAC address and a first inner layer message following the MAC address; the PL hardware module performs IP analysis on the first inner layer message to obtain an IP address and a second inner layer message following the IP address; If the SA information includes symmetric key information and message authentication code key information, the PL hardware module uses the message authentication code key information to calculate the message authentication code corresponding to the second inner layer message, and determines the authentication operation result of the second network packet based on the message authentication code; the PL hardware module uses the symmetric key information to decrypt the second inner layer message to obtain a plaintext payload message; The PL hardware module concatenates the plaintext payload message, the authentication operation result, the MAC address and the IP address to obtain a second network packet after security protection.
6. The method according to claim 5, characterized in that The XFRM module processes the received second network packet, including: The XFRM module checks whether the offload function is enabled; If yes, and the second network packet is an AH network packet or an ESP network packet, the XFRM module parses the received second network packet to obtain an authentication operation result; wherein the authentication operation result indicates that the second network packet passes the message authentication, or the second network packet fails the message authentication; If the identification operation result indicates that the second network packet passes the message identification, the XFRM module forwards the second network packet through the physical network port; or, if the identification operation result indicates that the second network packet fails the message identification, the XFRM module discards the second network packet.
7. The method according to claim 1, characterized in that The XFRM module sends the message identification information and the SA information to the PL hardware module, and the PL hardware module records the corresponding relationship between the message identification information and the SA information in a second mapping table, including: If the SA information is newly added SA information for the message identification information, the XFRM module sends a state addition command to the PL hardware module, and the state addition command carries the message identification information and the newly added SA information; the PL hardware module records the correspondence between the message identification information and the newly added SA information in the second mapping table based on the state addition command; or, If the SA information is updated SA information for the message identification information, the XFRM module sends a state deletion command and a state addition command to the PL hardware module, the state deletion command carries the message identification information, and the state addition command carries the message identification information and the updated SA information; the PL hardware module deletes the correspondence between the message identification information and the SA information from the second mapping table based on the state deletion command, and the PL hardware module records the correspondence between the message identification information and the newly added SA information in the second mapping table based on the state addition command.
8. A network device, characterized in that: The network equipment includes: The XFRM module is used to obtain the message identification information and the SA information corresponding to the first network packet, and record the corresponding relationship between the message identification information and the SA information in a first mapping table; the XFRM module is used to send the message identification information and the SA information to the PL hardware module; the PL hardware module is used to record the corresponding relationship between the message identification information and the SA information in a second mapping table; And, after receiving the first network packet, query the first mapping table through the message identification information of the first network packet to obtain the SA information corresponding to the message identification information; encapsulate the SA information in the first network packet, and send the encapsulated first network packet to the PL hardware module; The PL hardware module is used to parse the SA information from the encapsulated first network packet after receiving it, perform IPSec security protection on the first network packet based on the SA information, obtain the first network packet after security protection, and send the first network packet after security protection.
9. The network device according to claim 8, characterized in that: The PL hardware module performs IPSec security protection on the first network packet based on the SA information, and when the first network packet after security protection is obtained, it is specifically used to: perform MAC resolution on the first network packet to obtain a MAC address and a first inner layer message following the MAC address; perform IP resolution on the first inner layer message to obtain an IP address and a second inner layer message following the IP address; If the first network packet is an AH network packet or an ESP network packet, SA parsing is performed on the second inner layer message to obtain SA information and a payload message following the SA information; if the SA information includes symmetric key information and message authentication code key information, the payload message is encrypted using the symmetric key information to obtain a ciphertext payload message, and the message authentication code key information is used to calculate a message authentication code corresponding to the ciphertext payload message; The ciphertext payload message, the message authentication code, the MAC address and the IP address are concatenated to obtain a first network packet after security protection.
10. The network device according to claim 8, characterized in that: The PL hardware module is further configured to query the second mapping table through message identification information of the second network packet to obtain the SA information after receiving the second network packet in response to the first network packet; Perform IPSec security protection on the second network packet based on the SA information to obtain the second network packet after security protection, and send the second network packet after security protection to the XFRM module; The XFRM module is also used to process the received second network packet.
Citation Information
Cited By
Secure communication implementation method with software and hardware collaborative encryption and network device
US12603870B2
