New high-speed encryption and decryption system and method based on FPGA offloading
By using FPGA-based encryption and decryption methods in the server cipher machine, the high-speed service flow to FPGA processing is solved, and the problems of large network communication overhead and high latency in the prior art are realized, and a high-performance and low-latency encryption and decryption system is applicable. for high-performance network services.
Patent Information
- Application Number
- CN202411070070.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-06
AI Technical Summary
The existing server password machines communicate through the TCP protocol, resulting in large overhead and high latency of network communication, making it difficult to realize high-performance password services, and it is difficult to meet the needs of more than 10,000 gps of processing capabilities, low power consumption, small size and high performance at the same time.
The encryption and decryption method based on FPGA is adopted to uninstall the service startup, operation and termination process, and use FPGA to process high-speed service flows, reduce dependence on the service CPU, and improve network data throughput performance.
It reduces hardware costs and delays, improves performance, achieves higher network data throughput under the same hardware conditions, adapts to 100M~400G network service performance, and enhances system security.
Smart Images

Figure CN118590327B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information encryption, and in particular to a novel high-speed encryption and decryption system and method based on FPGA offloading. Background Art
[0002] like Figure 1 As shown in the figure, the existing server cryptographic machine implementation scheme mainly includes a server cryptographic machine and a client host, and the server cryptographic machine and the client host exchange data through the network. The server cryptographic machine consists of a network communication platform and a cryptographic card, which are connected through a PCIE hardware interface. The network communication platform handles network data transmission between the client host, and the cryptographic card accelerates various cryptographic operations. The client host software is encapsulated as an interface library, compiled together with the upper-layer application, providing a callable function interface for the upper-layer application, shielding the underlying network communication details.
[0003] The services provided by the server cryptographic machine generally include the following: symmetric algorithm, hash algorithm, asymmetric algorithm and object management. Among them, the performance requirements of symmetric algorithm and hash algorithm are relatively high, belonging to high-speed business flow, and the performance is limited by the network communication overhead; the asymmetric algorithm and object management function have relatively low requirements for network communication, belonging to low-speed business flow, and the performance is limited by the computing power of the cryptographic card and the business CPU processing power.
[0004] The low-speed and high-speed process processing methods of the existing server cryptographic machine are the same, and the execution process is as follows:
[0005] The client application calls the interface library, encapsulates the network communication request through the TCP protocol, and sends it to the server cryptographic machine; the server cryptographic machine receives the TCP message, parses the client application request, distinguishes the service type, and completes the preprocessing; the server cryptographic machine calls the local cryptographic module through the PCIE interface, performs the operation, and generates the operation result; the server cryptographic machine encapsulates the response result and sends the result to the client host through the TCP protocol; the client application receives the response returned by the server cryptographic machine through the interface library and obtains the operation result.
[0006] From the above, we can see that the existing server cryptographic machines communicate through the TCP protocol, which has the following problems: large network communication overhead and high latency; processing performance depends on the processing power of the business CPU, making it difficult to achieve high-performance cryptographic service applications, and the performance of existing domestic CPUs is difficult to meet the processing power requirements of more than 10 Gigabits; limited by the capabilities of the business CPU, it is difficult to simultaneously meet the requirements of low power consumption, small size and high performance. Summary of the invention
[0007] In view of the above problems, the present invention proposes a new high-speed encryption and decryption system and method based on FPGA offloading.
[0008] To achieve the purpose of the present invention, an encryption and decryption method based on FPGA offloading is provided, wherein the encryption and decryption method comprises: an offloading service startup process, an offloading service operation process and an offloading service termination process.
[0009] For the symmetric algorithm and the hash algorithm, the operation process includes three stages: the uninstall service startup process (initial), the uninstall service operation process (update) and the uninstall service termination process (final).
[0010] The uninstall service startup process includes the following steps:
[0011] S1: The client host sends an initial request message for offloading services to the server cryptographic machine through the TCP protocol;
[0012] S2: The external network interface module of the server cryptographic machine receives the initial request message of the offloading service through the network, and sends it to the service diversion module;
[0013] S3: the service diversion module identifies and obtains the initial type of the unloaded service based on the initial request message of the unloaded service, and then determines the current forwarding path based on the initial type of the unloaded service and sends the initial request message of the unloaded service to the internal network interface module;
[0014] S4: The internal network interface module receives the initial request message of the offload service and sends it to the backend service processing module;
[0015] S5: The backend service processing module first parses the initial request message of the offload service and obtains the specific type of the initial service; then creates the context of the computing session based on the specific type of the initial service, and allocates a session ID as a resource index for the created context of the computing session; then allocates a UDP port for subsequent update operations of the context of the computing session to construct a five-tuple diversion basis; finally, encapsulates the service configuration command and the diversion configuration command based on the context of the computing session, the resource index and the five-tuple diversion basis, and sends the encapsulated service configuration command and the diversion configuration command to the configuration management module;
[0016] S6: The configuration management module parses the service configuration command, and creates a cryptographic operation context based on the session ID in the high-speed service module based on the parsing result of the service configuration command; the configuration management module parses the diversion configuration command, and creates a diversion strategy quintuple of the context subsequent update message of the operation session in the service diversion module based on the parsing result of the diversion configuration command; the configuration management module sends the service configuration command and the execution result of the diversion configuration command to the back-end service processing module;
[0017] S7: The backend service processing module encapsulates an inital service response message based on the execution results of the service configuration command and the diversion configuration command, and sends the inital service response message to the internal network interface module;
[0018] S8: The internal network interface module receives the inital service response message and sends it to the service diversion module;
[0019] S9: The service distribution module receives the inital service response message and sends it to the external network interface module;
[0020] S10: The external network interface module receives the inital service response message and sends it to the client host through the network, so that the establishment of the cryptographic service session based on the session ID between the client host and the server cryptographic machine is completed;
[0021] The uninstallation service operation process includes the following steps:
[0022] S11: The client host sends an update message of cryptographic operation to the server cryptographic machine;
[0023] S12: The external network interface module of the server cryptographic machine receives the update message of the cryptographic operation through the network, and sends it to the service diversion module;
[0024] S13: the service diversion module performs message filtering on the update message of the cryptographic operation based on the diversion strategy quintuple of the update message, and obtains the message matching the diversion strategy; and then sends the message matching the diversion strategy to the high-speed service module;
[0025] S14: The high-speed service module matches the corresponding cryptographic operation context based on the session ID in the message matching the diversion strategy; then performs flow control based on the matched cryptographic operation context; then sends the cryptographic operation request to the cryptographic operation module based on the matched cryptographic operation context; finally, updates the data of the cryptographic operation context based on the flow control information;
[0026] S15: the cryptographic operation module performs an operation based on the cryptographic operation request, generates an operation result, and then sends the operation result to the high-speed service module;
[0027] S16: the high-speed service module updates the cryptographic operation context based on the operation result; then constructs an update response result message based on the updated cryptographic operation context; and finally sends the update response result message to the service diversion module;
[0028] S17: the service distribution module performs an aggregation process based on the update response result message, and then sends the aggregated update response result message to the external network interface module;
[0029] S18: the external network interface module sends the aggregated update response result message to the client host through the network; the interface library of the client host obtains the operation result based on the aggregated update response result message, and then sends the operation result to the client application, and updates the context of the local cryptographic operation session of the client host;
[0030] The uninstall service termination process includes the following steps:
[0031] S19: The client host sends a final request message for uninstalling the service to the server cryptographic machine;
[0032] S20: The external network interface module of the server cryptographic machine receives the final request message of the offload service through the network, and sends it to the service diversion module;
[0033] S21: the service diversion module identifies and obtains the final type of the unloaded service based on the final request message of the unloaded service, and then determines the current forwarding path based on the final type of the unloaded service and sends the final request message of the unloaded service to the internal network interface module;
[0034] S22: The internal network interface module receives the final request message of the offload service and sends it to the backend service processing module;
[0035] S23: The backend service processing module first parses the final request message of the offload service and obtains the session ID carried in the final request message of the offload service; then searches and obtains the corresponding cryptographic operation context based on the session ID carried in the final request message of the offload service; finally, encapsulates the service resource release command and the diversion strategy release command based on the corresponding cryptographic operation context, and sends the encapsulated service resource release command and the diversion strategy release command to the configuration management module;
[0036] S24: the configuration management module parses the service resource release command, and executes the service resource release operation based on the parsing result of the service resource release command, and at the same time clears the cryptographic operation context corresponding to the session ID in the high-speed service module; the configuration management module parses the diversion strategy release command, and releases the diversion strategy quintuple of the update message in the service diversion module based on the parsing result of the diversion strategy release command; the configuration management module sends the service resource release command and the execution result of the diversion strategy release command to the back-end service processing module;
[0037] S25: The backend service processing module encapsulates a final service response message based on the execution results of the service resource release command and the diversion strategy release command, and sends the final service response message to the internal network interface module;
[0038] S26: The internal network interface module receives the final service response message and sends it to the service distribution module;
[0039] S27: The service distribution module receives the final service response message and sends it to the external network interface module;
[0040] S28: The external network interface module receives the final service response message and sends it to the client host through the network; the interface library of the client host receives the final service response message and returns the execution result to the client application.
[0041] Furthermore, the encryption and decryption method also includes: Ethernet Layer 2 protocol and network control protocol processing flow; Ethernet Layer 2 protocol and network control protocol processing flow is generally used to process Ethernet Layer 2 protocol and network control protocol, such as ARP, RARP, ICMP and other protocols.
[0042] The Ethernet Layer 2 protocol and network control protocol processing flow includes the following steps:
[0043] A1: The external network interface module receives input messages from the external network;
[0044] A2: The external network interface module sends the input message to the service distribution module, and the service distribution module identifies and obtains the Ethernet layer 2 protocol and the network control class protocol based on the input message, and then sends them to the internal network interface module;
[0045] A3: The internal network interface module receives the Ethernet layer 2 protocol and the network control protocol, and sends them to the back-end service processing module;
[0046] A4: The back-end service processing module receives the Ethernet layer 2 protocol and the network control protocol, and sends them to the internal network interface module;
[0047] A5: The internal network interface module receives the Ethernet layer 2 protocol and the network control protocol, and sends them to the service distribution module;
[0048] A6: The service distribution module receives the Ethernet layer 2 protocol and the network control protocol, and performs message aggregation based on the Ethernet layer 2 protocol and the network control protocol to obtain an aggregated protocol message, and then sends the aggregated protocol message to the external network interface module;
[0049] A7: The external network interface module receives the aggregated protocol message and sends it to the external network.
[0050] Furthermore, the encryption and decryption method also includes: a normal business processing flow; for asymmetric algorithms and object management services, the server cryptographic machine executes the normal business processing flow.
[0051] The general business processing flow includes the following steps:
[0052] B1: The external network interface module receives a common service request message sent by the client host through the network;
[0053] B2: the external network interface module sends the common service request message to the service distribution module;
[0054] B3: The service distribution module receives the common service request message and sends it to the internal network interface module;
[0055] B4: The internal network interface module receives the common service request message and sends it to the back-end service processing module;
[0056] B5: The backend business processing module parses the common business request message and obtains the common business type, then encapsulates the cryptographic operation request or object management operation of the common business based on the common business type, and then sends the cryptographic operation request or object management operation of the common business to the cryptographic operation module;
[0057] B6: The cryptographic operation module completes the corresponding cryptographic operation or object management operation based on the cryptographic operation request or object management operation of the common service, and sends the execution result of the cryptographic operation or object management operation to the back-end service processing module;
[0058] B7: The backend business processing module encapsulates a common business response message based on the execution result of the cryptographic operation or the object management operation, and sends the common business response message to the internal network interface module;
[0059] B8: The internal network interface module receives the common service response message and sends it to the service distribution module;
[0060] B9: the service distribution module receives the common service response message, aggregates the messages based on the common service response message, obtains an aggregated common service response message, and then sends the aggregated common service response message to the external network interface module;
[0061] B10: The external network interface module receives the aggregated common service response message and sends it to the client host through the network.
[0062] Furthermore, the encryption and decryption method further includes: uninstalling the abnormal termination processing flow of the service;
[0063] The abnormal termination process of the uninstall service includes the following steps:
[0064] C1: The backend business processing module detects that an abnormality occurs in the TCP socket established by the offload business startup process, and searches for the cryptographic operation context corresponding to the session ID of the TCP socket; then encapsulates the business resource release command and the diversion strategy release command based on the corresponding cryptographic operation context, and sends the encapsulated business resource release command and the diversion strategy release command to the configuration management module;
[0065] C2: The configuration management module parses the service resource release command, and performs a service resource release operation based on the parsing result of the service resource release command, and at the same time clears the cryptographic operation context corresponding to the session ID in the high-speed service module; the configuration management module parses the diversion strategy release command, and releases the diversion strategy quintuple of the update message in the service diversion module based on the parsing result of the diversion strategy release command; the back-end service processing module releases the cryptographic operation session resources;
[0066] C3: The client application on the client host detects an exception and calls the interface library to release the local cryptographic operation session resources of the client host.
[0067] Furthermore, the cryptographic operation module is selected as an independent component or integrated into the high-speed service module.
[0068] The present invention also provides an encryption and decryption system based on FPGA offloading, which adopts an encryption and decryption method based on FPGA offloading, including: the client host and the server cryptographic machine;
[0069] The client host includes: the interface library and the client application;
[0070] The interface library includes: an interface layer, a control layer and a communication layer;
[0071] The interface layer is used to provide a callable function interface for the client application; the control layer is used to implement the reliability guarantee of data communication; the communication layer is used to implement network communication details;
[0072] The server cryptographic machine includes: a service CPU and a front-end FPGA;
[0073] The business CPU includes: the back-end business processing module;
[0074] The front FPGA includes: the configuration management module, the internal network interface module, the service diversion module, the external network interface module, the cryptographic operation module and the high-speed service module;
[0075] The configuration management module is used to parse the configuration management message and complete the configuration operation, and then generate a corresponding response message according to the result of the configuration operation;
[0076] The internal network interface module is used to forward the service data sent by the service distribution module to the back-end service processing module, or forward the message data returned by the back-end service processing module to the service distribution module;
[0077] The business diversion module is used to receive data messages output by other modules through a custom bus;
[0078] The external network interface module is used to receive external input data messages through the network, or send out the response message data sent by the business diversion module through the network;
[0079] The cryptographic operation module is used to perform cryptographic operations;
[0080] The high-speed service module is used to process high-speed service messages and generate data messages containing processing results and send them out;
[0081] The back-end business processing module is used to pre-process the input business request message and generate a cryptographic operation request.
[0082] Furthermore, the encryption and decryption system based on FPGA offloading further includes: an expansion storage module;
[0083] The expansion storage module is used to expand the storage space of the front FPGA.
[0084] The present invention also provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute an encryption and decryption method based on FPGA offloading.
[0085] Compared with the prior art, the present invention has the following beneficial technical effects:
[0086] Low cost: reduces hardware requirements, saves the high-performance network processing CPU, its peripheral circuits and high-performance network cards required by the front end, and saves hardware costs. Low latency: the present invention uses FPGA to offload business flows with high performance requirements and high load ratios, and passes ordinary business flows and other data flows to the business CPU, which has lower latency than traditional solutions. Higher performance under the same hardware conditions: under the same hardware capabilities, network data transmission and reception that relies on the CPU to process all services is prone to performance bottlenecks, while FPGA can always perform network data throughput at a performance close to the hardware interface line speed. Architecture scalability: with extremely high design flexibility, the system architecture can adapt to network service performance between 100M and 400G by simply adjusting the degree of parallelism, while traditional cryptographic service processing architectures cannot effectively perform above 10G.
[0087] High security: The present invention flexibly uses FPGA-based traffic unloading, which not only increases processing efficiency and greatly reduces CPU load, but also uses hardware firewalls to improve system security, achieving a rare combination of security and efficiency. The front-end FPGA hardware firewall design reduces the risk of the CPU and operating system being directly exposed to attacks on the network. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 It is a flow chart of the technical solution of the server cipher machine of the prior art;
[0089] Figure 2 The present invention is a schematic diagram of the process of starting an unloading service of an encryption and decryption method based on FPGA unloading according to an embodiment;
[0090] Figure 3 The diagram is a schematic diagram of the unloading service operation flow of the encryption and decryption method based on FPGA unloading according to an embodiment;
[0091] Figure 4 The present invention is a schematic diagram of the process of terminating the unloading service of the encryption and decryption method based on FPGA unloading according to an embodiment;
[0092] Figure 5 The present invention is a schematic diagram of the Ethernet layer 2 protocol and network control protocol processing flow of the encryption and decryption method based on FPGA offloading according to an embodiment;
[0093] Figure 6 is a schematic diagram of a common business processing flow of an encryption and decryption method based on FPGA offloading according to an embodiment;
[0094] Figure 7 is a flowchart of abnormal termination of unloading service of an encryption and decryption method based on FPGA unloading according to an embodiment;
[0095] Figure 8 is a module schematic diagram of an encryption and decryption system based on FPGA offloading according to an embodiment;
[0096] Fig. 9 is a schematic diagram of the structure of an external network interface module of an embodiment;
[0097] Fig.10 is a schematic diagram of the structure of a business diversion module of an embodiment;
[0098] Fig.11 is a schematic diagram of a message diversion service process of an embodiment;
[0099] Fig.12 is a schematic diagram of the structure of a high-speed service processing module of an embodiment;
[0100] Fig.13 is a schematic diagram of an implementation flow of business scheduling according to an embodiment;
[0101] Fig.14 is a schematic diagram of the implementation process of the back-end business module of an embodiment;
[0102] Fig.15 is a schematic diagram of an uninstall service startup process and a termination process of an embodiment;
[0103] Fig.16 is a schematic diagram of the structure of an internal network interface module of an embodiment;
[0104] Fig.17 is a schematic diagram of the configuration management module structure of an embodiment;
[0105] Fig.18 The diagram is a flow control mechanism diagram of an embodiment. DETAILED DESCRIPTION
[0106] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0107] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0108] The server cryptographic machine provides cryptographic service calls for client hosts in the local area network through network access. The data input through the external network can be divided into three categories: Ethernet layer 2 protocol and network control protocol, common services and offload services.
[0109] The encryption and decryption method based on FPGA offloading, when processing offloading services, the encryption and decryption method includes: offloading service startup process, offloading service operation process and offloading service termination process;
[0110] In one embodiment, Figure 2 As shown, the uninstall service startup process includes the following steps:
[0111] S1: The client host sends an initial request message of the unloading service to the server cryptographic machine through the TCP protocol; S2: The external network interface module of the server cryptographic machine receives the initial request message of the unloading service through the network and sends it to the service diversion module; S3: The service diversion module identifies and obtains the initial type of the unloading service based on the initial request message of the unloading service, and then determines the current forwarding path based on the initial type of the unloading service and sends the initial request message of the unloading service to the internal network interface module; S4: The internal network interface module receives the initial request message of the unloading service ial request message, and sends it to the back-end business processing module; S5: the back-end business processing module first parses the initial request message of the offload business and obtains the specific type of the initial business; then creates the context of the computing session based on the specific type of the initial business, and assigns a session ID as a resource index to the created context of the computing session; then assigns a udp port for subsequent update operations of the context of the computing session to construct a five-tuple diversion basis; finally, based on the context of the computing session, the resource index and the five-tuple diversion basis, encapsulates the business configuration command and the diversion configuration command, and sends the encapsulated business The configuration management module sends the service configuration command and the diversion configuration command to the configuration management module; S6: the configuration management module parses the service configuration command, and creates a cryptographic operation context based on the session ID in the high-speed service module based on the parsing result of the service configuration command; the configuration management module parses the diversion configuration command, and creates a diversion strategy quintuple of subsequent update messages of the context of the operation session in the service diversion module based on the parsing result of the diversion configuration command; the configuration management module sends the execution result of the service configuration command and the diversion configuration command to the back-end service processing module; S7: the back-end service processing module creates a cryptographic operation context based on the service configuration command and the diversion strategy quintuple of subsequent update messages of the context of the operation session in the service diversion module based on the parsing result of the diversion configuration command The execution result of the flow configuration command encapsulates the inital service response message and sends the inital service response message to the internal network interface module; S8: the internal network interface module receives the inital service response message and sends it to the service diversion module; S9: the service diversion module receives the inital service response message and sends it to the external network interface module; S10: the external network interface module receives the inital service response message and sends it to the client host through the network, so far, the establishment of the cryptographic service session based on the session ID between the client host and the server cryptographic machine is completed;
[0112] like Figure 3 As shown, the uninstallation service operation process includes the following steps:
[0113] S11: The client host sends an update message of the cryptographic operation to the server cryptographic machine; S12: The external network interface module of the server cryptographic machine receives the update message of the cryptographic operation through the network and sends it to the business diversion module; S13: The business diversion module filters the update message of the cryptographic operation based on the diversion strategy quintuple of the update message, and obtains the message matching the diversion strategy; then sends the message matching the diversion strategy to the high-speed business module; S14: The high-speed business module matches the corresponding cryptographic operation context based on the session ID in the message matching the diversion strategy; then performs flow control based on the matched cryptographic operation context; then sends the request for the cryptographic operation to the cryptographic operation module based on the matched cryptographic operation context; finally, updates the data of the cryptographic operation context based on the flow control information; S15: The cryptographic operation module The cryptographic operation request executes the operation and generates the operation result, and then sends the operation result to the high-speed business module; S16: the high-speed business module updates the cryptographic operation context based on the operation result; then constructs an update response result message based on the updated cryptographic operation context; finally, sends the update response result message to the business diversion module; S17: the business diversion module executes the aggregation process based on the update response result message, and then sends the aggregated update response result message to the external network interface module; S18: the external network interface module sends the aggregated update response result message to the client host through the network; the interface library of the client host obtains the operation result based on the aggregated update response result message, and then sends the operation result to the client application, and updates the context of the local cryptographic operation session of the client host;
[0114] like Figure 4 As shown, the uninstall service termination process includes the following steps:
[0115] S19: The client host sends a final request message for offloading services to the server cryptographic machine; this operation is based on the connection established by the TCP protocol during the initial process, and the final request message for offloading services sent contains a session ID. S20: The external network interface module of the server cryptographic machine receives the final request message through the network and sends it to the service diversion module; S21: The service diversion module identifies and obtains the final type of the unloading service based on the final request message of the unloading service, and then determines the current forwarding path based on the final type of the unloading service and sends the final request message of the unloading service to the internal network interface module; S22: The internal network interface module receives the final request message of the unloading service and sends it to the back-end service processing module; S23: The back-end service processing module first parses the final request message of the unloading service and obtains the session ID carried in the final request message of the unloading service; then searches and obtains the corresponding cryptographic operation context based on the session ID carried in the final request message of the unloading service; finally, encapsulates the service resource release command and the diversion strategy release command based on the corresponding cryptographic operation context, and sends the encapsulated service resource release command and the diversion strategy release command to the configuration management module; S24: The configuration management module parses the service resource release command, and based on the service resource The parsed result of the release command executes the business resource release operation, and at the same time clears the cryptographic operation context of the corresponding session ID in the high-speed business module; the configuration management module parses the diversion strategy release command, and releases the diversion strategy quintuple of the update message in the business diversion module based on the parsed result of the diversion strategy release command; the configuration management module sends the execution results of the business resource release command and the diversion strategy release command to the back-end business processing module; S25: the back-end business processing module encapsulates the final business response message based on the execution results of the business resource release command and the diversion strategy release command, and sends the final business response message to the internal network interface module; S26: the internal network interface module receives the final business response message and sends it to the business diversion module; S27: the business diversion module receives the final business response message and sends it to the external network interface module; S28: the external network interface module receives the final business response message and sends it to the client host through the network; the interface library of the client host receives the final business response message and returns the execution result to the client application. Moreover, at this time, both the client application and the server cryptographic machine successfully release the resources corresponding to the current cryptographic service session.
[0116] In one embodiment, when processing Ethernet layer 2 protocols and network control protocols, such as Figure 5 As shown, the encryption and decryption method also includes: Ethernet layer 2 protocol and network control protocol processing flow;
[0117] The Ethernet Layer 2 protocol and network control protocol processing flow includes the following steps:
[0118] A1: The external network interface module receives input messages from the external network; A2: The external network interface module sends the input messages to the service diversion module, and the service diversion module identifies and obtains the Ethernet Layer 2 protocol and the network control class protocol based on the input messages, and then sends them to the internal network interface module; A3: The internal network interface module receives the Ethernet Layer 2 protocol and the network control class protocol, and sends them to the back-end service processing module; A4: The back-end service processing module receives the Ethernet Layer 2 protocol and the network control class protocol, and sends them to the internal network interface module; A5: The internal network interface module receives the Ethernet Layer 2 protocol and the network control class protocol, and sends them to the service diversion module; A6: The service diversion module receives the Ethernet Layer 2 protocol and the network control class protocol, and performs message aggregation based on the Ethernet Layer 2 protocol and the network control class protocol to obtain the aggregated protocol message, and then sends the aggregated protocol message to the external network interface module; A7: The external network interface module receives the aggregated protocol message, and sends it to the external network.
[0119] In one embodiment, when processing ordinary business, such as Figure 6 As shown, the encryption and decryption method also includes: a common business processing flow;
[0120] The general business processing flow includes the following steps:
[0121] B1: The external network interface module receives the common service request message sent by the client host through the network; B2: The external network interface module sends the common service request message to the service diversion module; B3: The service diversion module receives the common service request message and sends it to the internal network interface module; B4: The internal network interface module receives the common service request message and sends it to the back-end service processing module; B5: The back-end service processing module parses the common service request message and obtains the common service type based on the common service request message, and then encapsulates the cryptographic operation request or object management operation of the common service based on the common service type, and then sends the cryptographic operation request or object management operation of the common service to the cryptographic operation module; B6: The cryptographic operation module completes the corresponding A cryptographic operation or object management operation, and sends the execution result of the cryptographic operation or object management operation to the back-end business processing module; B7: the back-end business processing module encapsulates the ordinary business response message based on the execution result of the cryptographic operation or object management operation, and sends the ordinary business response message to the internal network interface module; B8: the internal network interface module accepts the ordinary business response message, and sends it to the business diversion module; B9: the business diversion module accepts the ordinary business response message, and performs message aggregation based on the ordinary business response message to obtain the aggregated ordinary business response message, and then sends the aggregated ordinary business response message to the external network interface module; B10: the external network interface module accepts the aggregated ordinary business response message, and sends it to the client host through the network.
[0122] In one embodiment, Figure 7 As shown, the encryption and decryption method also includes: uninstalling the abnormal termination processing flow of the service;
[0123] The abnormal termination process of the uninstall service includes the following steps:
[0124] C1: The back-end business processing module detects that an abnormality occurs in the TCP socket established by the unloading business startup process, and searches for the cryptographic operation context corresponding to the session ID of the TCP socket; then encapsulates the business resource release command and the diversion strategy release command based on the corresponding cryptographic operation context, and sends the encapsulated business resource release command and the diversion strategy release command to the configuration management module; C2: The configuration management module parses the business resource release command, and performs a business resource release operation based on the parsing result of the business resource release command, and at the same time clears the cryptographic operation context of the corresponding session ID in the high-speed business module; the configuration management module parses the diversion strategy release command, and releases the diversion strategy quintuple of the update message in the business diversion module based on the parsing result of the diversion strategy release command; the back-end business processing module releases the cryptographic operation session resources; C3: The client application on the client host detects an abnormality and calls the interface library to release the local cryptographic operation session resources of the client host.
[0125] In one embodiment, the cryptographic operation module is selected as an independent component or integrated into the high-speed service module.
[0126] like Figure 8 As shown, the encryption and decryption system based on FPGA offloading includes: the client host and the server cryptographic machine;
[0127] The client host includes: the interface library and the client application; the interface library includes: an interface layer, a control layer and a communication layer; the interface layer is used to provide a callable function interface for the client application; the control layer is used to realize the reliability of data communication; the communication layer is used to realize the network communication details; the server cryptographic machine includes: a business CPU and a front-end FPGA; the business CPU includes: the back-end business processing module; the front-end FPGA includes: the configuration management module, the internal network interface module, the business diversion module, the external network interface module, the cryptographic operation module and the high-speed business module; the configuration management module is used to parse the configuration management message and complete the configuration operation, and then generate the corresponding reply message; the internal network interface module is used to forward the business data sent by the business diversion module to the back-end business processing module, or forward the message data returned by the back-end business processing module to the business diversion module; the business diversion module is used to receive data messages output by other modules through a custom bus; the external network interface module is used to receive external input data messages through the network, or send the reply message data sent by the business diversion module through the network; the cryptographic operation module is used to perform cryptographic operations; the high-speed business module is used to process high-speed business messages, and generate data messages containing processing results and send them out; the back-end business processing module is used to pre-process the input business request messages, and generate cryptographic operation requests.
[0128] In one embodiment, the FPGA offloading-based encryption and decryption system further includes: an expansion storage module;
[0129] The expansion storage module is used to expand the storage space of the front FPGA. According to the design requirements, the cryptographic operation module can be an independent component or integrated into the high-speed service module; if the system requires too many concurrent connections and the front FPGA chip storage space is insufficient, an expansion storage module can be designed.
[0130] An embodiment of the present application further provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the encryption and decryption method based on FPGA offloading.
[0131] In one embodiment, data interaction between the client host and the server cryptographic machine:
[0132] The data interaction between the client host and the server cryptographic machine is the data interaction between the interface library and the external network interface module. The interface library acts as a communication agent and runs on the client host along with the client application. The communication layer implements network communication functions and provides network communication services for the upper layer. The control layer implements transmission control and provides reliable transmission functions for the upper layer. The interface layer implements business parameter parsing and data encapsulation, and provides a callable function interface for external client applications.
[0133] The difference between the interface library in this solution and the traditional interface library is that a control layer is added. The reason is that the network communication of the traditional solution is based on the TCP protocol, which itself has reliable transmission capabilities, while the communication of this solution uses both TCP and UDP protocols. The UDP protocol carries the unloaded business flow, which requires reliable transmission control in the interface library.
[0134] The client application calls the function in the interface library, and the cryptographic service request is converted into the sending of network data messages inside the interface library. The data messages are sent to the external network interface module of the server cryptographic machine through the network. After the server cryptographic machine performs the calculation, it encapsulates the response result into a network data message and sends it back to the client host. The data passes through the communication layer, control layer and interface layer in turn and returns to the client application.
[0135] Data interaction between the business diversion module and the external network interface module:
[0136] Input direction: The external network interface module receives the data packets input by the network interface and sends them to the business diversion module through the internal custom bus.
[0137] Output direction: The business diversion module receives the data packets output by other modules and sends them to the external network interface module through the internal custom bus.
[0138] Data interaction between the internal network interface module and the business diversion module:
[0139] Input direction: The business diversion module diverts the input data. The business data that needs to be forwarded to the back-end business processing module (business that is not offloaded and accelerated) is sent to the internal network interface module through the internal custom bus.
[0140] Output direction: The internal network interface module receives the data packets output by the back-end business processing module (including the output results of the business logic of the back-end business processing module and the protocol stack network control packets), and sends them to the business diversion module through the internal custom bus.
[0141] Data interaction between the high-speed service module and the service diversion module:
[0142] Input direction: The business diversion module diverts the input data, and the business data flow that needs to be unloaded by high-speed business is sent to the high-speed business module through the internal custom bus.
[0143] Output direction: After the high-speed business processing module completes the processing of the high-speed business message, it generates a data message containing the processing result, and sends it to the business diversion module through the internal custom bus, and the business diversion module continues to forward it to the customer host.
[0144] Data interaction between the cryptographic operation module and the high-speed business module:
[0145] Input direction: After preprocessing the input service request message, the high-speed service processing module generates a cryptographic operation request, and sends the operation request to the cryptographic operation module according to the interface defined by the cryptographic operation module.
[0146] Output direction: The cryptographic operation module completes the input cryptographic operation request, generates the cryptographic operation result, follows the interface defined by the cryptographic operation module, and sends the operation result to the high-speed business module.
[0147] Data interaction between the extended storage module and the high-speed business module:
[0148] Input direction: When the high-speed service processing module processes the input service request message, it needs to record the context information of the current session. If the storage space on the chip is insufficient, the session context information is stored in the extended storage module.
[0149] Output direction: When the high-speed service processing module processes the input service request message, it needs to read the context information of the current session. If the context information is stored in the extended storage module, it needs to read the context information from the extended storage module.
[0150] Data interaction between the back-end business processing module and the internal network interface module:
[0151] Input direction: The internal network interface module accepts the business flow that does not need to be unloaded, and sends the business message to the back-end business processing module through the network interface.
[0152] Output direction: The back-end business processing module completes business processing (non-offload business), generates a response message, sends it to the internal network interface module through the network interface, and the internal network interface module forwards it to the client host.
[0153] Data interaction between the configuration management module and the backend business processing module:
[0154] The backend business processing module, as the main control logic, initiates the configuration management business, generates the configuration management message, and sends it to the configuration management module for configuration implementation.
[0155] The configuration management module parses the configuration management message, completes the configuration operation, generates a response message based on the operation result, and sends it to the back-end business processing module.
[0156] Data interaction between the configuration management module and the business diversion module: The configuration management module writes the data diversion strategy into the business diversion module through a custom interface.
[0157] Data interaction between the configuration management module and the high-speed business module: The configuration management module writes the parameters, keys, IVs and other resources required for cryptographic operations into the high-speed business module through a custom interface.
[0158] In one embodiment, the external network interface module implements the sending and receiving of data frames between the external Ethernet. Its specific functions are as follows: Fig. 9 As shown in the figure, the Ethernet PCS / PMA IP core provided by the FPGA manufacturer can be used as the PHY connected to the MAC, and the IP core can be constrained to the optical module to build a complete physical layer. The MAC (Media Access Control) layer is responsible for handling the physical transmission and reception of data. When the MAC layer receives a data frame from the network, it needs to perform a series of processing, including verification, decapsulation, etc., and then pass the data to the upper-layer service diversion module. In this process, in order to process the received data, a FIFO (First In, First Out) queue is used to temporarily store the data.
[0159] The following is the process of MAC receiving data to FIFO:
[0160] Data reception: The MAC layer receives data frames from the physical layer and performs CRC check on the received data frames to ensure data integrity.
[0161] Decapsulation: The MAC layer extracts the target MAC address from the data frame and compares it with the local MAC address to determine whether to receive the data frame. If the target MAC address matches, continue processing; otherwise, discard the data frame. Remove the header and tail of the data frame to extract the payload (that is, the data of the upper layer protocol).
[0162] The data is stored in the FIFO, and the decapsulated data is stored in the FIFO queue. The FIFO queue is usually a circular buffer that allows data to be stored and read in a first-in-first-out order. When the FIFO queue is full, the MAC layer may need to suspend receiving new data frames or take other measures to avoid data overflow.
[0163] The upper layer protocol reads data, and the service diversion module reads data from the FIFO queue.
[0164] Otherwise, the service offload module sends the data to be sent into the FIFO queue, and the MAC layer completes the data transmission.
[0165] In one embodiment, the business diversion module realizes the diversion of input data and the aggregation of output data. Its specific functions are as follows: Fig.10 As shown, diversion: data flow 1 (all data packets input by the network) is diverted into data flow 2 (data packets of ordinary business flow, data packets of layer 2 protocol and network control protocol) and data flow 3 (data packets of unloaded business flow) according to the strategy below; aggregation: data flow 4 (output business flow of unloaded business after processing) and data flow 5 (business flow output by back-end business processing module) are (unconditionally) aggregated into data flow 6; table lookup: data flow 7 is the request and response for looking up the diversion strategy table during data diversion, in a one-to-one manner; configuration: data flow 8 is the configuration management module to configure the diversion strategy, in a one-to-one manner, and the detailed process is described in the relevant chapter of the configuration management module.
[0166] The implementation process of data diversion is as follows: Fig.11 As shown: the business diversion module is connected to the local area network through the external network interface module. There are many types of data streams flowing in from the network interface. After the data packets flow in, they should be diverted first so that they can be processed by type.
[0167] Network message ( Fig.10 After the data flow 1) flows in, the data message integrity check is first performed, and then the five-tuple information of the message is extracted, and then the diversion process is entered. If the target address is a non-local IP address and a broadcast address, the destination of this message is a non-local device, and this message is discarded; the remaining messages execute the subsequent diversion process. If the five-tuple characteristics of the message meet the characteristics of the business flow to be unloaded, this message is diverted to the high-speed business processing module; the remaining messages execute the subsequent diversion process. If the five-tuple characteristics of the message meet the policy allowed by the firewall, this message is forwarded to the back-end business processing module; the remaining messages execute the discard process. At this point, the messages input by the network are divided into: discarded messages, messages that execute the unloading process ( Fig. 9 Data flow 3) and messages forwarded to the backend business processing module ( Fig.10 Data flow 2).
[0168] In one embodiment, the high-speed service module performs the message processing of the unloaded service flow, such as Fig.12 As shown:
[0169] Business scheduling: All unloaded business flow messages (data flow 1) enter the algorithm scheduling module, synchronously read the session table corresponding to the message, and enter different algorithm channels according to the scheduling process described below. Business aggregation: The operation output results and exception handling results (unconditional) are aggregated into data flow 2. Exception handling: Unloaded messages that should not perform cryptographic operations enter the exception handling process and construct exception response messages. Algorithm channel: The working logic for executing cryptographic algorithm operations can be implemented in the FPGA chip or call an external cryptographic chip. Reading and updating: In the process of algorithm scheduling of messages, the context information (sliding window, key and IV) corresponding to the message in the session table needs to be read; in the process of data aggregation, the context information (sliding window and IV) corresponding to the message in the session table needs to be refreshed. Reading and updating are both one-to-one response methods. Configuration: Data flow 4 is the configuration management module to configure the cryptographic operation context, a one-to-one response method. The detailed process is described in the relevant chapters of the configuration management module;
[0170] The actual process of algorithm scheduling is as follows Fig.13 As shown, after the data message of the unloaded service flow flows into the high-speed service module, the service scheduling process is first executed to read the session context corresponding to the current message, and extract the sliding window information, key information and IV information.
[0171] If the index of the current message is not within the sliding window range, the current message is sent to the exception processing channel; otherwise, the subsequent processing flow is executed. If the index of the current message is within the sliding window range, the algorithm channel corresponding to the current message is selected according to the strategy. The message, key and IV are sent to the corresponding algorithm channel to end the business scheduling process.
[0172] In one embodiment, Fig.14 As shown, the back-end business processing module runs on the CPU and is connected to the front-end offloading FPGA through the internal network interface module to process other services besides the offloading service. The TCP / IP protocol stack and the ordinary business processing unit are no different from the traditional server cryptographic machine. The configuration business unit and the offloading business management unit cooperate with the FPGA to complete the offloading function of the high-speed business.
[0173] TCP / IP protocol stack: Similar to traditional server cryptographic machines, it responds to and processes Layer 2 protocols and network management and control protocols (such as ICMP) in the network, and responds to and processes TCP and UDP protocols that carry services. It can use the protocol stack that comes with the operating system.
[0174] Ordinary business processing: Same as traditional server cryptographic machines, processing is completed on the business CPU, without using FPGA to offload cryptographic operations, such as asymmetric cryptographic operations and object management. The performance bottleneck of this type of business is not in communication or the functions are complex and not suitable for implementation on FPGA.
[0175] Offload service management: Symmetric algorithms and hash algorithms are offloaded cryptographic operations, and their operations are completed in the FPGA. However, the initialization and finalization of offload services involve complex resource management processes (as described below), which are implemented in the backend service processing module.
[0176] Configuration management: The back-end business processing module writes configuration information to the front-end FPGA during device startup, such as MAC address, IP address, and firewall policy.
[0177] In one embodiment, the service startup process and the termination process are uninstalled, such as Fig.15 As shown:
[0178] The process of starting the uninstall service is as follows:
[0179] The client host sends an initial request to the server cipher machine;
[0180] The server cryptographic machine receives the request, and the backend business processing module allocates memory CPU_MEM, session handle handle and FPGA internal resource index s_index;
[0181] The backend service processing module writes the fpga_initial command into the FPGA, carrying the parameters s_index, KEY, IV, and the five-tuple strategy for offloading services;
[0182] FPGA responds to the backend business processing module configuration success information;
[0183] The back-end business processing module constructs a successful response message and returns the session handle value to the client host.
[0184] The client host interface library receives a successful response and records the handle as the basis for subsequent sessions.
[0185] The normal termination process of the uninstall service is as follows:
[0186] The client host sends a final request to the server cryptographic machine, carrying the parameter handle;
[0187] The server cipher receives the request, searches for CPU_MEM based on the handle, and reads the s_index stored in CPU_MEM;
[0188] The backend business processing module writes the fpga_final command into the fpga, carrying the parameter s_index;
[0189] FPGA responds to the backend business processing module with success information;
[0190] The backend business processing module constructs a successful response message, carries the handle value, sends the response message, and then releases the resources corresponding to the local CPU_MEM;
[0191] The client host interface library receives a successful response and releases the session resource with handle as the index.
[0192] The abnormal termination process of the uninstall service is as follows:
[0193] The server cryptographic machine detects that the communication status with the client host is abnormal and starts the termination process;
[0194] The server cryptographic machine searches CPU_MEM according to the handle of the communication anomaly and reads the s_index stored in CPU_MEM;
[0195] The backend business processing module writes the fpga_final command into the fpga, carrying the parameter s_index;
[0196] FPGA responds to the backend business processing module with success information;
[0197] Regardless of whether the backend service processing module receives a response from the FPGA, it releases the session resource with handle as the index.
[0198] The client host also detects the communication anomaly and releases the session resource that handle is used as the index.
[0199] In one embodiment, the internal network interface module implements the sending and receiving of data frames between the service CPU and the front-end FPGA. Fig.16 As shown, the internal network interface module connects the back-end service processing module and the service distribution module, and includes PHY, MAC, FIFO and service CPU network card. The specific implementation method is the same as that of the external network interface module.
[0200] In one embodiment, Fig.17 As shown, the configuration management module receives control from the backend business processing module, forwards configuration information to each business unit inside the FPGA, and responds to the backend business processing module with configuration results. The configuration management operations include: writing to the diversion strategy table, writing to the session table, writing to the IP address, and writing to the MAC address.
[0201] Message parsing: Analyze the configuration operation commands written by the backend business processing module, parse the parameters according to the command words, and perform subsequent operations.
[0202] Configuration write: connect the configured input and output modules, execute the specific write operation process, and return the result of the write operation.
[0203] Message construction: According to the result of configuration writing, construct the corresponding response information to notify the back-end business processing module of the operation result.
[0204] Arbitration: The traffic diversion table and session table are read and written by different modules at the same time. The arbitration module is used to ensure that all operations are executed in sequence to avoid failures caused by simultaneous reading and writing.
[0205] In one embodiment, Fig.18 As shown, compared with the traditional interface library, the client host interface library adds a control layer to implement the flow control mechanism of the unloaded service. The server cryptographic machine implements the flow control mechanism in the service scheduling unit of the high-speed service module and works in conjunction with the control layer of the client host interface library.
[0206] The communication model is that the client host sends, the server cipher receives and responds, the client host receives the server cipher's response, and the cycle continues. According to this model, the reliable transmission mechanism is designed as follows:
[0207] All request messages are numbered sequentially starting from 0. Each request message corresponds to a response message. The request message and response message of the same message have the same index.
[0208] For the client host library, messages can be divided into three states: sent and acknowledged (ACKED), sent request but not yet acknowledged (SEQ), and unsent request (UNACCEPTED).
[0209] The client host interface library saves two sequence numbers for each cryptographic operation session, start_seq is the sequence number of the sent but unanswered start packet, and next_seq is the sequence number of the next unsent packet in the sliding window. The message sent by the client host contains sequence numbers (sseq, sack), sseq identifies the sequence number of the currently sent message, and sack identifies the sequence number of the message that has received the processing result.
[0210] For the server, the message can be divided into three states: the message that has been calculated and ACKed by the client (DELT), the message that meets the calculation conditions (CTX), and the message that does not meet the calculation conditions (UNKNOWN).
[0211] The server saves a context corresponding to a sliding window between [seq_start, seq_start + WIN_SIZE), with a fixed space of WIN_SIZE; the server cipher machine moves the seq_start pointer according to the sack of the message sent by the client host; the message sent by the server contains a sequence number (rseq, rnext), rseq identifies the current response message sequence number, and rnext identifies the next message sequence number that meets the operation conditions but has not yet arrived.
[0212] The client host interface library controls the timeout retransmission mechanism, and controls the message retransmission and retransmission time interval according to the sending status and receiving message status. The server cipher machine responds to the client host's request message according to the status, passively participates in the flow control process, and calculates and returns the settlement result if the calculation conditions are met.
[0213] The client host saves the flow control context for each service and can record the following:
[0214] Struct _client_flow_ctx{
[0215] Unsigned short start_seq;
[0216] Unsigned short next_seq;
[0217] BOOL acked[WIN_SIZE];
[0218] Unsigned char sndcnt[WIN_SIZE];
[0219] Struct timeval sendtime[WIN_SIZE];
[0220] }
[0221] In the initial state, start_seq = next_seq = 0;
[0222] Client host sends message processing:
[0223] There are currently unanswered lost messages. Check whether the lost message has reached the retransmission time. If so, resend it.
[0224] Currently, there is no unanswered lost message. Check whether the sending window is full. If not, continue to send the message indexed by next_seq;
[0225] The client host receives the message and processes it:
[0226] For the received input message, verify the validity of rseq and rnext; the returned valid response packet sequence number rseq must be between start_seq and next_seq; rnext must be between req and next_seq;
[0227] Each time a sequential response result is received, start_seq++;
[0228] Each time a non-sequential response result is received, the corresponding acked is marked; out-of-order responses will trigger the retransmission of unanswered messages;
[0229] The server saves the flow control context for each flow. The flow control context contains the following elements:
[0230]
[0231] The server processes the received message:
[0232] For the input operation request message, verify the legitimacy of sseq and sack; verify whether each received message sseq is between the window valid sequence number seq_start and the maximum receivable sequence number seq_next; verify that the received message sack should be less than the current valid window upper limit seq_end;
[0233] If sack is valid, it means that the client has confirmed receipt of the response indexed by sack, and the valid window header seq_start = sack + 1 is moved;
[0234] According to the current request message index sseq, the operation context is searched to complete the cryptographic operation processing of the payload data;
[0235] The server processes the sent message:
[0236] If the operation with message index sseq corresponds to the first request (non-retransmission), the operation context needs to be updated after the operation is completed, and the current valid window upper limit seq_end pointer needs to be moved backward;
[0237] Construct a reply message, which keeps the output message index equal to the input message index rseq=sseq, and the maximum receivable sequence number rnext=seq_next;
[0238] Send a reply message to the client host.
[0239] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0240] It should be noted that the terms "first\second\third" involved in the embodiments of the present application are only used to distinguish similar objects, and do not represent a specific order for the objects. It is understandable that the specific order or sequence of "first\second\third" can be interchanged where permitted. It should be understood that the objects distinguished by "first\second\third" can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0241] The terms "including" and "having" and any variations thereof in the embodiments of the present application are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or modules is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other steps or modules that are inherent to these processes, methods, products, or equipment.
[0242] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. The encryption and decryption method based on FPGA offloading is characterized in that: The encryption and decryption method includes: an uninstall service startup process, an uninstall service operation process and an uninstall service termination process; The uninstall service startup process includes the following steps: S1: The client host sends an initial request message for offloading services to the server cryptographic machine through the TCP protocol; S2: The external network interface module of the server cryptographic machine receives the initial request message of the offloading service through the network, and sends it to the service diversion module; S3: the service diversion module identifies and obtains the initial type of the unloaded service based on the initial request message of the unloaded service, and then determines the current forwarding path based on the initial type of the unloaded service and sends the initial request message of the unloaded service to the internal network interface module; S4: The internal network interface module receives the initial request message of the offload service and sends it to the backend service processing module; S5: The backend service processing module first parses the initial request message of the offload service and obtains the specific type of the initial service; then creates the context of the computing session based on the specific type of the initial service, and allocates a session ID as a resource index for the created context of the computing session; then allocates a UDP port for subsequent update operations of the context of the computing session to construct a five-tuple diversion basis; finally, encapsulates the service configuration command and the diversion configuration command based on the context of the computing session, the resource index and the five-tuple diversion basis, and sends the encapsulated service configuration command and the diversion configuration command to the configuration management module; S6: The configuration management module parses the service configuration command, and creates a cryptographic operation context based on the session ID in the high-speed service module based on the parsing result of the service configuration command; the configuration management module parses the diversion configuration command, and creates a diversion strategy quintuple of the context subsequent update message of the operation session in the service diversion module based on the parsing result of the diversion configuration command; the configuration management module sends the service configuration command and the execution result of the diversion configuration command to the back-end service processing module; S7: The backend service processing module encapsulates an inital service response message based on the execution results of the service configuration command and the diversion configuration command, and sends the inital service response message to the internal network interface module; S8: The internal network interface module receives the inital service response message and sends it to the service distribution module; S9: The service distribution module receives the inital service response message and sends it to the external network interface module; S10: The external network interface module receives the inital service response message and sends it to the client host through the network, so that the establishment of the cryptographic service session based on the session ID between the client host and the server cryptographic machine is completed; The uninstallation service operation process includes the following steps: S11: The client host sends an update message of cryptographic operation to the server cryptographic machine; S12: The external network interface module of the server cryptographic machine receives the update message of the cryptographic operation through the network, and sends it to the service diversion module; S13: the service diversion module performs message filtering on the update message of the cryptographic operation based on the diversion strategy quintuple of the update message, and obtains the message matching the diversion strategy; and then sends the message matching the diversion strategy to the high-speed service module; S14: The high-speed service module matches the corresponding cryptographic operation context based on the session ID in the message matching the diversion strategy; then performs flow control based on the matched cryptographic operation context; then sends the cryptographic operation request to the cryptographic operation module based on the matched cryptographic operation context; finally, updates the data of the cryptographic operation context based on the flow control information; S15: the cryptographic operation module performs an operation based on the cryptographic operation request, generates an operation result, and then sends the operation result to the high-speed service module; S16: the high-speed service module updates the cryptographic operation context based on the operation result; then constructs an update response result message based on the updated cryptographic operation context; and finally sends the update response result message to the service diversion module; S17: the service distribution module performs an aggregation process based on the update response result message, and then sends the aggregated update response result message to the external network interface module; S18: the external network interface module sends the aggregated update response result message to the client host through the network; the interface library of the client host obtains the operation result based on the aggregated update response result message, and then sends the operation result to the client application, and updates the context of the local cryptographic operation session of the client host; The uninstall service termination process includes the following steps: S19: The client host sends a final request message for uninstalling the service to the server cryptographic machine; S20: The external network interface module of the server cryptographic machine receives the final request message of the offload service through the network, and sends it to the service diversion module; S21: the service diversion module identifies and obtains the final type of the unloaded service based on the final request message of the unloaded service, and then determines the current forwarding path based on the final type of the unloaded service and sends the final request message of the unloaded service to the internal network interface module; S22: The internal network interface module receives the final request message of the offload service and sends it to the backend service processing module; S23: The backend service processing module first parses the final request message of the offload service and obtains the session ID carried in the final request message of the offload service; then searches and obtains the corresponding cryptographic operation context based on the session ID carried in the final request message of the offload service; finally, encapsulates the service resource release command and the diversion strategy release command based on the corresponding cryptographic operation context, and sends the encapsulated service resource release command and the diversion strategy release command to the configuration management module; S24: the configuration management module parses the service resource release command, and executes the service resource release operation based on the parsing result of the service resource release command, and at the same time clears the cryptographic operation context corresponding to the session ID in the high-speed service module; the configuration management module parses the diversion strategy release command, and releases the diversion strategy quintuple of the update message in the service diversion module based on the parsing result of the diversion strategy release command; the configuration management module sends the service resource release command and the execution result of the diversion strategy release command to the back-end service processing module; S25: The backend service processing module encapsulates a final service response message based on the execution results of the service resource release command and the diversion strategy release command, and sends the final service response message to the internal network interface module; S26: The internal network interface module receives the final service response message and sends it to the service distribution module; S27: The service distribution module receives the final service response message and sends it to the external network interface module; S28: The external network interface module receives the final service response message and sends it to the client host through the network; the interface library of the client host receives the final service response message and returns the execution result to the client application; The server cryptographic machine includes: a service CPU and a front-end FPGA; The business CPU includes: the back-end business processing module; The front-end FPGA includes: the configuration management module, the internal network interface module, the service diversion module, the external network interface module, the cryptographic operation module and the high-speed service module.
2. The encryption and decryption method based on FPGA offloading according to claim 1 is characterized in that: The encryption and decryption method also includes: Ethernet layer 2 protocol and network control protocol processing flow; The Ethernet Layer 2 protocol and network control protocol processing flow includes the following steps: A1: The external network interface module receives input messages from the external network; A2: The external network interface module sends the input message to the service distribution module, and the service distribution module identifies and obtains the Ethernet layer 2 protocol and the network control class protocol based on the input message, and then sends them to the internal network interface module; A3: The internal network interface module receives the Ethernet layer 2 protocol and the network control protocol, and sends them to the back-end service processing module; A4: The back-end service processing module receives the Ethernet layer 2 protocol and the network control protocol, and sends them to the internal network interface module; A5: The internal network interface module receives the Ethernet layer 2 protocol and the network control protocol, and sends them to the service distribution module; A6: The service distribution module receives the Ethernet layer 2 protocol and the network control protocol, and performs message aggregation based on the Ethernet layer 2 protocol and the network control protocol to obtain an aggregated protocol message, and then sends the aggregated protocol message to the external network interface module; A7: The external network interface module receives the aggregated protocol message and sends it to the external network.
3. The encryption and decryption method based on FPGA offloading according to claim 2 is characterized in that: The encryption and decryption method also includes: a common business processing flow; The general business processing flow includes the following steps: B1: The external network interface module receives a common service request message sent by the client host through the network; B2: the external network interface module sends the common service request message to the service distribution module; B3: The service distribution module receives the common service request message and sends it to the internal network interface module; B4: The internal network interface module receives the common service request message and sends it to the back-end service processing module; B5: The backend business processing module parses the common business request message and obtains the common business type, then encapsulates the cryptographic operation request or object management operation of the common business based on the common business type, and then sends the cryptographic operation request or object management operation of the common business to the cryptographic operation module; B6: The cryptographic operation module completes the corresponding cryptographic operation or object management operation based on the cryptographic operation request or object management operation of the common service, and sends the execution result of the cryptographic operation or object management operation to the back-end service processing module; B7: The backend business processing module encapsulates a common business response message based on the execution result of the cryptographic operation or the object management operation, and sends the common business response message to the internal network interface module; B8: The internal network interface module receives the common service response message and sends it to the service distribution module; B9: the service distribution module receives the common service response message, aggregates the messages based on the common service response message, obtains an aggregated common service response message, and then sends the aggregated common service response message to the external network interface module; B10: The external network interface module receives the aggregated common service response message and sends it to the client host through the network.
4. The encryption and decryption method based on FPGA offloading according to claim 3 is characterized in that: The encryption and decryption method further includes: uninstalling the abnormal termination process of the service; The abnormal termination process of the uninstall service includes the following steps: C1: The backend business processing module detects that an abnormality occurs in the TCP socket established by the offload business startup process, and searches for the cryptographic operation context corresponding to the session ID of the TCP socket; then encapsulates the business resource release command and the diversion strategy release command based on the corresponding cryptographic operation context, and sends the encapsulated business resource release command and the diversion strategy release command to the configuration management module; C2: The configuration management module parses the service resource release command, and performs a service resource release operation based on the parsing result of the service resource release command, and at the same time clears the cryptographic operation context corresponding to the session ID in the high-speed service module; the configuration management module parses the diversion strategy release command, and releases the diversion strategy quintuple of the update message in the service diversion module based on the parsing result of the diversion strategy release command; the back-end service processing module releases the cryptographic operation session resources; C3: The client application on the client host detects an exception and calls the interface library to release the local cryptographic operation session resources of the client host.
5. The encryption and decryption method based on FPGA offloading according to claim 4 is characterized in that: The cryptographic operation module is selected as an independent component or integrated into the high-speed service module.
6. An encryption and decryption system based on FPGA offloading, adopting the encryption and decryption method based on FPGA offloading as described in any one of claims 1 to 5, characterized in that: include: The client host and the server cryptographic machine; The client host includes: the interface library and the client application; The interface library includes: an interface layer, a control layer and a communication layer; The interface layer is used to provide a callable function interface for the client application; the control layer is used to implement the reliability guarantee of data communication; the communication layer is used to implement network communication details; The server cryptographic machine includes: a service CPU and a front-end FPGA; The business CPU includes: the back-end business processing module; The front FPGA includes: the configuration management module, the internal network interface module, the service diversion module, the external network interface module, the cryptographic operation module and the high-speed service module; The configuration management module is used to parse the configuration management message and complete the configuration operation, and then generate a corresponding response message according to the result of the configuration operation; The internal network interface module is used to forward the service data sent by the service distribution module to the back-end service processing module, or forward the message data returned by the back-end service processing module to the service distribution module; The business diversion module is used to receive data messages output by other modules through a custom bus; The external network interface module is used to receive external input data messages through the network, or send out the response message data sent by the business diversion module through the network; The cryptographic operation module is used to perform cryptographic operations; The high-speed service module is used to process high-speed service messages and generate data messages containing processing results and send them out; The back-end business processing module is used to pre-process the input business request message and generate a cryptographic operation request.
7. The encryption and decryption system based on FPGA offloading according to claim 6, characterized in that: Also includes: Expansion storage module; The extended storage module is used to expand the storage space of the front FPGA.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the encryption and decryption method based on FPGA offloading as described in any one of claims 1 to 5.
