Data processing method, device, electronic device and storage medium

By designing first-level coroutines and second-level coroutines in SSL proxy services and sending the encryption and decryption operations to the hardware acceleration device for processing, the problem of high CPU load in SSL proxy services is solved, and the device's processing of concurrent services is improved performance.

CN115426403BActive Publication Date: 2024-11-26QI-ANXIN LEGENDSEC INFORMATION TECH (BEIJING) INC +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211017571.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-23
Publication Date
2024-11-26
Estimated Expiration
2042-08-23

AI Technical Summary

Technical Problem

Existing SSL agents consume a lot of CPU resources in the encryption and decryption operation, resulting in excessive CPU load on the device and affecting the performance of other services.

Method used

The first-level coroutine and second-level coroutine are designed to process messages from SSL proxy services separately, and the encryption and decryption operation is submitted to the hardware acceleration device for asynchronous processing. Through the cooperation of coroutine switching and hardware acceleration device, CPU computing resource consumption is reduced. Improve processing performance.

Benefits of technology

It effectively improves the processing performance of SSL proxy services, reduces CPU load, improves the processing ability of network intermediate devices for concurrent services, and can handle messages in more business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115426403B_ABST
    Figure CN115426403B_ABST
Patent Text Reader

Abstract

The present application provides a data processing method, device, electronic device and storage medium, which relate to the field of communication technology. The method designs two-level coroutines under the SSL proxy service to process the messages that need to be used for the SSL proxy service, thereby realizing the layering of the code logic level, which can effectively improve the processing performance of the SSL proxy service, and the message processing process of the network intermediate device can receive messages of various services and process them accordingly, so that the network intermediate device can process messages in more business scenarios, rather than just processing messages of the SSL proxy service, thereby improving the performance of the network intermediate device in processing other businesses. In addition, the present solution sends the encryption and decryption operations to the hardware acceleration device for processing, so that the performance of the hardware acceleration device can be fully utilized, the consumption of computing resources of the CPU in the network intermediate device can be reduced, and the performance of the CPU in processing concurrent businesses can be further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art

[0002] The Secure Sockets Layer (SSL) protocol is between the application layer and the transport layer. The application layer data is no longer passed directly to the transport layer, but to the SSL layer. The SSL layer encrypts the data received from the application layer, which ensures the security of communication between the client and the server and prevents it from being monitored and tampered with.

[0003] Usually, SSL proxy is used as a way to implement the SSL layer. The implementation of SSL proxy often involves a large number of encryption and decryption operations. These encryption and decryption operations consume a large amount of computing resources of the device CPU, resulting in excessive CPU load, which in turn affects the performance of other business processing of the device. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a data processing method, device, electronic device and storage medium to improve the problem that the existing method requires a large amount of CPU computing resources to be consumed and affects the performance of other business processing of the device.

[0005] In a first aspect, an embodiment of the present application provides a data processing method, which is applied to a network intermediate device, wherein the network intermediate device is deployed with an SSL proxy service, and the method includes:

[0006] Receiving a current message sent by a server or a client through a message processing process of the network intermediate device, and switching to a first-level coroutine of the SSL proxy service when determining that the current message needs to be processed by an SSL proxy service;

[0007] Preprocessing the current message through the first-level coroutine, and switching to the second-level coroutine of the SSL proxy service after the preprocessing is completed;

[0008] The secondary coroutine performs relevant operations specified in the SSL protocol on the current message after preprocessing, wherein, when the secondary coroutine performs encryption and decryption operations on data, the encryption and decryption operations are submitted to the hardware acceleration device for asynchronous processing.

[0009] In the above implementation process, the method designs a first-level coroutine and a second-level coroutine under the SSL proxy service. The two-level coroutines are used to process the messages that need to be used for the SSL proxy service, respectively, so as to realize the layering of the code logic level and effectively improve the processing performance of the SSL proxy service. The message processing process of the network intermediate device can receive messages of various services and process them accordingly, so that the network intermediate device can process messages in more business scenarios, not just messages of the SSL proxy service, so as to improve the performance of the network intermediate device in processing other businesses. And in the present application scheme, the encryption and decryption operations are sent to the hardware acceleration device for processing, so as to give full play to the performance of the hardware acceleration device, reduce the consumption of computing resources of the CPU in the network intermediate device, and further improve the performance of the CPU in processing concurrent businesses.

[0010] Optionally, after submitting the encryption and decryption operation to the hardware acceleration device for asynchronous processing through the secondary coroutine, the method further includes:

[0011] Save the execution scene of the secondary coroutine and switch back to the primary coroutine;

[0012] Save the execution scene of the first-level coroutine and switch back to the message processing process;

[0013] The task processing result of the encryption and decryption operation is monitored through the message processing process.

[0014] In the above implementation process, by saving the execution sites of the first-level coroutine and the second-level coroutine, the execution can be restored and continued when called next time, so there is no need to start the execution from the beginning, thereby improving processing efficiency.

[0015] Optionally, after switching back to the first-level coroutine, the method further includes:

[0016] Adding the encryption and decryption operation task to the hardware execution task queue through the first-level coroutine;

[0017] The monitoring of the task processing result of the encryption and decryption operation through the message processing process includes:

[0018] The task processing result of the encryption and decryption operation in the hardware execution task queue is monitored through the message processing process.

[0019] In the above implementation process, since the hardware execution task queue can store multiple encryption and decryption operation tasks, the message processing process can detect the task processing results of multiple encryption and decryption operations at the same time by monitoring the hardware execution task queue, thereby improving the detection efficiency.

[0020] Optionally, the method further comprises:

[0021] After the message processing process detects that the task processing of the encryption and decryption operation is completed, the execution scene of the first-level coroutine is restored through the message processing process, and the execution scene is switched to the first-level coroutine;

[0022] Restore the execution scene of the second-level coroutine through the first-level coroutine, and switch to the second-level coroutine;

[0023] The result of the encryption and decryption operation is obtained from the hardware acceleration device through the secondary coroutine, and the related operations specified by the SSL protocol are continued to be executed.

[0024] In the above implementation process, after the secondary coroutine resumes the execution site, it obtains the result of the encryption and decryption operation from the hardware acceleration device and continues to perform related operations. In this way, the secondary coroutine and the hardware acceleration device can realize asynchronous processing of the message, thereby improving the processing performance of the SSL proxy service.

[0025] Optionally, performing relevant operations specified in the SSL protocol on the current message after preprocessing through the secondary coroutine includes:

[0026] The secondary coroutine performs an SSL handshake negotiation operation or a corresponding message processing operation on the current message after preprocessing. In this way, the code logic layering can be realized through the two-level coroutine, and the processing performance of the message of the SSL proxy service can be improved through the mutual cooperation between the primary coroutine and the secondary coroutine.

[0027] Optionally, when the current message is the first message that requires SSL proxy service, preprocessing the current message by using the first-level coroutine includes:

[0028] The certificate obtained from the server is re-issued through the first-level coroutine, so that the current message is processed using the re-issued certificate. The first-level coroutine performs simple pre-processing operations on the message, so that the specific message operation can be handled by the second-level coroutine, so as to realize the layering of the proxy logic level, give full play to the advantages of the coroutine, and improve the processing performance of the SSL proxy service.

[0029] Optionally, the network intermediate device is a firewall, and the hardware acceleration device is an acceleration card based on QAT technology.

[0030] In a second aspect, an embodiment of the present application provides a data processing device, which runs on a network intermediate device, and the network intermediate device is deployed with an SSL proxy service, and the device includes:

[0031] A coroutine switching module, used for receiving a current message sent by a server or a client through a message processing process of the network intermediate device, and switching to a first-level coroutine of the SSL proxy service when it is determined that the current message needs to be provided with an SSL proxy service;

[0032] A first-level coroutine processing module, used for preprocessing the current message through the first-level coroutine, and switching to the second-level coroutine of the SSL proxy service after the preprocessing is completed;

[0033] The secondary coroutine processing module is used to perform relevant operations specified in the SSL protocol on the current message after preprocessing through the secondary coroutine, wherein when the secondary coroutine performs encryption and decryption operations on data, the encryption and decryption operations are submitted to the hardware acceleration device for asynchronous processing.

[0034] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method provided in the first aspect are performed.

[0035] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the method provided in the first aspect are performed.

[0036] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0038] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application;

[0039] Figure 2 A flowchart of interaction between two-level coroutines provided in an embodiment of the present application;

[0040] Figure 3 A structural block diagram of a data processing device provided in an embodiment of the present application;

[0041] Figure 4 A schematic diagram of the structure of an electronic device for executing a data processing method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present application.

[0043] It should be noted that the terms "system" and "network" in the embodiments of the present invention can be used interchangeably. "Multiple" means two or more. In view of this, in the embodiments of the present invention, "multiple" can also be understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the previously associated objects are in an "or" relationship.

[0044] The embodiment of the present application provides a data processing method, which is applied to a network intermediate device, in which an SSL proxy service is deployed, and a first-level coroutine and a second-level coroutine are designed under the SSL proxy service. The two-level coroutines are respectively used to process messages that need to be used for SSL proxy services, which can realize the layering of the code logic level and effectively improve the processing performance of the SSL proxy service. The message processing process of the network intermediate device can receive messages of various services and process them accordingly, so that the network intermediate device can process messages in more business scenarios, not just messages of SSL proxy services, which can improve the performance of the network intermediate device in processing other businesses. And in the scheme of the present application, the encryption and decryption operations are sent to the hardware acceleration device for processing, so that the performance of the hardware acceleration device can be fully utilized, the consumption of computing resources of the CPU in the network intermediate device can be reduced, and the performance of the CPU in processing concurrent businesses can be further improved.

[0045] Please refer to Figure 1 , Figure 1 A flowchart of a data processing method provided in an embodiment of the present application, the method is applied to a network intermediate device, and includes the following steps:

[0046] Step S110: receiving the current message sent by the server or the client through the message processing process of the network intermediate device, and when determining that the current message needs to perform SSL proxy service, switching to the first-level coroutine of the SSL proxy service.

[0047] The network intermediate device in the embodiment of the present application may refer to a gateway, a router, a firewall and other devices, and the network intermediate device may be used to process the communication messages between the client and the server accordingly. In order to ensure the security of the communication between the client and the server, an SSL proxy service is deployed in the network intermediate device, so that the network intermediate device can communicate with the client and the server respectively as an SSL proxy server.

[0048] For example, when a client communicates with a server, the client sends a Client Hello message to initiate an SSL connection. After receiving the message, the network intermediate device parses and caches the message, and sends its own Client Hello message to the server. The server responds to the message and returns a Server Hello message and a server certificate to the network intermediate device. At this time, the network intermediate device acts as a proxy client to complete an SSL handshake with the server and establish an SSL connection. The network intermediate device then sends its own Server Hello message and a re-issued certificate to the client. After the client completes the certificate verification, it completes an SSL handshake with the network intermediate device and establishes an SSL connection. After that, the messages transmitted between the client, the network intermediate device, and the server are all encrypted messages. The network intermediate device can decrypt the messages received from the client or server, perform security content detection or audit on the decrypted messages, and then re-encrypt them and send them to the client or server.

[0049] Therefore, the network intermediate device will involve a large number of encryption and decryption operations in the SSL proxy process. These encryption and decryption operations will consume a large amount of computing resources of the CPU of the network intermediate device. However, the network intermediate device also involves the processing of other business messages, which also requires the consumption of CPU resources. In order to reduce the occupation of CPU computing resources by encryption and decryption operations, a two-level coroutine is proposed in the embodiment of the present application to process the messages of the SSL proxy service, and the encryption and decryption operations are sent to the hardware acceleration device for processing. In this way, there is no need for the CPU of the network intermediate device to perform encryption and decryption operations, and the network intermediate device can also have more resources to process more other business messages.

[0050] Among them, the message processing process of the network intermediate device can refer to the main process of the network intermediate device, which can be used to process various business messages, such as messages of SSL proxy services, filtering, intercepting, and security testing of other business messages. For messages of other businesses, the message processing process can process them directly, and for messages of SSL proxy services, the messages can be submitted to the two-level coroutine of the SSL proxy service for processing. In this way, the message processing process can still process other business messages synchronously and will not be affected by the processing of SSL proxy service messages. This can improve the performance of the network intermediate device in handling concurrent services.

[0051] The first-level coroutine and the second-level coroutine can be created for the SSL proxy service. Using the coroutine to process the messages of the SSL proxy service can release the resources occupied by the message processing process, so that the message processing process can continue to process other business messages synchronously.

[0052] Coroutine means that a function containing multiple instruction statements can no longer be executed from the first instruction statement of the multiple instruction statements every time, but continue to execute from the position where the last call was paused during the process of calling the function. Specifically, when the coroutine function is first called, a coroutine context will be allocated on the stack to save the return address of the initiator, entry parameters, variables, and the position of releasing control over system resources. When the coroutine calls the function again, the calling environment will be restored based on the saved coroutine context, and then the function will continue to execute from the position where the execution was paused last time. In this way, the coroutine mechanism can be used to protect and restore the execution site. In the embodiment of the present application, a two-level coroutine mechanism is used to process the message of the SSL proxy service. Each level of coroutine completes the corresponding message processing action. For example, the first-level coroutine can pre-process the message, and the specific message processing operation is placed in the second-level coroutine. In this way, the cooperation of the two-level coroutine can realize the rapid processing of the message.

[0053] In this step S110, the interactive message between the client and the server will be forwarded through the network intermediate device. If the current message received by the message processing process of the network intermediate device needs to be processed by the SSL proxy service, that is, it needs to be processed by the SSL proxy service, then it will switch to the first-level coroutine of the SSL proxy service for processing. Here, the network intermediate device can determine whether the SSL proxy service is needed based on some information carried by the current message, such as determining whether the current message is a Hello message sent by the client or server, or whether it is a message transmitted between the client or the server through an SSL connection, etc.

[0054] Step S120: pre-process the current message through the first-level coroutine, and switch to the second-level coroutine of the SSL proxy service after the processing is completed.

[0055] Among them, the preprocessing here can refer to some basic processing of the message. For example, if the current message is the first message that requires SSL proxy service, such as the current message is the first time that the client sends a Client Hello message, the preprocessing operation may include a first-level coroutine to re-issue the certificate obtained from the server (such as replacing the issuer and the key pair used by the certificate) to process the current message using the re-issued certificate. The network intermediate device replies to the client with a Server Hello message and a re-issued server certificate for the current message, so that the subsequent client can use the key pair of the re-issued server certificate to encrypt the message.

[0056] In addition, when the SSL connection is initially established, the preprocessing operation may also include some initialization of SSL, such as the protocol version used, the algorithm suite supported, etc. The preprocessing operation may also include operations such as parsing the message, such as parsing the required extension fields (such as whether the Application-Layer Protocol Negotiation (ALPN) and Server Name Indication (SNI) are supported) of the Client Hello message sent by the client. In addition, the preprocessing operation may also include determining whether session multiplexing is required.

[0057] It can be understood that in practical applications, preprocessing operations can be set according to needs. These preprocessing operations can be considered as some preparations for the message, while the specific message processing operations can be handled by the secondary coroutine.

[0058] Therefore, the first-level coroutine can establish an SSL connection between the server and the client, and between the client and the server through preprocessing operations, and the context information of the SSL connection can be maintained in the first-level coroutine. After the next message sent by the receiving client or server through the SSL connection, the context information can be restored in the first-level coroutine to continue processing the message.

[0059] Step S130: Perform relevant operations specified by the SSL protocol on the current message after preprocessing through the secondary coroutine.

[0060] After the first-level coroutine completes the preprocessing of the current message, it switches to the second-level coroutine. At this time, the second-level coroutine can perform the relevant operations specified by the SSL protocol on the current message, such as constructing a reply message corresponding to the current message according to the negotiation state of the current SSL connection and sending it to the corresponding server or client, or generating or obtaining the key of the corresponding algorithm suite according to the type of algorithm suite used in the negotiation process. Or the relevant operations specified by the SSL protocol also include performing an SSL handshake negotiation operation or a corresponding message processing operation on the current message. Here, the SSL handshake negotiation operation refers to the network intermediate device performing SSL handshake negotiation with the other party on behalf of the client or server, such as negotiating a key pair for encryption and decryption. The corresponding message processing operation can refer to the encryption and decryption operation, forwarding operation or other operations involved in other SSL proxy services, such as decrypting the message obtained from one side, transparently transmitting the plaintext to the other side of the SSL proxy, or re-encrypting the plaintext and sending it out. It can also be determined whether to send the plaintext information to other services through mirroring for security inspection according to the policy configuration.

[0061] Of course, here, if the secondary coroutine performs encryption and decryption operations on the data, in order to reduce the computing burden of the CPU of the network intermediate device, the encryption and decryption operations are submitted to the hardware acceleration device for asynchronous processing.

[0062] The second-level coroutine here can refer to the OpenSSL protocol. Submitting the encryption and decryption operation to the hardware acceleration device can be understood as using the interface function provided by OpenSSL to call the engine of the hardware acceleration device in the kernel state, and the engine drives the hardware acceleration device to process the encryption and decryption operation. For example, when the second-level coroutine executes the encryption and decryption operation, it generates a corresponding asynchronous task and then directly enters the corresponding processing engine.

[0063] The hardware acceleration device may be an acceleration card based on Quick Assist Technology (QAT), and the processing engine may be a QAT Engine. The processing engine may call the QAT driver in the kernel state to drive the hardware acceleration device to asynchronously process encryption and decryption operations. In this case, the hardware acceleration device may asynchronously process encryption and decryption tasks, and the two-level coroutine of the SSL proxy service may asynchronously process other messages, without requiring the network intermediate device to perform encryption and decryption operations additionally, thereby giving full play to the processing capability of the hardware acceleration device and maximizing the performance of the network intermediate device.

[0064] In the above implementation process, by designing a first-level coroutine and a second-level coroutine under the SSL proxy service, these two levels of coroutines are used to process the messages that need to be used for the SSL proxy service, respectively, so as to realize the layering of the code logic level, and effectively improve the processing performance of the SSL proxy service, and the message processing process of the network intermediate device can receive messages of various services and process them accordingly, so that the network intermediate device can process messages in more business scenarios, not just messages of the SSL proxy service, so as to improve the performance of the network intermediate device in processing other businesses. And in the present application scheme, the encryption and decryption operations are sent to the hardware acceleration device for processing, so as to give full play to the performance of the hardware acceleration device, reduce the consumption of computing resources of the CPU in the network intermediate device, and further improve the performance of the CPU in processing concurrent businesses.

[0065] On the basis of the above embodiment, in order to enable the two-level coroutine and the hardware acceleration device to process asynchronously, after the encryption and decryption operation is submitted to the hardware acceleration device for asynchronous processing through the second-level coroutine, the second-level coroutine can also save its execution scene (that is, it can continue to execute from the pause point after the scene is restored next time), and switch back to the first-level coroutine, and then save the execution scene of the first-level coroutine, and switch back to the message processing process, and then the task processing results of the encryption and decryption operation can be monitored through the message processing process.

[0066] That is to say, after the secondary coroutine submits the encryption and decryption operation to the hardware acceleration device, it finally switches back to the message processing process. At this time, the message processing process can monitor the task processing results of the encryption and decryption operation. For example, the message processing process can create a monitoring task, which is mainly used to monitor the task processing results of this encryption and decryption operation, such as whether the processing is completed. After the processing is completed, the encrypted and decrypted message can be obtained through the two-level coroutine. The subsequent network intermediate device can continue to process the message after encryption and decryption, such as forwarding it to the client or server.

[0067] In the above implementation process, by saving the execution sites of the first-level coroutine and the second-level coroutine, the execution can be restored and continued when called next time, so there is no need to start the execution from the beginning, thereby improving processing efficiency.

[0068] On the basis of the above embodiment, since the SSL proxy service involves many encryption and decryption operations, many encryption and decryption operation tasks will be submitted to the hardware acceleration device. In order to improve the monitoring efficiency of the message processing process, at the execution site where the second-level coroutine is saved, after switching back to the first-level coroutine, the encryption and decryption operation tasks can also be added to the hardware execution task queue through the first-level coroutine, and the task processing results of the encryption and decryption operations in the hardware execution task queue are monitored through the message processing process.

[0069] Here, the hardware execution task queue can be used to store the various encryption and decryption operation tasks processed by the hardware acceleration device. The hardware acceleration device can mark the processing results of each encryption and decryption task in the hardware execution task queue. If the processing is not completed, it is marked as 0, and if the processing is completed, it is marked as 1. Of course, the mark here can be flexibly set according to actual needs, as long as the message processing process can know the task processing results of the encryption and decryption operation from the hardware execution task queue. In this way, the message processing process can know whether the encryption and decryption operation is completed through the mark representing the task processing result corresponding to the encryption and decryption operation in the hardware execution task queue. If the processing is completed, the corresponding message after the encryption and decryption operation can be obtained through the two-level coroutine of the SSL proxy service.

[0070] When the message processing process monitors the hardware execution task queue, it can read the task processing result of the encryption and decryption operation from the hardware execution task queue periodically or in real time.

[0071] In the above implementation process, since the hardware execution task queue can store multiple encryption and decryption operation tasks, the message processing process can detect the task processing results of multiple encryption and decryption operations at the same time by monitoring the hardware execution task queue, thereby improving the detection efficiency.

[0072] Based on the above embodiment, after the message processing process detects that the task processing of the encryption and decryption operation is completed, the execution site of the first-level coroutine is restored through the message processing process and switched to the first-level coroutine. Then, the execution site of the second-level coroutine is restored through the first-level coroutine and switched to the second-level coroutine. At this time, the result of the encryption and decryption operation can be obtained from the hardware acceleration device through the second-level coroutine, and the relevant operations specified by the SSL protocol can continue to be executed.

[0073] For example, when the message processing process detects that the task processing of the encryption and decryption operation is completed in the hardware execution task queue, it switches to the first-level coroutine. At this time, the first-level coroutine restores the previously saved execution scene and continues to execute according to the current logic, that is, switches to the second-level coroutine. The second-level coroutine restores the previously saved execution scene. Since the second-level coroutine submits the encryption and decryption operation to the hardware acceleration device, it is equivalent to the second-level coroutine suspending the task of executing the encryption and decryption operation. Therefore, the second-level coroutine can resume the execution of the encryption and decryption operation at this time. At this time, it can be understood that the second-level coroutine obtains the processing result of the encryption and decryption operation from the hardware acceleration device, such as the current message after encryption and decryption, and then can continue to perform the relevant operations specified in the SSL protocol on the current message after encryption and decryption, such as forwarding it to the client or server through an SSL connection, that is, continue to perform the operations on the message after encryption and decryption in the SSL protocol, such as continuing to perform the SSL handshake process or continuing to perform subsequent processing on the message, and repeating the above process when encountering the next suspension point, that is, when encountering the next message that requires SSL proxy service, it is processed according to the same process, or the relevant operations specified in the SSL protocol here also include the operations mentioned in the above step S130.

[0074] After the secondary coroutine obtains the result of the encryption and decryption task, it can end the previously created encryption and decryption task, that is, release the created encryption and decryption task. If there are multiple encryption and decryption tasks, each time the result of the encryption and decryption task is obtained, the encryption and decryption task will be released and switched back to the first-level coroutine. The first-level coroutine will also release the asynchronous task created previously and switch back to the message processing process.

[0075] In the above implementation process, after the secondary coroutine resumes the execution site, it obtains the result of the encryption and decryption operation from the hardware acceleration device and continues to perform related operations. In this way, the secondary coroutine and the hardware acceleration device can realize asynchronous processing of the message, thereby improving the processing performance of the SSL proxy service.

[0076] In order to describe the process in the above embodiment more clearly, Figure 2 The interactive process shown in the figure can be understood, where the following are Figure 2 The meaning or function of each function in:

[0077] User Space: user space;

[0078] Kernel Space: kernel state;

[0079] dp: message processing process;

[0080] ssl_entry: SSL proxy entity;

[0081] ssl_entry async: asynchronous task in SSL proxy entity;

[0082] Libsg_ssl: library functions that implement the SSL protocol;

[0083] OpenSSL async: Asynchronous tasks in OpenSSL, i.e., secondary coroutines;

[0084] Libsg_crypto: library functions that implement various cryptographic algorithms;

[0085] Qat Engine: The engine library file that supports the use of QAT provided by the third-party Intel, which can also be understood as the QAT engine;

[0086] QAT Driver: QAT driver;

[0087] app_proc: application layer processing;

[0088] ssl_async_schedule: SSL proxy asynchronous processing scheduling function;

[0089] ssl async job: asynchronous task of SSL proxy;

[0090] ssl_fibre_start: SSL proxy asynchronous task start function (switching from the message processing process to the first-level coroutine of the SSL proxy);

[0091] SSL_connect: function to initiate SSL connection;

[0092] ssl_start_async_job: asynchronous processing function in SSL (allocating OpenSSL async, recording asynchronous processing status, etc.);

[0093] ASYNC_start_job: Function for allocating asynchronous tasks in OpenSSL;

[0094] async_fibre_swapcontext: asynchronous task startup function in OpenSSL (switching from the first-level coroutine of the SSL agent to the second-level coroutine of OpenSSL);

[0095] ssl_op_intern: SSL internal asynchronous processing function;

[0096] Cpa Crypto OP: calls QAT interface operations;

[0097] ASYNC_PAUSE: The status returned by the asynchronous task when it is not completed;

[0098] ssl_fibre_switch: SSL proxy asynchronous task switching function (switching between the message processing process and the first-level coroutine of the SSL proxy);

[0099] ASYNC_resume_job: OpenSSL asynchronous task resume operation;

[0100] ASYNC_FINISH: The status returned after asynchronous task processing is completed;

[0101] SSL_ERROR_WANT_ASYNC: The status returned by SSL when the asynchronous task is not completed;

[0102] SSL_ERROR_NONE: an SSL status code;

[0103] ssl_async_poll_hw: SSL proxy poll function (query QAT processing results).

[0104] The following is a brief introduction Figure 2 The execution process: After the message main process dp receives the current message, if the current message needs SSL proxy service, it switches to the first-level coroutine of SSL proxy service through the ssl_async_schedule function. The first-level coroutine preprocesses the current message, including creating an ssl async job (this task is used to preprocess the message), that is, creating an asynchronous task, and initiating an SSL connection through the SSL_connect function, and switching to the second-level coroutine for processing by calling Libsg_ssl.

[0105] When the secondary coroutine executes the encryption and decryption operation, it creates an asynchronous task (ASYNC_start_job). Here, the secondary coroutine can create an asynchronous task for each encryption and decryption operation, and submit the encryption and decryption operation to the QAT engine. The QAT engine calls the QAT driver through the interface function to drive the QAT to process the encryption and decryption operation. Then the secondary coroutine saves the execution scene (i.e. ASYNC_PAUSE), and then switches back to the primary coroutine. The primary coroutine saves the execution scene (i.e. saves the ssl async job), and finally switches to the message processing process, which monitors the hardware execution task queue (ssl_async_poll_hw).

[0106] Then the message processing process switches to the first-level coroutine, resumes the execution site of the first-level coroutine (ssl_fibre_switch), and then switches to the second-level coroutine, resumes the execution site of the second-level coroutine (ASYNC_resume_job), and reads the result of the encryption and decryption operation of the message by QAT through the QAT driver. At this time, the task execution of the encryption and decryption operation in the second-level coroutine ends (ASYNC_FINISH), that is, the asynchronous task created by the second-level coroutine is released after the second-level coroutine obtains the corresponding encryption and decryption result, and switches to the first-level coroutine. The first-level coroutine finally switches to the message processing process and releases the asynchronous task created by the first-level coroutine (release ssl async job), that is, the asynchronous task of the first-level coroutine can be released after the second-level coroutine executes the relevant operations specified by the SSL protocol. The asynchronous tasks of the two-level coroutines are suspended after the second-level coroutine submits the encryption and decryption operation to QAT, and are resumed after the message processing process detects that the encryption and decryption operation task processing is completed.

[0107] Therefore, the embodiment of the present application submits the encryption and decryption operations to the hardware acceleration device for asynchronous processing, which can solve the problem of low performance caused by using CPU resources to perform encryption and decryption operations in a synchronous manner in the original method, and processes the messages of the SSL proxy service through two-level coroutines, so that the message processing process of the network intermediate device can synchronously process other business messages, thereby improving the message processing efficiency. The processing process of the two-level coroutine realizes the layering of the code logic level, and can also effectively improve the processing performance of the message. Since the coroutine mechanism can save context information, the execution site can be restored through the context information at the next execution, so the difficulty of state preservation and reentry in the SSL proxy service process can also be solved. And the coroutine is also lighter, thereby avoiding the problem of frequent switching between kernel state and user state faced by processes and threads, which consumes a lot of switching time.

[0108] Please refer to Figure 3 , Figure 3 The structure block diagram of a data processing device 200 provided in an embodiment of the present application, the device 200 may be a module, program segment or code on an electronic device (i.e., a network intermediate device). It should be understood that the device 200 is similar to the above Figure 1 The method embodiment corresponds to and can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device 200 can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here.

[0109] Optionally, the device 200 includes:

[0110] The coroutine switching module 210 is used to receive the current message sent by the server or the client through the message processing process of the network intermediate device, and when it is determined that the current message needs to perform the SSL proxy service, switch to the first-level coroutine of the SSL proxy service;

[0111] A first-level coroutine processing module 220, used for preprocessing the current message through the first-level coroutine, and switching to the second-level coroutine of the SSL proxy service after the preprocessing is completed;

[0112] The secondary coroutine processing module 230 is used to perform relevant operations specified in the SSL protocol on the current message after preprocessing through the secondary coroutine, wherein when the secondary coroutine performs encryption and decryption operations on data, the encryption and decryption operations are submitted to the hardware acceleration device for asynchronous processing.

[0113] Optionally, the device 200 further includes:

[0114] A monitoring module is used to save the execution site of the secondary coroutine and switch back to the primary coroutine; save the execution site of the primary coroutine and switch back to the message processing process; and monitor the task processing results of the encryption and decryption operations through the message processing process.

[0115] Optionally, the monitoring module is further used to add the encryption and decryption operation task to the hardware execution task queue through the first-level coroutine; and monitor the task processing result of the encryption and decryption operation in the hardware execution task queue through the message processing process.

[0116] Optionally, the device 200 further includes:

[0117] A result acquisition module is used to restore the execution site of the first-level coroutine through the message processing process and switch to the first-level coroutine after the message processing process detects that the task processing of the encryption and decryption operation is completed; restore the execution site of the second-level coroutine through the first-level coroutine and switch to the second-level coroutine; obtain the result of the encryption and decryption operation from the hardware acceleration device through the second-level coroutine, and continue to execute the relevant operations specified by the SSL protocol.

[0118] Optionally, the secondary coroutine processing module 230 is used to perform an SSL handshake negotiation operation or a corresponding message processing operation on the current message after preprocessing through the secondary coroutine.

[0119] Optionally, when the current message is the first message that requires SSL proxy service, the first-level coroutine processing module 220 is used to re-issue the certificate obtained from the server through the first-level coroutine to process the current message using the re-issued certificate.

[0120] Optionally, the network intermediate device is a firewall, and the hardware acceleration device is an acceleration card based on QAT technology.

[0121] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0122] Please refer to Figure 4 , Figure 4 A structural diagram of an electronic device for executing a data processing method provided in an embodiment of the present application, the electronic device may include: at least one processor 310, such as a CPU, at least one communication interface 320, at least one memory 330 and at least one communication bus 340. Among them, the communication bus 340 is used to realize direct connection and communication between these components. Among them, the communication interface 320 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The memory 330 can be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 330 can optionally also be at least one storage device located away from the aforementioned processor. The memory 330 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 310, the electronic device executes the above-mentioned Figure 1 The method process is shown.

[0123] Understandably, Figure 4 The structure shown is for illustration only, and the electronic device may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0124] The present application embodiment provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the following is performed: Figure 1 The method process in the method embodiment shown is executed by the electronic device.

[0125] The present embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided by the above-mentioned method embodiments, for example, including: receiving a current message sent by a server or a client through a message processing process of the network intermediate device, and switching to a first-level coroutine of the SSL proxy service when it is determined that the current message needs to perform an SSL proxy service; preprocessing the current message through the first-level coroutine, and switching to a second-level coroutine of the SSL proxy service after the preprocessing is completed; performing relevant operations specified in the SSL protocol on the current message after the preprocessing is completed through the second-level coroutine, wherein, when the second-level coroutine performs encryption and decryption operations on data, the encryption and decryption operations are submitted to a hardware acceleration device for asynchronous processing.

[0126] In summary, the embodiments of the present application provide a data processing method, device, electronic device and storage medium. The method designs a first-level coroutine and a second-level coroutine under the SSL proxy service. The two-level coroutines are respectively used to process the messages that need to perform the SSL proxy service, which can realize the layering of the code logic level and effectively improve the processing performance of the SSL proxy service. The message processing process of the network intermediate device can receive messages of various services and process them accordingly, so that the network intermediate device can process messages in more business scenarios, not just the messages of the SSL proxy service, which can improve the performance of the network intermediate device in processing other businesses. And in the scheme of the present application, the encryption and decryption operations are sent to the hardware acceleration device for processing, which can give full play to the performance of the hardware acceleration device, reduce the consumption of computing resources of the CPU in the network intermediate device, and further improve the performance of the CPU in processing concurrent businesses.

[0127] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0128] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0129] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0130] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0131] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A data processing method, characterized in that: Applied to a network intermediate device, the network intermediate device is deployed with an SSL proxy service, and the method includes: Receiving a current message sent by a server or a client through a message processing process of the network intermediate device, and switching to a first-level coroutine of the SSL proxy service when it is determined that the current message needs to be subjected to an SSL proxy service, wherein the message processing process is used to process a variety of business messages, and the various business messages include messages of the SSL proxy service; Preprocess the current message through the first-level coroutine, and switch to the second-level coroutine of the SSL proxy service after the preprocessing is completed; The secondary coroutine performs relevant operations specified in the SSL protocol on the current message after preprocessing is completed, wherein when the secondary coroutine performs encryption and decryption operations on data, the encryption and decryption operations are submitted to the hardware acceleration device for asynchronous processing; Wherein, after submitting the encryption and decryption operation to the hardware acceleration device for asynchronous processing through the secondary coroutine, the method further includes: Save the execution scene of the secondary coroutine and switch back to the primary coroutine; Save the execution scene of the first-level coroutine and switch back to the message processing process; Monitoring the task processing result of the encryption and decryption operation through the message processing process; After switching back to the first-level coroutine, the method further includes: Adding the encryption and decryption operation task to the hardware execution task queue through the first-level coroutine; The monitoring of the task processing result of the encryption and decryption operation through the message processing process includes: The task processing result of the encryption and decryption operation in the hardware execution task queue is monitored through the message processing process, wherein the task processing result is marked by the hardware acceleration device in the hardware execution task queue.

2. The method according to claim 1, characterized in that The method further comprises: After the message processing process detects that the task processing of the encryption and decryption operation is completed, the execution scene of the first-level coroutine is restored through the message processing process, and the execution scene is switched to the first-level coroutine; Restore the execution scene of the second-level coroutine through the first-level coroutine, and switch to the second-level coroutine; The result of the encryption and decryption operation is obtained from the hardware acceleration device through the secondary coroutine, and the related operations specified by the SSL protocol are continued to be executed.

3. The method according to claim 1, characterized in that The performing of the relevant operations specified in the SSL protocol on the current message after the preprocessing is completed by the secondary coroutine includes: The secondary coroutine performs an SSL handshake negotiation operation or a corresponding message processing operation on the current message after preprocessing is completed.

4. The method according to claim 1, characterized in that When the current message is the first message that needs to be served by the SSL proxy service, the preprocessing of the current message by the first-level coroutine includes: The certificate obtained from the server is re-issued through the first-level coroutine, so as to process the current message using the re-issued certificate.

5. The method according to any one of claims 1 to 4, characterized in that: The network intermediate device is a firewall, and the hardware acceleration device is an acceleration card based on QAT technology.

6. A data processing device, characterized in that: Running on a network intermediate device, the network intermediate device is deployed with an SSL proxy service, and the device includes: A coroutine switching module, used for receiving a current message sent by a server or a client through a message processing process of the network intermediate device, and switching to a first-level coroutine of the SSL proxy service when it is determined that the current message needs to be provided with an SSL proxy service, wherein the message processing process is used for processing a variety of business messages, and the various business messages include messages of the SSL proxy service; A first-level coroutine processing module, used for preprocessing the current message through the first-level coroutine, and switching to the second-level coroutine of the SSL proxy service after the preprocessing is completed; A secondary coroutine processing module, used to perform relevant operations specified in the SSL protocol on the current message after preprocessing through the secondary coroutine, wherein when the secondary coroutine performs encryption and decryption operations on data, the encryption and decryption operations are submitted to the hardware acceleration device for asynchronous processing; Wherein, the device further comprises: A monitoring module, used to save the execution site of the secondary coroutine and switch back to the primary coroutine; save the execution site of the primary coroutine and switch back to the message processing process; monitor the task processing result of the encryption and decryption operation through the message processing process; Among them, the monitoring module is also used to add the task of the encryption and decryption operation to the hardware execution task queue through the first-level coroutine; and monitor the task processing result of the encryption and decryption operation in the hardware execution task queue through the message processing process, wherein the task processing result is marked by the hardware acceleration device in the hardware execution task queue.

7. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 5 is executed.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is performed.