Data transmission methods, devices, storage media, and electronic equipment
By performing handshake negotiation and data transmission in the operating system kernel mode, the vulnerability of virus implantation caused by insufficient security in user mode is resolved, and the security of data transmission is improved.
Patent Information
- Application Number
- CN202210833740.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2042-07-15
AI Technical Summary
During data transmission, the security of the user-space operating system is difficult to guarantee, which can lead to potential risks such as virus implantation during the handshake negotiation process, thereby affecting the security of data transmission.
The handshake negotiation operation is performed in the operating system kernel mode, and data transmission is confined to the kernel mode environment to improve the security of handshake negotiation and data transmission.
By confining handshake negotiation and data transmission to the operating system kernel mode, the probability of virus implantation is reduced, the execution security of handshake negotiation is directly improved, and the security of data transmission is indirectly guaranteed.
Smart Images

Figure CN117440025B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a data transmission method, apparatus, storage medium, and electronic device. Background Technology
[0002] In data transmission scenarios, a handshake negotiation is typically performed using the device's operating system user space, and data transmission only occurs after the handshake negotiation is successful. However, because the security of the user-space operating system is difficult to guarantee, it is hard to ensure that potential risks such as virus injection can occur during the handshake negotiation process, thus significantly jeopardizing the security of data transmission. Therefore, related technologies suffer from low data transmission security.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a data transmission method, apparatus, storage medium, and electronic device to at least address the technical problem of low data transmission security.
[0005] According to one aspect of the embodiments of this application, a data transmission method is provided, comprising: receiving a data packet sent by the user mode of the operating system of a first device; performing the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of a second device when the handshake negotiation function in the kernel mode of the operating system of the first device is enabled and the handshake negotiation operation has not yet been performed; and transmitting the data packet to the operating system kernel mode of the second device after the handshake negotiation operation has been completed, and returning the transmission result to the user mode of the operating system of the first device.
[0006] According to another aspect of the embodiments of this application, a data transmission apparatus is also provided, comprising: a receiving unit, configured to receive a data packet sent by the user mode of the operating system of a first device; an execution unit, configured to perform the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of a second device when the handshake negotiation function in the kernel mode of the operating system of the first device is enabled and the handshake negotiation operation has not yet been performed; and a transmission unit, configured to transmit the data packet to the operating system kernel mode of the second device after the handshake negotiation operation has been completed, and return the transmission result to the user mode of the operating system of the first device.
[0007] As an optional solution, the execution unit includes: a first sending module, configured to send a first negotiation message to the operating system kernel of the second device when the handshake negotiation function in the operating system kernel of the first device is enabled and the handshake negotiation operation has not yet been performed, wherein the first negotiation message carries a first synchronization sequence number; a first receiving module, configured to receive a negotiation response message from the operating system kernel of the second device, wherein the negotiation response message carries a second synchronization sequence number and an acknowledgment character for the first synchronization sequence number; and a second sending module, configured to send a second negotiation message to the operating system kernel of the second device when indicated by the negotiation response message, and to determine that the handshake negotiation operation has been completed after the second negotiation message has been sent, wherein the second negotiation message carries an acknowledgment character for the second synchronization sequence number.
[0008] As an optional solution, the above apparatus further includes: a third sending module, configured to send the first negotiation message to the operating system user mode of the second device after receiving the data packet sent by the operating system user mode of the first device, when the handshake negotiation function in the operating system kernel mode of the first device is disabled and the handshake negotiation operation has not yet been performed; a second receiving module, configured to receive the negotiation response message fed back by the operating system user mode of the second device after receiving the data packet sent by the operating system user mode of the first device; and a fourth sending module, configured to send the second negotiation message to the operating system user mode of the second device after receiving the data packet sent by the operating system user mode of the first device, when indicated by the negotiation response message, and to determine that the handshake negotiation operation has been completed after the second negotiation message has been sent.
[0009] As an optional solution, the first sending module includes: an acquisition submodule, configured to acquire negotiation information to be sent from the operating system kernel of the first device, and at least one extension item to be associated with the negotiation information; a determination submodule, configured to determine a first attribute type of the negotiation information and a second attribute type of each of the at least one extension item; an establishment submodule, configured to establish an association between the negotiation information and a target extension item, and use the association to package the target extension item and the negotiation information to obtain the first negotiation message, wherein the target extension item is an extension item whose similarity between the second attribute type and the first attribute type reaches a target threshold among the at least one extension item; and a sending submodule, configured to send the first negotiation message to the operating system kernel of the second device.
[0010] As an optional solution, before performing the handshake negotiation operation on the user mode of the operating system of the first device and the kernel mode of the operating system of the second device, the apparatus includes: a configuration unit, configured to configure the handshake function parameters corresponding to the kernel mode of the operating system of the first device in response to a configuration instruction triggered on the kernel mode of the operating system of the first device, wherein the handshake function parameters are function parameters associated with the handshake negotiation operation.
[0011] As an optional solution, the above configuration unit includes at least one of the following: a first configuration module, configured to configure handshake function parameters indicating whether to enable the handshake negotiation function in the operating system kernel mode of the first device; a second configuration module, configured to configure handshake function parameters indicating whether to enable encryption and decryption functions, wherein the encryption and decryption functions include encryption functions used when encapsulating the data packets and decryption functions used when parsing the received data packets; a third configuration module, configured to configure handshake function parameters indicating the key exchange mode of the encryption and decryption functions, wherein the key exchange mode is the handshake function of the first device during the execution of the handshake negotiation operation. The system kernel mode and the operating system kernel mode of the second device are configured to exchange keys; the fourth configuration module is configured to configure handshake function parameters indicating whether to enable the early data function, wherein the early data function is the function that allows the transmission of the data packets during the execution of the handshake negotiation operation; the fifth configuration module is configured to configure handshake function parameters indicating the encryption suite, wherein the encryption suite is the combination of encryption algorithms indicated by the first device and used to implement the encryption function; the sixth configuration module is configured to configure handshake function parameters indicating the algorithm used for the digital signature, wherein the digital signature is the encrypted signature used during the execution of the handshake negotiation operation.
[0012] As an optional solution, the above-mentioned apparatus includes: a first acquisition module, configured to acquire, after configuring the handshake function parameters for indicating the encryption suite, the current negotiation stage in which the operating system kernel of the first device performs the handshake negotiation operation, wherein the handshake negotiation operation includes multiple negotiation stages, and the multiple negotiation stages include the current negotiation stage; a determination module, configured to, after configuring the handshake function parameters for indicating the encryption suite, determine a target suite parameter matching the current negotiation stage from the handshake function parameters for indicating the encryption suite, wherein the handshake function parameters for indicating the encryption suite include multiple encryption suite parameters, and the multiple encryption suite parameters include the target suite parameter; and an encryption module, configured to, after configuring the handshake function parameters for indicating the encryption suite, use the target suite parameter to implement the encryption operation of the operating system kernel of the first device in the current negotiation stage.
[0013] As an optional solution, the above-mentioned apparatus includes: a first parsing unit, configured to, during the handshake negotiation operation performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device, when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message received by the operating system kernel mode of the first device is plaintext, call a parsing function corresponding to the type of the negotiation message to parse the negotiation message and obtain a first parsing result; or, a second parsing unit, configured to, during the handshake negotiation operation performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device, when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message is ciphertext, decrypt the negotiation message to obtain the type of the negotiation message; and call a parsing function corresponding to the type of the negotiation message to parse the negotiation message and obtain a second parsing result.
[0014] As an optional solution, the transmission unit includes: a second acquisition module, configured to acquire target transmission parameters associated with the handshake negotiation operation after the handshake negotiation operation has been completed, wherein the target transmission parameters are data for data transmission determined between the operating system kernel state of the first device and the operating system kernel state of the second device through the execution of the handshake negotiation operation; an encapsulation module, configured to encapsulate the data packet using the target transmission parameters to obtain a target data packet; and a transmission module, configured to transmit the target data packet to the operating system kernel state of the second device.
[0015] As an optional solution, the above-mentioned device includes: a third receiving module, configured to receive a first data packet transmitted by the operating system kernel of the second device after performing the handshake negotiation operation on the operating system kernel of the first device and the operating system kernel of the second device, wherein the first data packet is a data packet obtained by the operating system kernel of the second device encapsulating the second data packet using the target transmission parameters; and a decapsulation module, configured to decapsulate the first data packet using the target transmission parameters after performing the handshake negotiation operation on the operating system kernel of the first device and the operating system kernel of the second device to obtain the second data packet.
[0016] According to another aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data transmission method described above.
[0017] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described data transmission method through the computer program.
[0018] In this embodiment, a data packet sent by the user mode of the operating system of the first device is received. If the handshake negotiation function in the kernel mode of the operating system of the first device is enabled but the handshake negotiation operation has not yet been performed, the handshake negotiation operation is performed between the kernel mode of the operating system of the first device and the kernel mode of the operating system of the second device. If the handshake negotiation operation has been completed, the data packet is transmitted to the kernel mode of the operating system of the second device, and the transmission result is returned to the user mode of the operating system of the first device. By utilizing the high stringency of the operating environment of the operating system kernel mode, the execution environment of the handshake negotiation operation is limited to the operating system kernel mode, thereby reducing the probability of potential risks such as virus implantation during the handshake negotiation phase. This directly improves the execution security of the handshake negotiation operation. Furthermore, the high security of the preceding steps indirectly ensures the security of data transmission in subsequent steps. In addition, limiting data transmission to the operating environment of the operating system kernel mode further directly ensures the security of data transmission, thus achieving the technical effect of improving the security of data transmission and solving the technical problem of low data transmission security. Attached Figure Description
[0019] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0020] Figure 1 This is a schematic diagram of an application environment for an optional data transmission method according to an embodiment of this application;
[0021] Figure 2 This is a schematic diagram of the flow of an optional data transmission method according to an embodiment of this application;
[0022] Figure 3 This is a schematic diagram of an optional data transmission method according to an embodiment of this application;
[0023] Figure 4 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0024] Figure 5 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0025] Figure 6 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0026] Figure 7 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0027] Figure 8 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0028] Figure 9 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0029] Figure 10 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0030] Figure 11 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0031] Figure 12 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0032] Figure 13 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0033] Figure 14This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0034] Figure 15 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0035] Figure 16 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0036] Figure 17 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0037] Figure 18 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0038] Figure 19 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0039] Figure 20 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0040] Figure 21 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0041] Figure 22 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0042] Figure 23 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0043] Figure 24 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0044] Figure 25 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0045] Figure 26 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0046] Figure 27 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0047] Figure 28 This is a schematic diagram of another optional data transmission method according to an embodiment of this application;
[0048] Figure 29This is a schematic diagram of an optional data transmission device according to an embodiment of this application;
[0049] Figure 30 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0050] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0051] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0052] For ease of understanding, the following is an explanation of the terms used in this application:
[0053] Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to achieve data computing, storage, processing, and sharing.
[0054] Cloud technology is a collective term for network technologies, information technologies, integration technologies, management platform technologies, and application technologies applied to the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0055] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and server can be connected directly or indirectly through wired or wireless communication methods, which is not limited herein.
[0056] Transport Layer Security (TLS) is a protocol used in network communication to ensure the security of network transmission. It includes mechanisms for negotiating encryption / decryption algorithms, key generation, and authentication.
[0057] Client: The end that actively initiates a connection in network communication.
[0058] Server: The end in network communication that accepts client connection requests.
[0059] Connection: The transport layer connection established between two parties in network communication.
[0060] Handshake: The TLS connection establishment process can be divided into two phases. The first phase is the handshake negotiation phase (control plane). When the client and server establish a connection, they negotiate the relevant parameters of the connection through the handshake, such as the encryption and decryption algorithms used, certificates, etc., and perform identity authentication. The second phase is the data transmission phase (data plane), in which the plaintext to be transmitted is encrypted and encapsulated into ciphertext for transmission.
[0061] Message Extensions: A message can contain multiple extensions. Each extension is used to negotiate parameters used by the server and client when communicating under TLS, such as certificate type and encryption / decryption algorithm parameters.
[0062] Transcript hash: Performs hash calculations based on the sent and received handshake messages. The calculation results are used to further calculate secrets, verify certificates, etc.
[0063] Secret, Traffic key: The key used in the TLS encryption and decryption process; different keys are used at different stages of the handshake negotiation.
[0064] According to one aspect of the embodiments of this application, a data transmission method is provided. Optionally, as an optional implementation, the above-described data transmission method may be applied to, but is not limited to, [examples of other methods]. Figure 1 The environment shown may include, but is not limited to, user equipment 102 and server 112. User equipment 102 may include, but is not limited to, a display 108, a processor 106 and a memory 104. Server 112 includes a database 114 and a processing engine 116.
[0065] The specific process can be summarized in the following steps:
[0066] In step S102, the user device 102 in the operating system kernel mode receives the data packet sent by the user device 102 in the operating system user mode. If the handshake negotiation function in the user device 102 in the operating system kernel mode is enabled and the handshake negotiation operation has not yet been performed, the user device 102 in the operating system kernel mode and the operating system kernel mode of the second device perform a handshake negotiation operation. The handshake negotiation operation includes the following steps S104, S106, S108, S110, and S112.
[0067] Steps S104-S106: The first target negotiation message of the user device 102 in the operating system kernel mode is sent to the server 112 through the network 110;
[0068] In step S108, server 112 processes the first target negotiation message of user device 102 in operating system kernel mode through processing engine 116 to obtain the second target negotiation information of server 112 in operating system kernel mode.
[0069] In steps S110-S112, the second target negotiation information is sent to the user equipment 102 via the network 110. The user equipment 102 processes the second target negotiation information via the processor 106, displays the execution status of the handshake negotiation operation on the display 108, stores the second target negotiation information in the memory 104, and then continues to execute subsequent handshake negotiation operations until the handshake negotiation operation is completed.
[0070] remove Figure 1 Beyond the examples shown, the above steps can be completed with client assistance, i.e., the client can perform steps such as obtaining the second target negotiation information, thereby reducing the processing load on the server. The user equipment 102 includes, but is not limited to, handheld devices (such as mobile phones), laptops, desktop computers, in-vehicle devices, etc., and this application does not limit the specific implementation of the user equipment 102.
[0071] Alternatively, as an alternative implementation method, such as Figure 2 As shown, the data transmission method includes:
[0072] S202, Receive data packets sent by the user mode of the operating system of the first device;
[0073] S204, if the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed, perform the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device.
[0074] S206, after the handshake negotiation operation has been completed, transmit the data packet to the operating system kernel mode of the second device, and return the transmission result to the operating system user mode of the first device.
[0075] Optionally, in this embodiment, the above data transmission method can be applied to, but is not limited to, all application scenarios requiring network communication transmission, especially those with high network security requirements, such as financial payments, digital RMB, and metaverse. It is also applicable to other application scenarios that rely on network communication, such as network storage.
[0076] Specifically, the aforementioned data transmission method can be applied, but is not limited to, scenarios using the Linux operating system. Specifically, it utilizes the TLS handshake function implemented in the Linux kernel space and stores the TLS key and ciphertext in the Linux kernel space, thus providing higher security. Furthermore, compared to the implementation of the TLS protocol in Linux user space, which involves multiple interactions between Linux user space and Linux kernel space, the implementation of the TLS protocol in this embodiment does not involve interactions between Linux user space and Linux kernel space, thereby reducing performance overhead and improving the efficiency of TLS protocol implementation.
[0077] Optionally, in this embodiment, the first device and the second device can be understood as, but are not limited to, client or server or other main devices with execution functions, such as the first device being a client and the second device being a server.
[0078] Optionally, in this embodiment, the operating system user mode and operating system kernel mode can be understood as two operating states of the operating system, but are not limited to. Taking the operating system user mode as an example, the central processing unit (CPU) in the operating system user mode can only access memory in a limited way and is not allowed to access peripheral devices. The CPU in the operating system user mode is not allowed to monopolize, or it can be understood that the CPU in the operating system user mode can be acquired by other programs. Taking the operating system kernel mode as another example, the CPU in the operating system kernel mode can access any data, including peripheral devices such as network cards and hard disk lights. Taking the operating system kernel mode as another example, the CPU in the operating system kernel mode can switch from one program to another, and there will be no preemption when occupying the CPU. For example, the privilege level 0 state can be regarded as the operating system kernel mode.
[0079] It is evident that the operating environment in user mode is more permissive than that in kernel mode (e.g., the CPU in user mode can be accessed by other programs), and is more susceptible to intrusion by malicious programs (such as computer viruses). In other words, the operating environment in user mode is less secure than that in kernel mode.
[0080] For operating system user mode, related technologies typically configure the CPU in user mode to perform technical operations for product testing. For operating system kernel mode, related technologies typically configure the CPU in user mode to perform background testing operations. Therefore, for operations closer to product testing, such as handshake negotiation and data transfer, related technologies usually instruct the CPU in user mode to perform these operations. However, because the CPU in user mode needs to frequently access critical data when performing handshake negotiation and data transfer operations, the interaction between operating system user mode and operating system kernel mode becomes frequent, resulting in significant performance degradation.
[0081] Furthermore, since the handshake negotiation process involves various types of private data, such as the secret key generated during the handshake negotiation, a less secure operating environment can easily lead to the loss of this private data. Moreover, both the handshake negotiation process and the data transmission process involve the interaction between at least two devices. If any of these at least two devices is compromised by a malicious program, the other device will also be compromised by the same malicious program. Thus, improving the security of the operating environment can reduce the probability of devices being compromised by malicious programs, thereby improving the overall security of the at least two devices.
[0082] Optionally, in this embodiment, the handshake negotiation function can be flexibly enabled or disabled, such as enabling the handshake negotiation function when it is enabled, and disabling the handshake negotiation function when it is disabled, thus disabling the handshake negotiation function. Furthermore, when the handshake negotiation function is enabled, handshake negotiation operations are allowed to be performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device; conversely, when the handshake negotiation function is disabled, normal operation is restored, and handshake negotiation operations are performed on the operating system user mode of the first device and the operating system user mode of the second device, so as to meet different needs in daily use.
[0083] Optionally, in this embodiment, the handshake negotiation operation can be understood as, but is not limited to, the operation of establishing a connection protocol between at least two devices. For example, by performing a handshake negotiation operation on the client (first device) and the server (second device), the client and the server can confirm each other's identities and establish a standardized connection protocol. In addition, in order to protect the data transmitted in the record encapsulation, the handshake negotiation operation can also be, but is not limited to, assisting the client and the server in selecting the encryption algorithm, MAC algorithm, related keys, etc. used when connecting.
[0084] Optionally, in this embodiment, performing a handshake negotiation operation with the operating system kernel of the first device, and transmitting data packets to the operating system kernel of the second device can be understood, but is not limited to, performing a handshake negotiation operation and transmitting data packets in the operating system kernel of the first device.
[0085] Optionally, in this embodiment, receiving the data packet sent by the operating system user space of the first device and returning the transmission result to the operating system user space of the first device can be understood, but is not limited to, performing operations such as internal sending and internal return of the data packet in the operating system user space of the first device;
[0086] To further illustrate, alternatively, for example... Figure 3As shown, the operating system user mode is responsible for performing internal data packet sending and internal return operations, while the operating system kernel mode is responsible for performing handshake negotiation operations and data packet transmission operations. For example, the operating system user mode of the first device 302 performs the internal data packet sending operation, sending the data packet internally to the operating system kernel mode of the first device 302. Then, the operating system kernel mode of the first device 302 performs the handshake negotiation operation with the operating system kernel mode of the second device 304. After the handshake negotiation operation is completed, the operating system kernel mode of the first device 302 performs the data transmission operation with the operating system kernel mode of the second device 304 and returns the operation result to the operating system user mode of the first device 302. For the second device 304, the operating system kernel mode of the second device 304 receives the data packet and returns the data packet to the operating system user mode of the second device 304.
[0087] It should be noted that by leveraging the high stringency of the operating system kernel environment, the handshake negotiation operation is confined to the operating system kernel environment. This reduces the probability of potential risks such as virus implantation during the handshake negotiation phase, thereby directly improving the execution security of the handshake negotiation operation. Furthermore, the high security of the preceding steps indirectly ensures the security of data transmission in subsequent steps. In addition, confining data transmission to the operating system kernel environment further directly ensures the security of data transmission, thus improving the overall security of data transmission.
[0088] To further illustrate, optional examples include... Figure 4 As shown, the system receives data packets sent by the user mode of the operating system of the first device 402; when the handshake negotiation function in the kernel mode of the operating system of the first device 402 is enabled and the handshake negotiation operation has not yet been performed, the system performs a handshake negotiation operation between the kernel mode of the operating system of the first device 402 and the kernel mode of the operating system of the second device 404; when the handshake negotiation operation has been completed, the system transmits data packets to the kernel mode of the operating system of the second device 404 and returns the transmission result to the user mode of the operating system of the first device 402.
[0089] The embodiments provided in this application receive data packets sent by the user mode of the operating system of the first device. When the handshake negotiation function in the kernel mode of the operating system of the first device is enabled but the handshake negotiation operation has not yet been performed, a handshake negotiation operation is performed between the kernel mode of the operating system of the first device and the kernel mode of the operating system of the second device. Once the handshake negotiation operation is completed, data packets are transmitted to the kernel mode of the operating system of the second device, and the transmission result is returned to the user mode of the operating system of the first device. By utilizing the high stringency of the operating environment of the operating system kernel mode, the execution environment of the handshake negotiation operation is limited to the operating system kernel mode, thereby reducing the probability of potential risks such as virus implantation during the handshake negotiation phase. This directly improves the execution security of the handshake negotiation operation. Furthermore, the high security of the preceding steps indirectly ensures the security of data transmission in subsequent steps. In addition, limiting data transmission to the operating environment of the operating system kernel mode further directly ensures the security of data transmission, thus achieving the technical effect of improving the security of data transmission.
[0090] As an optional approach, if the handshake negotiation function in the operating system kernel mode of the first device is enabled but the handshake negotiation operation has not yet been performed, the handshake negotiation operation is performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device, including:
[0091] S1, when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed, a first negotiation message is sent to the operating system kernel mode of the second device, wherein the first negotiation message carries a first synchronization sequence number;
[0092] S2, receive a negotiation response message from the operating system kernel mode of the second device, wherein the negotiation response message carries an acknowledgment character for the second synchronization sequence number and the first synchronization sequence number;
[0093] S3, upon receiving the negotiation response message indication, sends a second negotiation message to the operating system kernel mode of the second device, and after the second negotiation message is sent, determines that the handshake negotiation operation has been completed. The second negotiation message carries an acknowledgment character of the second synchronization sequence number.
[0094] Optionally, in this embodiment, the synchronization sequence number may be, but is not limited to, the handshake signal used in the handshake negotiation process. For example, the first device first sends a SYN message (first negotiation message), and the second device responds with another SYN+ACK message (negotiation response message) to indicate that it has received the SYN message sent by the first device. Finally, the first device responds with a separate ACK message (second negotiation message). In this way, a reliable TCP connection is established between the first device and the second device, and subsequent data transmission is carried out through this TCP connection.
[0095] To further illustrate, the optional based on Figure 4 The scenario shown continues, for example... Figure 5 As shown, the specific steps are as follows:
[0096] Step S502: When the handshake negotiation function in the operating system kernel mode of the first device 402 is enabled and the handshake negotiation operation has not yet been performed, a first negotiation message is sent to the operating system kernel mode of the second device 404, wherein the first negotiation message carries a first synchronization sequence number.
[0097] Step S504: Receive a negotiation response message from the operating system kernel mode of the second device 404, wherein the negotiation response message carries an acknowledgment character for the second synchronization sequence number and the first synchronization sequence number;
[0098] In step S506, upon receiving the negotiation response message indication, a second negotiation message is sent to the operating system kernel mode of the second device 404, and after the second negotiation message is sent, it is determined that the handshake negotiation operation has been completed. The second negotiation message carries an acknowledgment character of the second synchronization sequence number.
[0099] The embodiments provided in this application, when the handshake negotiation function in the operating system kernel mode of the first device is enabled but the handshake negotiation operation has not yet been performed, send a first negotiation message to the operating system kernel mode of the second device, wherein the first negotiation message carries a first synchronization sequence number; receive a negotiation response message from the operating system kernel mode of the second device, wherein the negotiation response message carries a second synchronization sequence number and an acknowledgment character for the first synchronization sequence number; when indicated by the negotiation response message, send a second negotiation message to the operating system kernel mode of the second device, and after the second negotiation message is sent, determine that the handshake negotiation operation has been completed, wherein the second negotiation message carries an acknowledgment character for the second synchronization sequence number. By placing the handshake negotiation operation in the kernel mode for execution, the technical effect of improving the security of data transmission is achieved.
[0100] As an optional approach, after receiving the data packet sent by the operating system user space of the first device, the method further includes:
[0101] S1, if the handshake negotiation function in the kernel mode of the operating system of the first device is disabled and the handshake negotiation operation has not been performed, send the first negotiation message to the user mode of the operating system of the second device.
[0102] S2, receive the negotiation response message from the user space of the operating system of the second device;
[0103] S3, upon receiving the negotiation response message indication, sends a second negotiation message to the user space of the second device's operating system, and after the second negotiation message is sent, determines that the handshake negotiation operation has been completed.
[0104] Optionally, in this embodiment, whether the handshake negotiation operation is executed in the user mode of the operating system or in the kernel mode of the operating system can be controlled, but is not limited to, by whether the handshake negotiation function in the kernel mode of the operating system is enabled. If the handshake negotiation function is enabled, it means that the handshake negotiation operation is executed in the user mode of the operating system; otherwise, if the handshake negotiation function is disabled, it means that the handshake negotiation operation is executed in the kernel mode of the operating system.
[0105] To further illustrate, the optional based on Figure 4 The scenario shown continues, for example... Figure 6 As shown, when the handshake negotiation function is enabled (shaded), the handshake negotiation operation between the first device 402 and the second device 404 will be executed in the operating system kernel mode; conversely, when the handshake negotiation function is disabled (unshaded), the handshake negotiation operation between the first device 402 and the second device 404 will be executed in the operating system user mode.
[0106] Optionally, in this embodiment, the enable or disable state of the handshake negotiation function can affect, but is not limited to, the execution mode of the handshake negotiation operation, and can also affect, but is not limited to, the execution mode of operations such as data transmission. For example, when the handshake negotiation function is enabled, the handshake negotiation operation and the data transmission operation will be executed in the operating system kernel mode; conversely, when the handshake negotiation function is disabled, the handshake negotiation operation and the data transmission operation will be executed in the operating system user mode.
[0107] Optionally, in this embodiment, whether the handshake negotiation function is enabled or disabled may affect, but is not limited to, only the execution mode of the handshake negotiation operation. For operations such as data transmission, it may be determined by whether the corresponding operation function is enabled. For example, when the data transmission function is enabled, the data transmission operation will be executed in the operating system kernel mode; conversely, when the data transmission function is disabled, the data transmission operation will be executed in the operating system user mode.
[0108] Through the embodiments provided in this application, when the handshake negotiation function in the kernel mode of the operating system of the first device is disabled and the handshake negotiation operation has not yet been performed, a first negotiation message is sent to the user mode of the operating system of the second device; a negotiation response message is received from the user mode of the operating system of the second device; when indicated by the negotiation response message, a second negotiation message is sent to the user mode of the operating system of the second device; and after the second negotiation message is sent, it is determined that the handshake negotiation operation has been completed. By using different execution methods of the handshake negotiation operation, diverse usage requirements can be adapted, thereby achieving the technical effect of improving the adaptability of the handshake negotiation operation.
[0109] As an optional approach, a first negotiation message is sent to the operating system kernel mode of the second device, including:
[0110] S1, obtain the negotiation information to be sent in the operating system kernel mode of the first device, and at least one extension item to be associated with the negotiation information;
[0111] S2, determine the first attribute type of the negotiation information, and the second attribute type of each of the at least one extension item;
[0112] S3, establish the association between the negotiation information and the target extension item, and use the association to package the target extension item and the negotiation information to obtain the first negotiation message, wherein the target extension item is an extension item in at least one extension item whose similarity between the second attribute type and the first attribute type reaches the target threshold;
[0113] S4 sends the first negotiation message to the operating system kernel of the second device.
[0114] Optionally, in this embodiment, in order to improve the richness of the negotiation information, it is possible, but not limited to, to allow more information content to be transmitted through extension items in addition to the content of the negotiation information (such as expanding the original information content, adding more functional implementations, etc.). However, in order to reduce the probability of abnormal situations caused by extension items, the similarity between the attribute type of the extension item and the attribute type of the negotiation information is limited to reach the target threshold.
[0115] The embodiments provided in this application obtain negotiation information to be sent from the operating system kernel of a first device, as well as at least one extension item to be associated with the negotiation information; determine the first attribute type of the negotiation information and the second attribute type of each extension item in the at least one extension item; establish an association relationship between the negotiation information and the target extension item, and use the association relationship to package the target extension item and the negotiation information to obtain a first negotiation message, wherein the target extension item is an extension item in the at least one extension item whose similarity between the second attribute type and the first attribute type reaches a target threshold; and send the first negotiation message to the operating system kernel of the second device, thereby achieving the technical effect of improving the content richness of the negotiation information while ensuring the smooth transmission of the negotiation information.
[0116] As an optional approach, before performing handshake negotiation operations between the user mode of the first device's operating system and the kernel mode of the second device's operating system, the method includes:
[0117] In response to a configuration command triggered by the operating system kernel mode of the first device, the handshake function parameters corresponding to the operating system kernel mode of the first device are configured, wherein the handshake function parameters are function parameters associated with the handshake negotiation operation.
[0118] Optionally, in this embodiment, the handshake function parameters are function parameters associated with the handshake negotiation operation, such as parameters indicating whether the handshake negotiation function is enabled, parameters indicating the operation associated with the handshake negotiation function to be executed, etc.
[0119] As an optional approach, the handshake function parameters corresponding to the operating system kernel mode of the first device are configured, including at least one of the following:
[0120] Configure handshake function parameters used to indicate whether to enable the handshake negotiation function in the operating system kernel mode of the first device;
[0121] Configure handshake function parameters to indicate whether encryption and decryption functions are enabled. The encryption and decryption functions include encryption functions used when encapsulating data packets and decryption functions used when parsing received data packets.
[0122] Configure handshake function parameters for indicating the key exchange mode of encryption and decryption functions, wherein the key exchange mode is the mode in which the operating system kernel mode of the first device and the operating system kernel mode of the second device exchange keys during the execution of the handshake negotiation operation;
[0123] Configure handshake function parameters to indicate whether the early data function is enabled, where the early data function is the function that allows the transmission of data packets during the execution of the handshake negotiation operation;
[0124] Configure handshake function parameters for indicating cipher suites, wherein the cipher suite is a combination of encryption algorithms indicated by the first device for implementing encryption functions;
[0125] Configure handshake function parameters to indicate the algorithm used for the digital signature, where the digital signature is the cryptographic signature used during the execution of the handshake negotiation operation.
[0126] Optionally, in this embodiment, handshake function parameters are configured to indicate whether the handshake negotiation function in the operating system kernel mode of the first device is enabled, such as parameters indicating whether the handshake negotiation function is enabled, parameters indicating the operation execution associated with the handshake negotiation function, etc.
[0127] Optionally, in this embodiment, handshake function parameters are configured to indicate whether the encryption and decryption functions are enabled, such as parameters indicating whether the encryption and decryption functions are enabled, parameters indicating the execution (encapsulation, parsing) of operations associated with the handshake encryption and decryption functions, etc.
[0128] Optionally, in this embodiment, a handshake function parameter is configured to indicate the key exchange mode of the encryption and decryption function. The key exchange mode is the mode in which the operating system kernel mode of the first device and the operating system kernel mode of the second device exchange keys during the execution of the handshake negotiation operation. For example, mode A starts from the first device and ends from the second device. Specifically, the first device sends the first key to the second device, and then the second device sends the second key to the first device to realize the key exchange. Or, mode B starts from the second device and ends from the first device. Specifically, the second device sends the second key to the first device, and then the first device sends the first key to the second device to realize the key exchange.
[0129] Optionally, in this embodiment, a handshake function parameter is configured to indicate whether the early data function is enabled, wherein the early data function is a function that allows the transmission of data packets during the execution of the handshake negotiation operation;
[0130] To further illustrate, only after the handshake negotiation operation is completed is the communication connection between the first device and the second device considered established, thus allowing the first device and the second device to use the aforementioned communication connection to achieve bidirectional or unidirectional data transmission; or, before the handshake negotiation operation is completed, the communication connection between the first device and the second device is not established, thus preventing the first device and the second device from achieving bidirectional or unidirectional data transmission. In this embodiment, by enabling the early data function, the first device and the second device can be allowed to achieve bidirectional or unidirectional data transmission in advance before the handshake negotiation operation is completed, thereby improving the efficiency of data transmission. In addition, for security considerations, the data to be transmitted for the early data function can be, but is not limited to, target data, wherein the target data can be, but is not limited to, data whose security attribute value reaches a preset threshold.
[0131] Optionally, in this embodiment, handshake function parameters for indicating the encryption suite are configured, wherein the encryption suite is a combination of encryption algorithms indicated by the first device when implementing the encryption function;
[0132] To further illustrate, the encryption algorithms used to implement the encryption function may include encryption algorithm A, encryption algorithm B, and encryption algorithm C. When using the above three encryption algorithms, how to use them, such as the order of use and priority of use, may be determined by, but is not limited to, the handshake function parameters used to indicate the encryption suite.
[0133] Optionally, in this embodiment, handshake function parameters are configured to indicate the algorithm used for the digital signature. The digital signature is the encrypted signature used during the execution of the handshake negotiation operation. The digital signature can be understood as, but is not limited to, a public key digital signature, which is a string of numbers that only the sender of the information can generate and that cannot be forged by others. This string of numbers is also a valid proof of the authenticity of the information sent by the sender. It can involve, but is not limited to, the application of asymmetric key encryption technology and digital digest technology.
[0134] As an optional approach, after configuring the handshake function parameters used to indicate the cryptographic suite, the method includes:
[0135] S1, obtain the current negotiation stage when the operating system kernel of the first device performs the handshake negotiation operation, wherein the handshake negotiation operation includes multiple negotiation stages, and the multiple negotiation stages include the current negotiation stage;
[0136] S2, determine the target suite parameter that matches the current negotiation phase from the handshake function parameters used to indicate the cipher suite, wherein the handshake function parameters used to indicate the cipher suite include multiple cipher suite parameters, and the multiple cipher suite parameters include the target suite parameter;
[0137] S3 utilizes the target kit parameters to implement encryption operations in the operating system kernel mode of the first device during the current negotiation phase.
[0138] Optionally, there are various types of encryption operations, but different types of encryption operations can only achieve the best encryption effect in the appropriate application scenario. In this embodiment, the current negotiation stage when the operating system kernel of the first device performs the handshake negotiation operation is first obtained. Then, the target kit parameter that matches the current negotiation stage is determined from the handshake function parameters used to indicate the encryption kit. The encryption operation of the operating system kernel of the first device in the current negotiation stage is implemented using the target kit parameter. By improving the compatibility between the encryption operation and the current negotiation stage, the encryption strength of the encryption operation is improved.
[0139] As an optional approach, the method for performing handshake negotiation operations between the operating system kernel mode of the first device and the operating system kernel mode of the second device includes:
[0140] S1, if the handshake negotiation function in the operating system kernel mode of the first device is enabled, and the negotiation message received by the operating system kernel mode of the first device is plaintext, call the parsing function corresponding to the type of the negotiation message to parse the negotiation message and obtain the first parsing result; or,
[0141] S2, when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message is encrypted, the negotiation message is decrypted to obtain the type of the negotiation message; the parsing function corresponding to the type of the negotiation message is called to parse the negotiation message and obtain the second parsing result.
[0142] Optionally, in this embodiment, when a negotiation message is received, a corresponding parsing operation is performed based on the message attributes (plaintext or ciphertext) of the negotiation message; similarly, when a negotiation message is to be sent, a corresponding parsing operation is also performed based on the message attributes (plaintext or ciphertext) of the negotiation message.
[0143] To illustrate further, an alternative approach is to first determine whether the negotiation message is plaintext or ciphertext when sending it. If the negotiation message is plaintext, it is directly encapsulated using the record message format and sent to the TCP protocol stack. If the negotiation message is ciphertext, it needs to be encrypted first, then encapsulated, and then sent to the TCP protocol stack.
[0144] Through the embodiments provided in this application, when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message received by the operating system kernel mode of the first device is plaintext, the parsing function corresponding to the type of the negotiation message is called to parse the negotiation message and obtain a first parsing result; or, when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message is ciphertext, the negotiation message is decrypted to obtain the type of the negotiation message; the parsing function corresponding to the type of the negotiation message is called to parse the negotiation message and obtain a second parsing result. This achieves the purpose of matching a highly adaptable parsing method for negotiation messages with different attributes, thereby realizing the technical effect of improving the parsing accuracy of negotiation messages.
[0145] As an optional approach, after the handshake negotiation operation has been completed, data packets are transmitted to the operating system kernel mode of the second device, and the transmission result is returned to the operating system user mode of the first device, including:
[0146] S1, if the handshake negotiation operation has been completed, obtain the target transmission parameters associated with the handshake negotiation operation, wherein the target transmission parameters are the data for data transmission determined between the operating system kernel state of the first device and the operating system kernel state of the second device through the handshake negotiation operation;
[0147] S2, the data packet is encapsulated using the target transmission parameters to obtain the target data packet;
[0148] S3 transmits the target data packet to the operating system kernel mode of the second device.
[0149] Optionally, in this embodiment, after the handshake negotiation operation is completed, the first device and the second device may, but are not limited to, have reached a unified standard protocol, and the standard protocol may, but is not limited to, be reflected through target transmission parameters. In a specific real-time scenario, the target transmission parameters will be used to encapsulate the data to be transmitted subsequently, and only the two parties that have reached the unified standard protocol can use the handshake negotiation operation to parse the encapsulated data.
[0150] As an optional approach, after performing handshake negotiation operations on the operating system kernel mode of the first device and the operating system kernel mode of the second device, the method includes:
[0151] S1, receive the first data packet transmitted by the operating system kernel mode of the second device, wherein the first data packet is the data packet obtained by the operating system kernel mode of the second device encapsulating the second data packet with the target transmission parameters;
[0152] S2, the first data packet is deassembled using the target transmission parameters to obtain the second data packet.
[0153] Optionally, in this embodiment, the first device and the second device are interaction objects, which may be, but are not limited to, data receiving objects or data sending objects in the interaction objects. For example, the first device, as a data receiving object, receives the first data packet transmitted by the operating system kernel mode of the second device, and deassembles the first data packet using the target transmission parameters to obtain the second data packet; or the first device, as a data sending object, encapsulates the data packet using the target transmission parameters to obtain the target data packet, and transmits the target data packet to the operating system kernel mode of the second device.
[0154] As an alternative, for ease of understanding, the above data transmission method is applied to the implementation scenario of the TLS protocol, specifically the implementation of the Linux kernel network protocol stack transport layer. The TLS handshake negotiation process is placed in the Linux kernel state, which has no specific requirements for the hardware environment and is applicable to all hardware environments running the Linux operating system.
[0155] Optionally, in this embodiment, a new KTLS handshake component is added. User-space network applications no longer rely on user-space components such as OpenSSL and Gnutls. After creating a socket, the KTLS handshake negotiation function is enabled, and relevant parameters are configured. Subsequent TLS handshake actions will be completed by the KTLS kernel module. Components such as OpenSSL and Gnutls are typically used in related technologies to complete TLS handshake negotiation and data encryption / decryption. After the handshake is completed, the encryption / decryption of data packets is also completed by the KTLS kernel module.
[0156] To further illustrate, alternatively, for example... Figure 7 As shown, the newly added KTLS handshake component in this embodiment, together with the existing KTLS offload component in the kernel, forms a kernel-mode component (KTLS kernel module). This module collaborates with other kernel components such as strparser and crypto to complete kernel-mode TLS functionality. Furthermore, the KTLS kernel module is built on top of the Linux kernel's TCP / IP protocol stack. Information exchange between the client and server will be implemented through a router or switch. Specific kernel-mode components call the network cards of the client and server for network communication; the network cards may also involve encryption / decryption technologies.
[0157] Optionally, the newly added KTLS handshake component in this embodiment, together with the original KTLS offload component in the kernel, forms a KTLS kernel module, which works with components such as strparser and crypto in the kernel to complete the kernel-mode TLS function.
[0158] To further illustrate, alternatively, for example... Figure 8 As shown, the functions of several key modules in the original Linux kernel are as follows: Strparser is a bridge between the TCP protocol stack and the TLS protocol stack in the receiving direction. Strparser sends the data packets received from the TCP / IP layer to the KTLS module for processing, such as data packets forwarded by the network card; Crypto can be understood, but is not limited to, as the kernel's encryption and decryption module, providing functions such as message digest, signing, and verification.
[0159] Optionally, in this embodiment, the KTLS client initiates the TLS handshake request via the kernel-mode KTLS module. The secret key generated during the handshake negotiation is also stored in kernel mode, further enhancing security and reducing the number of system calls, thus improving performance. The KTLS client process is further as follows: Figure 9 As shown, the specific steps are as follows:
[0160] Step S902: Configure TLS parameters by passing TLS handshake-related parameters to the kernel's KTLS module via the setsockopt system call. These parameters include, but are not limited to: whether to enable the KTLS handshake function, whether to enable the PSK function, the PSK key exchange mode, whether to enable the early data function, which cipher suites the client wants to use, which TLS groups to use, and the algorithm used for digital signatures.
[0161] Step S904: Initialize the KTLS handshake related data structures. In this embodiment, a new struct tls_hsk data structure is added to store KTLS handshake related information, including but not limited to the role of the local end (client or server), the supported TLS version number, the corresponding sock pointer, and the encryption algorithms supported by the local end.
[0162] Step S906: Initiate TCP Connect, and establish a TCP connection with the server through a TCP three-way handshake;
[0163] In step S908, KTLS initiates a TLS handshake request. After the TCP protocol layer connection is successfully established, the KTLS client initiates a TLS protocol layer connection request to the TLS server, that is, constructs and sends a client hello message.
[0164] In step S910, the server returns TLS protocol messages such as "server hello". After that, the client and server conduct a handshake negotiation according to the TLS protocol. The negotiation actions in the TLS handshake phase are all performed within the kernel KTLS module.
[0165] Step S912: Data Transmission. After the KTLS module completes the TLS handshake negotiation, data transmission can begin. Data encryption and decryption operations are performed within the kernel KTLS module, and the decrypted data is sent to the user-space process.
[0166] Optionally, in this embodiment, the processing flow of the TLS server is as follows: Figure 10 As shown, the specific steps are as follows:
[0167] Step S1002: Configure TLS parameters by passing TLS handshake-related parameters to the kernel's KTLS module via the setsockopt system call. These parameters include, but are not limited to: whether to enable the KTLS handshake function, whether to enable the PSK function, the PSK key exchange mode, whether to enable the early data function, which cipher suites the client wants to use, which TLS groups to use, and the algorithm used for digital signatures.
[0168] Step S1004: Initialize the KTLS handshake related data structures. In this embodiment, a new struct tls_hsk data structure is added to store KTLS handshake related information, including but not limited to the role of the local end (client or server), the supported TLS version number, the corresponding sock pointer, and the encryption algorithms supported by the local end.
[0169] Step S1006: Process the client's TCP connect request. After receiving the client's TCP SYN request, the Linux kernel TCP protocol stack completes the TCP three-way handshake and establishes a TCP connection with the client.
[0170] In step S1008, KTLS processes the client's TLS handshake request. After successfully establishing a TCP connection, it begins the TLS handshake negotiation. Upon receiving the client's "client hello" message, the KTLS server returns "server hello" and other TLS protocol messages. Subsequently, the client and server negotiate the handshake according to the TLS protocol. All negotiation actions during the TLS handshake phase are performed within the kernel KTLS module.
[0171] In step S1010, the server returns TLS protocol messages such as "server hello". After that, the client and server conduct a handshake negotiation according to the TLS protocol. The negotiation actions in the TLS handshake phase are all performed within the kernel KTLS module.
[0172] Step S1012: Data Transmission. After the KTLS module completes the TLS handshake negotiation, data transmission can begin. Data encryption and decryption operations are performed within the kernel KTLS module, and the decrypted data is sent to the user-space process.
[0173] To further illustrate, optionally, the main functional components of KTLS Handshake include, for example, Figure 11 As shown, the main functional components of KTLSHandshake include user-space data sending interface, user-space data receiving interface, record parsing and encapsulation, handshake message parsing and encapsulation, ext parsing and encapsulation, Transcript Hash generator, Secret generator, Traffic key generator, Alert encapsulation and parsing, etc.
[0174] Optionally, in this embodiment, the user-space data sending interface uses a client as an example to illustrate the workflow of this component, such as... Figure 12 As shown, when a user-space process calls the `tls_sw_sendmsg()` function to send a packet (this is just one of the packet sending interfaces; the TLS handshake process for other similar interfaces is similar), it first determines whether the KTLS handshake negotiation function is enabled. If not enabled, the original KTLS offload process is followed. If the KTLS handshake negotiation function is enabled but has not yet been performed, a `client hello` message is sent to the server. Upon receiving this message, the server returns `server hello`, `cert`, and other TLS handshake messages. After successful negotiation, the KTLS offload raw data sending process begins. Finally, the sending result is returned to the user-space application process. The specific steps are as follows:
[0175] Step S1202: The user-space process sends a packet;
[0176] Step S1204: Determine whether KTLS HSK is enabled. If yes, proceed to step S1206; otherwise, proceed to step S1214.
[0177] Step S1206: Determine whether TLS has been negotiated. If yes, proceed to step S1214; otherwise, proceed to step S1208.
[0178] Step S1208: Send client hello;
[0179] Step S1210, TLS handshake negotiation;
[0180] Step S1212: Determine whether the negotiation was successful. If yes, proceed to step S1214; otherwise, proceed to step S1216.
[0181] Step S1214, Ktls offload raw data sending process;
[0182] Step S1216: Return the sending result to the user process;
[0183] Step S1218: The user mode receives the returned result.
[0184] Optionally, in this embodiment, the user-space data receiving interface uses the server as an example to illustrate the workflow of this component, such as... Figure 13 As shown, when the user-space process calls the `tls_sw_recvmsg()` function to receive packets (note that this is only one of the interfaces for receiving packets; the TLS handshake process for other similar interfaces is similar), it first determines whether the KTLS handshake negotiation function is enabled. If it is not enabled, the original KTLS offload process is followed. If the KTLS handshake negotiation function is enabled but has not yet been performed, it waits to receive the client's `client hello` message. After receiving this message, the server will return `server hello`, `cert`, and other TLS handshake messages. After successful negotiation, the process enters the KTLS offload raw data packet reception process. Finally, the reception result is returned to the user-space application process. The specific steps are as follows:
[0185] Step S1302: The user-space process sends a packet;
[0186] Step S1304: Determine whether KTLS HSK is enabled. If yes, proceed to step S1306; otherwise, proceed to step S1314.
[0187] Step S1306: Determine whether TLS has been negotiated. If yes, proceed to step S1314; otherwise, proceed to step S1308.
[0188] Step S1308: Send client hello;
[0189] Step S1310, TLS handshake negotiation;
[0190] Step S1312: Determine whether the negotiation was successful. If yes, proceed to step S1314; otherwise, proceed to step S1316.
[0191] Step S1314, Ktls offload raw data transmission process;
[0192] Step S1316: Return the sending result to the user process;
[0193] Step S1318: The user mode receives the returned result.
[0194] Optionally, in this embodiment, Record parsing and encapsulation are responsible for processing the TLS protocol record layer, including record parsing (decryption) and encapsulation (encryption). Taking the record parsing process as an example, the bridge between KTLS and the TCP layer is strp, which is responsible for sending TCP packets to the kTLS module for processing. If KTLS's handshake function is not enabled, the original packet processing flow of kTLS offload is followed; otherwise, the KTLS module parses the record. If it is plaintext, the parsing function corresponding to the record type is called directly. If it is ciphertext, the packet needs to be decrypted first to obtain the actual record type. Finally, the processing result is returned, and further processing is performed as follows... Figure 14 As shown, the specific steps are as follows:
[0195] Step S1402: Send the TCP packet to the KTLS module for processing;
[0196] Step S1404: Determine whether KTLS HSK is enabled. If yes, proceed to step S1408; otherwise, proceed to step S1406.
[0197] Step S1406, Ktls offload raw data reception process;
[0198] Step S1408: Receive TLS record;
[0199] Step S1410: Determine if it is plaintext. If yes, proceed to step S1414; otherwise, proceed to step S1412.
[0200] Step S1412: Decrypt the message using the key;
[0201] Step S1414: Determine the record type. If the record type is handshake, proceed to step S1416-1. If the record type is Alert, proceed to step S1416-2. If the record type is Data, proceed to step S1416-3. If the record type is Change cipher spec, proceed to step S1416-4.
[0202] Step S1416-1: Parse the Handshake record;
[0203] Step S1416-2: Parse the Alert record;
[0204] Step S1416-3: Parse the Data record;
[0205] Step S1416-4: Parse the Change cipher spec record;
[0206] Step S1418: Return the processing result.
[0207] Optionally, the encapsulation and sending process of a record can be used as an example for further explanation. Figure 15 As shown, when sending, it first determines whether it is in the plaintext or ciphertext transmission stage. If it is plaintext, it is directly encapsulated in the record message format and sent to the TCP protocol stack. If it is ciphertext, it needs to be encrypted first, then encapsulated, and then sent to the TCP protocol stack. The specific steps are as follows:
[0208] Step S1502, KTLS sends the record;
[0209] Step S1504: Is encryption required? If yes, proceed to step S1506; otherwise, proceed to step S1508.
[0210] Step S1506: Invoke the aead algorithm of the crypto module for encryption;
[0211] Step S1508: Encapsulate according to record format;
[0212] Step S1510: Call the TCP protocol layer packet sending function.
[0213] Optionally, in this embodiment, Handshake message parsing and encapsulation is responsible for encapsulating and parsing according to the TLS handshake message format specified in RFC8446, including client_hello, server_hello, new_session_ticket, end_of_early_data, encrypted_extensions, certificate, certificate_request, certificate_verify, finished, etc.
[0214] To further illustrate, we can optionally use the parsing process of a handshake message as an example, such as... Figure 16 As shown, when a record of type "handshake" is received, the handshake message is extracted from it, the message type is extracted from the message header, and the message parsing function corresponding to that type is called. After parsing, it is checked whether there is any unparsed data in the record. If so, the handshake message is read and parsed again; otherwise, the parsing result is returned. The specific steps are as follows:
[0215] Step S1602: Parse the handshake record;
[0216] Step S1604: Remove the handshake message from the record;
[0217] Step S1606: Determine the message type;
[0218] Step S1608: Call the parsing function corresponding to the message;
[0219] In step S1610, is there any Record left? If not, proceed to step S1612; if yes, proceed to step S1604.
[0220] Step S1612: Return the parsing result.
[0221] To further illustrate, we can optionally use the encapsulation and sending process of a handshake message as an example, such as... Figure 17 As shown, the handshake message is encapsulated according to the specified format and sent to the record layer. The record layer determines whether it can be merged with other handshake messages. If it can be merged, it can continue to encapsulate other types of handshake messages; otherwise, it sends the encapsulated record. The specific steps are as follows:
[0222] Step S1702: Encapsulate the hadshake message;
[0223] Step S17604: Send to the KTLS record layer;
[0224] Step S1706: Determine if there are any other messages. If not, proceed to step S1708; if yes, proceed to step S1702.
[0225] Step S1708: Return the parsing result.
[0226] Optionally, in this embodiment, Ext parsing and encapsulation are responsible for encapsulating and parsing the ext extensions attached to the handshake message. These include server_name, supported_groups, signature_algorithms, pre_shared_key, early_data, supported_versions, cookie, key_share, etc.
[0227] To further illustrate, we can optionally use the Ext parsing process as an example, such as... Figure 18As shown, when parsing a handshake message, its extensions are also parsed. Each handshake message can carry multiple extensions, which are parsed one by one. During parsing, it is necessary to check whether the extensions and message types are compatible. Specific extensions are only allowed to appear in specific message types. The specific steps are as follows:
[0228] Step S1802: Parse the hadshake message;
[0229] Step S1804: Parse the ext file in the message;
[0230] Step S1806: Determine if ext is valid. If it is, proceed to step S1808; otherwise, proceed to step S1812.
[0231] Step S1808: Call the corresponding parsing function based on the ext type;
[0232] Step S1810: Determine if there are any other ext. If yes, proceed to step S1804; otherwise, proceed to step S1812.
[0233] Step S1812: Return the parsing result.
[0234] To further illustrate, we can optionally use the Ext wrapper process as an example, such as... Figure 19 As shown, when constructing a HandshakeMessage, the system determines which types of exts the message should contain. It then calls the corresponding wrapper function for each ext type, finally returning the wrapper result. The specific steps are as follows:
[0235] Step S1902: Construct a handshake message;
[0236] Step S1904: Set the ext type to be included in the message;
[0237] Step S1906: Encapsulate ext one by one;
[0238] Step S1908: Return the encapsulation result.
[0239] Optionally, in this embodiment, the Transcript Hash generator is as follows: Figure 20As shown, each time KTLS receives or sends a handshake message, it calls the kernel crypto's shash module to update the transcript hash value. The transcript hash is used to calculate the secret, certificate verification, etc. After the cipher suite is determined through negotiation, the data structures required for hash calculation are initialized: struct crypto_shash and struct shash_desc objects. The specific steps are as follows:
[0240] Step S2002, negotiate cipher sutie;
[0241] Step S2004: According to the hash algorithm specified by the cipher suite, the kernel's crypto module is called to allocate and initialize a struct crypto_shash object;
[0242] Step S2006: Allocate a struct shash_desc object;
[0243] Step S2008: Save the struct crypto_shash object and the struct shash_desc object into struct tls_hsk.
[0244] To further illustrate, alternatively, for example... Figure 21 As shown, after each handshake message is received or sent, the kernel's crypto_shash_update() function is called to update the current transcript hash. The specific steps are as follows:
[0245] Step S2102, when a TLS handshake message is received or sent;
[0246] Step S2104, when a TLS handshake message is received or sent;
[0247] Step S2106: Call the crypto_shash_update() function to update the transcript hash;
[0248] Step S2108: The updated result is saved to the struct shash_desc object from struct tls_hsk.
[0249] Optionally, in this embodiment, the secret and traffic key generator calculates secrets such as the early secret, handshake secret, and master secret according to the stage of the TLS handshake negotiation, and then calculates the traffic key required for encrypting and decrypting data, such as... Figure 22 The secret calculation rules specified in RFC8446 are shown below. This embodiment calculates each secret in kernel mode according to the above secret calculation rules; in addition, the hkdf drive and expand rules specified in RFC8446 are as follows: Figure 23 As shown; furthermore, in order to support the calculation of hkdf, this embodiment implements the hkdf extract and expand algorithms in the KTLS module;
[0250] To further illustrate, alternatively, for example... Figure 24 As shown, the first step is to initialize the data structures required for HKDF operations. The cipher suite, i.e., the encryption / decryption algorithm suite, is negotiated at the beginning of the TLS handshake. Based on the negotiation result, the data structures required for HKDF HMAC operations are allocated. The specific steps are as follows:
[0251] Step S2402, negotiate cipher sutie;
[0252] Step S2404: Determine the HMAC algorithm based on the hash algorithm specified by the cipher suite;
[0253] Step S2406: Allocate the struct crypto_shash object used for hmac operations;
[0254] Step S2408: Save the struct crypto_shash object into struct tls_hsk.
[0255] Optionally, in this embodiment, the Hkdf extract algorithm of RFC5869 is defined as Figure 25 The content shown uses the `crypto_shash_setkey()` function to set the salt and the `crypto_shash_tfm_digest()` function to calculate the prk. The specific steps are as follows: Figure 26 As shown:
[0256] Step S2602: Pass in the struct crypto_shash object corresponding to hmac and salt ikm;
[0257] Step S2604: Call crypto shash_setkey
[0258] The function sets the salt for hkdf operations;
[0259] Step S2606: Call the crypto shash_tfm_digest function to calculate the result;
[0260] Step S2608, return.
[0261] Optionally, in this embodiment, the Hkdf expand algorithm of RFC5869 is defined as Figure 27 The content shown in this embodiment demonstrates how the hkdf expand action is implemented in the kernel-mode KTLS module. Figure 28 As shown, the specific steps are as follows:
[0262] Step S2802: Pass in the struct crypto_shash object, prk, info and other parameters corresponding to hmac;
[0263] Step S2804: Call the crypto_shash_setkey function to set the key for the hkdf operation;
[0264] Step S2806: Call crypto_shash_digestsize to obtain the length of the result of one hash operation;
[0265] Step S2808: Initialize by calling crypto_shash_init;
[0266] Step S2810: Based on the calculation result of the previous round, prey calls crypto_shash_update to update the hash value and saves it to the crypto_shash_desc object;
[0267] Step S2812: Based on info, call crypto_shash_update to update the hash value and save it to the structshash_desc object;
[0268] Step S2814: Call crypto_shash_finup to calculate the hash result for this round;
[0269] Step S2816: Combine the results of this round with the previous results;
[0270] Step S2818: Determine whether the cumulative output length meets the requirements. If yes, proceed to step S2822; otherwise, proceed to step S2820.
[0271] Step S2820: Use the prey character array to store the calculation results of this round, and proceed to the next round of calculation;
[0272] Step S2822, return.
[0273] RFC 8446 specifies rules for calculating encryption / decryption keys and IVs based on secrets, which may include, but are not limited to, the following:
[0274] [sender]_write_key=HKDF-Expand-Label(secret,"key","",key_length)
[0275] [sender]_write_iv=HKDF-Expand-Label(secret,"iv","",iv_length)
[0276] Pass in the parameters secret, label("key", "iv"), and calculate the corresponding key value according to the expand process described above.
[0277] Through the embodiments of this application, important security-related data such as keys are stored in the Linux kernel space, which greatly improves security and enables the Linux kernel's KTLS to have the function of handshake negotiation, becoming a complete TLS protocol implementation. Key calculation during the handshake is also performed in the kernel space, which can improve the server's connection request processing capabilities and enhance the independent controllability in the field of network security.
[0278] It is understood that in the specific embodiments of this application, data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0279] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0280] According to another aspect of the embodiments of this application, a data transmission apparatus for implementing the above-described data transmission method is also provided. For example... Figure 29 As shown, the device includes:
[0281] The receiving unit 2902 is used to receive data packets sent by the operating system user mode of the first device;
[0282] The execution unit 2904 is used to perform a handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed.
[0283] The transmission unit 2906 is used to transmit data packets to the operating system kernel mode of the second device after the handshake negotiation operation has been completed, and to return the transmission result to the operating system user mode of the first device.
[0284] Optionally, in this embodiment, the aforementioned data transmission device can be applied to, but is not limited to, all application scenarios requiring network communication transmission, especially those with high network security requirements, such as financial payments, digital RMB, and metaverse. It is also applicable to other application scenarios that rely on network communication, such as network storage.
[0285] Specifically, the aforementioned data transmission device can be applied in, but is not limited to, scenarios using the Linux operating system. Specifically, it implements the TLS handshake function in the Linux kernel space and stores the TLS key and ciphertext in the Linux kernel space, thus providing higher security. Furthermore, compared to the implementation of the TLS protocol in the Linux user space, which involves multiple interactions between the Linux user space and the Linux kernel space, the implementation of the TLS protocol in this embodiment does not involve interactions between the Linux user space and the Linux kernel space, thereby reducing performance overhead and improving the efficiency of the TLS protocol implementation.
[0286] Optionally, in this embodiment, the first device and the second device can be understood as, but are not limited to, client or server or other main devices with execution functions, such as the first device being a client and the second device being a server.
[0287] Optionally, in this embodiment, the operating system user mode and operating system kernel mode can be understood as two operating states of the operating system, but are not limited to. Taking the operating system user mode as an example, the central processing unit (CPU) in the operating system user mode can only access memory in a limited way and is not allowed to access peripheral devices. The CPU in the operating system user mode is not allowed to monopolize, or it can be understood that the CPU in the operating system user mode can be acquired by other programs. Taking the operating system kernel mode as another example, the CPU in the operating system kernel mode can access any data, including peripheral devices such as network cards and hard disk lights. Taking the operating system kernel mode as another example, the CPU in the operating system kernel mode can switch from one program to another, and there will be no preemption when occupying the CPU. For example, the privilege level 0 state can be regarded as the operating system kernel mode.
[0288] It is evident that the operating environment in user mode is more permissive than that in kernel mode (e.g., the CPU in user mode can be accessed by other programs), and is more susceptible to intrusion by malicious programs (such as computer viruses). In other words, the operating environment in user mode is less secure than that in kernel mode.
[0289] For operating system user mode, related technologies typically configure the CPU in user mode to perform technical operations for product testing. For operating system kernel mode, related technologies typically configure the CPU in user mode to perform background testing operations. Therefore, for operations closer to product testing, such as handshake negotiation and data transfer, related technologies usually instruct the CPU in user mode to perform these operations. However, because the CPU in user mode needs to frequently access critical data when performing handshake negotiation and data transfer operations, the interaction between operating system user mode and operating system kernel mode becomes frequent, resulting in significant performance degradation.
[0290] Furthermore, since the handshake negotiation process involves various types of private data, such as the secret key generated during the handshake negotiation, a less secure operating environment can easily lead to the loss of this private data. Moreover, both the handshake negotiation process and the data transmission process involve the interaction between at least two devices. If any of these at least two devices is compromised by a malicious program, the other device will also be compromised by the same malicious program. Thus, improving the security of the operating environment can reduce the probability of devices being compromised by malicious programs, thereby improving the overall security of the at least two devices.
[0291] Optionally, in this embodiment, the handshake negotiation function can be flexibly enabled or disabled, such as enabling the handshake negotiation function when it is enabled, and disabling the handshake negotiation function when it is disabled, thus disabling the handshake negotiation function. Furthermore, when the handshake negotiation function is enabled, handshake negotiation operations are allowed to be performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device; conversely, when the handshake negotiation function is disabled, normal operation is restored, and handshake negotiation operations are performed on the operating system user mode of the first device and the operating system user mode of the second device, so as to meet different needs in daily use.
[0292] Optionally, in this embodiment, the handshake negotiation operation can be understood as, but is not limited to, the operation of establishing a connection protocol between at least two devices. For example, by performing a handshake negotiation operation on the client (first device) and the server (second device), the client and the server can confirm each other's identities and establish a standardized connection protocol. In addition, in order to protect the data transmitted in the record encapsulation, the handshake negotiation operation can also be, but is not limited to, assisting the client and the server in selecting the encryption algorithm, MAC algorithm, related keys, etc. used when connecting.
[0293] Optionally, in this embodiment, performing a handshake negotiation operation with the operating system kernel of the first device, and transmitting data packets to the operating system kernel of the second device can be understood, but is not limited to, performing a handshake negotiation operation and transmitting data packets in the operating system kernel of the first device.
[0294] Optionally, in this embodiment, receiving the data packet sent by the operating system user space of the first device and returning the transmission result to the operating system user space of the first device can be understood, but is not limited to, performing operations such as internal sending and internal return of the data packet in the operating system user space of the first device;
[0295] It should be noted that by leveraging the high stringency of the operating system kernel environment, the handshake negotiation operation is confined to the operating system kernel environment. This reduces the probability of potential risks such as virus implantation during the handshake negotiation phase, thereby directly improving the execution security of the handshake negotiation operation. Furthermore, the high security of the preceding steps indirectly ensures the security of data transmission in subsequent steps. In addition, confining data transmission to the operating system kernel environment further directly ensures the security of data transmission, thus improving the overall security of data transmission.
[0296] For specific embodiments, please refer to the examples shown in the above data transmission device, which will not be repeated here.
[0297] The embodiments provided in this application receive data packets sent by the user mode of the operating system of the first device. When the handshake negotiation function in the kernel mode of the operating system of the first device is enabled but the handshake negotiation operation has not yet been performed, a handshake negotiation operation is performed between the kernel mode of the operating system of the first device and the kernel mode of the operating system of the second device. Once the handshake negotiation operation is completed, data packets are transmitted to the kernel mode of the operating system of the second device, and the transmission result is returned to the user mode of the operating system of the first device. By utilizing the high stringency of the operating environment of the operating system kernel mode, the execution environment of the handshake negotiation operation is limited to the operating system kernel mode, thereby reducing the probability of potential risks such as virus implantation during the handshake negotiation phase. This directly improves the execution security of the handshake negotiation operation. Furthermore, the high security of the preceding steps indirectly ensures the security of data transmission in subsequent steps. In addition, limiting data transmission to the operating environment of the operating system kernel mode further directly ensures the security of data transmission, thus achieving the technical effect of improving the security of data transmission.
[0298] As an optional solution, execution unit 2904 includes:
[0299] The first sending module is configured to send a first negotiation message to the operating system kernel of the second device when the handshake negotiation function in the operating system kernel of the first device is enabled and the handshake negotiation operation has not yet been performed. The first negotiation message carries a first synchronization sequence number.
[0300] The first receiving module is used to receive a negotiation response message fed back by the operating system kernel mode of the second device, wherein the negotiation response message carries a second synchronization sequence number and an acknowledgment character for the first synchronization sequence number;
[0301] The second sending module is used to send a second negotiation message to the operating system kernel mode of the second device when indicated by the negotiation response message, and to determine that the handshake negotiation operation has been completed after the second negotiation message is sent. The second negotiation message carries an acknowledgment character of the second synchronization sequence number.
[0302] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0303] As an optional solution, the device also includes:
[0304] The third sending module is used to send a first negotiation message to the operating system user mode of the second device after receiving the data packet sent by the operating system user mode of the first device, when the handshake negotiation function in the operating system kernel mode of the first device is disabled and the handshake negotiation operation has not been performed.
[0305] The second receiving module is used to receive a negotiation response message from the operating system user mode of the second device after receiving a data packet sent by the operating system user mode of the first device.
[0306] The fourth sending module is used to send a second negotiation message to the operating system user space of the second device after receiving the data packet sent by the operating system user space of the first device, upon the indication of the negotiation response message, and to determine that the handshake negotiation operation has been completed after the second negotiation message is sent.
[0307] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0308] As an optional solution, the first sending module includes:
[0309] The acquisition submodule is used to acquire the negotiation information to be sent in the operating system kernel mode of the first device, and at least one extension item to be associated with the negotiation information;
[0310] A determination submodule is used to determine the first attribute type of the negotiation information and the second attribute type of each of at least one extension item;
[0311] A submodule is established to establish the association between the negotiation information and the target extension item, and to use the association to package the target extension item and the negotiation information to obtain the first negotiation message. The target extension item is at least one extension item in which the similarity between the second attribute type and the first attribute type reaches a target threshold.
[0312] The sending submodule is used to send the first negotiation message to the operating system kernel mode of the second device.
[0313] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0314] As an optional approach, before performing handshake negotiation operations between the user mode of the first device's operating system and the kernel mode of the second device's operating system, the apparatus includes:
[0315] The configuration unit is used to configure the handshake function parameters corresponding to the operating system kernel mode of the first device in response to the configuration instruction triggered by the operating system kernel mode of the first device, wherein the handshake function parameters are function parameters associated with the handshake negotiation operation.
[0316] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0317] As an optional solution, the configuration unit includes at least one of the following:
[0318] The first configuration module is used to configure handshake function parameters that indicate whether to enable the handshake negotiation function in the operating system kernel mode of the first device.
[0319] The second configuration module is used to configure handshake function parameters for indicating whether the encryption and decryption functions are enabled. The encryption and decryption functions include the encryption function used when encapsulating data packets and the decryption function used when parsing received data packets.
[0320] The third configuration module is used to configure the handshake function parameters for indicating the key exchange mode of the encryption and decryption functions. The key exchange mode is the mode in which the operating system kernel mode of the first device and the operating system kernel mode of the second device exchange keys during the execution of the handshake negotiation operation.
[0321] The fourth configuration module is used to configure handshake function parameters that indicate whether the early data function is enabled, wherein the early data function is the function that allows the transmission of data packets during the execution of the handshake negotiation operation;
[0322] The fifth configuration module is used to configure handshake function parameters for indicating the encryption suite, wherein the encryption suite is a combination of encryption algorithms indicated by the first device for implementing the encryption function;
[0323] The sixth configuration module is used to configure the handshake function parameters that indicate the algorithm used for digital signatures, wherein the digital signature is the cryptographic signature used during the execution of the handshake negotiation operation.
[0324] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0325] As an optional solution, the device includes:
[0326] The first acquisition module is used to acquire the current negotiation stage when the operating system kernel of the first device performs the handshake negotiation operation after configuring the handshake function parameters for indicating the encryption suite. The handshake negotiation operation includes multiple negotiation stages, and the multiple negotiation stages include the current negotiation stage.
[0327] The determination module is used to determine, after configuring the handshake function parameters for indicating the cipher suite, a target suite parameter that matches the current negotiation phase from the handshake function parameters for indicating the cipher suite, wherein the handshake function parameters for indicating the cipher suite include multiple cipher suite parameters, and the multiple cipher suite parameters include the target suite parameter.
[0328] An encryption module is used to implement encryption operations in the operating system kernel mode of the first device during the current negotiation phase by utilizing the target suite parameters after configuring the handshake function parameters for indicating the encryption suite.
[0329] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0330] As an optional solution, the device includes:
[0331] The first parsing unit is configured to, during the handshake negotiation operation between the operating system kernel mode of the first device and the operating system kernel mode of the second device, if the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message received by the operating system kernel mode of the first device is plaintext, call the parsing function corresponding to the type of the negotiation message to parse the negotiation message and obtain a first parsing result; or,
[0332] The second parsing unit is used to decrypt the negotiation message and obtain the type of the negotiation message when the handshake negotiation function in the operating system kernel mode of the first device and the operating system kernel mode of the second device are enabled and the negotiation message is encrypted during the handshake negotiation operation. The second parsing unit is used to call the parsing function corresponding to the type of the negotiation message to parse the negotiation message and obtain the second parsing result.
[0333] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0334] As an optional solution, the transmission unit 2906 includes:
[0335] The second acquisition module is used to acquire the target transmission parameters associated with the handshake negotiation operation when the handshake negotiation operation has been completed. The target transmission parameters are the data for data transmission determined between the operating system kernel state of the first device and the operating system kernel state of the second device through the handshake negotiation operation.
[0336] The encapsulation module is used to encapsulate data packets using the target transmission parameters to obtain the target data packet;
[0337] The transmission module is used to transmit target data packets to the operating system kernel mode of the second device.
[0338] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0339] As an optional solution, the device includes:
[0340] The third receiving module is used to receive the first data packet transmitted by the operating system kernel of the second device after performing a handshake negotiation operation with the operating system kernel of the first device and the operating system kernel of the second device. The first data packet is a data packet obtained by the operating system kernel of the second device encapsulating the second data packet with target transmission parameters.
[0341] The decompression module is used to decompress the first data packet using the target transmission parameters after performing handshake negotiation operations on the operating system kernel mode of the first device and the operating system kernel mode of the second device, in order to obtain the second data packet.
[0342] For specific implementation examples, please refer to the examples shown in the above data transmission method; these examples will not be repeated here.
[0343] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described data transmission method is also provided, such as... Figure 30 As shown, the electronic device includes a memory 3002 and a processor 3004. The memory 3002 stores a computer program, and the processor 3004 is configured to execute the steps in any of the above method embodiments via the computer program.
[0344] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0345] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0346] S1, receives data packets sent by the operating system user mode of the first device;
[0347] S2, if the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed, perform the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device.
[0348] S3, after the handshake negotiation operation has been completed, transmits data packets to the operating system kernel mode of the second device and returns the transmission result to the operating system user mode of the first device.
[0349] Alternatively, as those skilled in the art will understand, Figure 30 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 30This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 30 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 30 The different configurations shown.
[0350] The memory 3002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the data transmission method and apparatus in this embodiment. The processor 3004 executes various functional applications and data processing by running the software programs and modules stored in the memory 3002, thereby realizing the aforementioned data transmission method. The memory 3002 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 3002 may further include memory remotely located relative to the processor 3004, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 3002 may be used, but is not limited to, to store data packets and transmission results, etc. As an example, such as... Figure 30 As shown, the memory 3002 may include, but is not limited to, the receiving unit 2902, the execution unit 2904, and the transmission unit 2906 in the data transmission device. Furthermore, it may include, but is not limited to, other module units in the data transmission device, which will not be elaborated upon in this example.
[0351] Optionally, the transmission device 3006 described above is used to receive or send data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission device 3006 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 3006 is a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0352] In addition, the aforementioned electronic device also includes: a display 3008 for displaying the aforementioned data packets and transmission results, and a connection bus 3010 for connecting the various module components in the aforementioned electronic device.
[0353] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a peer-to-peer (P2P) network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this peer-to-peer network.
[0354] According to one aspect of this application, a computer program product is provided, comprising a computer program / instructions containing program code for performing the methods shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit, it performs various functions provided in embodiments of this application.
[0355] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0356] It should be noted that the computer system of the electronic device is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0357] A computer system includes a Central Processing Unit (CPU), which performs various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) or loaded from RAM. ROM also stores various programs and data required for system operation. The CPU, ROM, and RAM are interconnected via a bus. Input / output interfaces (I / O interfaces) are also connected to the bus.
[0358] The following components are connected to the input / output interface: input sections including keyboards, mice, etc.; output sections including cathode ray tubes (CRTs), liquid crystal displays (LCDs), and speakers; storage sections including hard drives; and communication sections including network interface cards such as LAN cards and modems. The communication section performs communication processing via a network such as the Internet. Drives are also connected to the input / output interface as needed. Removable media, such as disks, optical discs, magneto-optical discs, semiconductor memories, etc., are installed on the drive as needed so that computer programs read from them can be installed into the storage section as required.
[0359] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit, it performs various functions defined in the system of this application.
[0360] According to one aspect of this application, a computer-readable storage medium is provided, wherein a processor of a computer device reads computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative implementations described above.
[0361] Optionally, in this embodiment, the computer-readable storage medium described above may be configured to store a computer program for performing the following steps:
[0362] S1, receives data packets sent by the operating system user mode of the first device;
[0363] S2, if the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed, perform the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device.
[0364] S3, after the handshake negotiation operation has been completed, transmits data packets to the operating system kernel mode of the second device and returns the transmission result to the operating system user mode of the first device.
[0365] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0366] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0367] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0368] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0369] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0370] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0371] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0372] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A data transmission method, characterized in that, include: Receive data packets sent by the operating system user mode of the first device; If the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed, the handshake negotiation operation is performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device. If the handshake negotiation operation has been completed, the data packet is transmitted to the operating system kernel mode of the second device, and the transmission result is returned to the operating system user mode of the first device, including: If the handshake negotiation operation has been completed, the target transmission parameters associated with the handshake negotiation operation are obtained, wherein the target transmission parameters are the data for data transmission determined between the operating system kernel state of the first device and the operating system kernel state of the second device by performing the handshake negotiation operation; The data packet is encapsulated using the target transmission parameters to obtain the target data packet; The target data packet is transmitted to the operating system kernel mode of the second device.
2. The method according to claim 1, characterized in that, When the handshake negotiation function in the operating system kernel mode of the first device is enabled but the handshake negotiation operation has not yet been performed, performing the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device includes: When the handshake negotiation function in the operating system kernel mode of the first device is in the enabled state and the handshake negotiation operation has not yet been performed, a first negotiation message is sent to the operating system kernel mode of the second device, wherein the first negotiation message carries a first synchronization sequence number; The system receives a negotiation response message from the operating system kernel of the second device, wherein the negotiation response message carries a second synchronization sequence number and an acknowledgment character for the first synchronization sequence number; In response to the negotiation response message, a second negotiation message is sent to the operating system kernel mode of the second device, and after the second negotiation message is sent, it is determined that the handshake negotiation operation has been completed. The second negotiation message carries an acknowledgment character for the second synchronization sequence number.
3. The method according to claim 2, characterized in that, After receiving the data packet sent by the operating system user mode of the first device, the method further includes: If the handshake negotiation function in the kernel mode of the operating system of the first device is disabled and the handshake negotiation operation has not yet been performed, the first negotiation message is sent to the user mode of the operating system of the second device. Receive the negotiation response message from the user space of the operating system of the second device; Upon receiving the negotiation response message, the second negotiation message is sent to the operating system user space of the second device, and after the second negotiation message is sent, it is determined that the handshake negotiation operation has been completed.
4. The method according to claim 2, characterized in that, Sending the first negotiation message to the operating system kernel mode of the second device includes: Obtain the negotiation information to be sent in the operating system kernel mode of the first device, and at least one extension item to be associated with the negotiation information; Determine the first attribute type of the negotiation information, and the second attribute type of each of the at least one extension item; Establish the association between the negotiation information and the target extension item, and use the association to package the target extension item and the negotiation information to obtain the first negotiation message, wherein the target extension item is the extension item in the at least one extension item whose similarity between the second attribute type and the first attribute type reaches a target threshold; The first negotiation message is sent to the operating system kernel mode of the second device.
5. The method according to claim 1, characterized in that, Before performing the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device, the method includes: In response to a configuration command triggered by the operating system kernel mode of the first device, the handshake function parameters corresponding to the operating system kernel mode of the first device are configured, wherein the handshake function parameters are function parameters associated with the handshake negotiation operation.
6. The method according to claim 5, characterized in that, The configuration of the handshake function parameters corresponding to the operating system kernel mode of the first device includes at least one of the following: Configure handshake function parameters to indicate whether to enable the handshake negotiation function in the operating system kernel mode of the first device; Configure handshake function parameters to indicate whether encryption and decryption functions are enabled, wherein the encryption and decryption functions include encryption functions used when encapsulating the data packets and decryption functions used when parsing the received data packets; Configure handshake function parameters for indicating the key exchange mode of the encryption and decryption functions, wherein the key exchange mode is the mode in which the operating system kernel mode of the first device and the operating system kernel mode of the second device exchange keys during the execution of the handshake negotiation operation; Configure handshake function parameters to indicate whether the early data function is enabled, wherein the early data function is the function that allows the transmission of the data packets during the execution of the handshake negotiation operation; Configure handshake function parameters for indicating a cryptographic suite, wherein the cryptographic suite is a combination of encryption algorithms indicated by the first device for implementing the encryption function; Configure handshake function parameters to indicate the algorithm used for the digital signature, wherein the digital signature is an encrypted signature used during the execution of the handshake negotiation operation.
7. The method according to claim 6, characterized in that, After configuring the handshake function parameters for the cryptographic suite, the method includes: The current negotiation stage at which the first device's operating system kernel performs the handshake negotiation operation is obtained, wherein the handshake negotiation operation includes multiple negotiation stages, and the multiple negotiation stages include the current negotiation stage; A target suite parameter matching the current negotiation phase is determined from the handshake function parameters used to indicate the cipher suite, wherein the handshake function parameters used to indicate the cipher suite include a plurality of cipher suite parameters, and the plurality of cipher suite parameters include the target suite parameter; The target suite parameters are used to implement the encryption operation of the operating system kernel mode of the first device during the current negotiation phase.
8. The method according to any one of claims 1 to 7, characterized in that, During the handshake negotiation operation performed on the operating system kernel mode of the first device and the operating system kernel mode of the second device, the method includes: When the handshake negotiation function in the operating system kernel mode of the first device is enabled, and the negotiation message received by the operating system kernel mode of the first device is plaintext, the parsing function corresponding to the type of the negotiation message is called to parse the negotiation message and obtain a first parsing result; or, When the handshake negotiation function in the operating system kernel mode of the first device is enabled and the negotiation message is encrypted, the negotiation message is decrypted to obtain the type of the negotiation message; the parsing function corresponding to the type of the negotiation message is called to parse the negotiation message and obtain the second parsing result.
9. The method according to claim 1, characterized in that, After performing the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device, the method includes: Receive a first data packet transmitted by the operating system kernel mode of the second device, wherein the first data packet is a data packet obtained by the operating system kernel mode of the second device encapsulating the second data packet using the target transmission parameters; The first data packet is deassembled using the target transmission parameters to obtain the second data packet.
10. A data transmission device, characterized in that, include: The receiving unit is used to receive data packets sent by the operating system user mode of the first device; An execution unit is configured to perform the handshake negotiation operation on the operating system kernel mode of the first device and the operating system kernel mode of the second device when the handshake negotiation function in the operating system kernel mode of the first device is enabled and the handshake negotiation operation has not yet been performed. The transmission unit, configured to transmit the data packet to the operating system kernel mode of the second device after the handshake negotiation operation has been completed, and to return the transmission result to the operating system user mode of the first device, includes: If the handshake negotiation operation has been completed, the target transmission parameters associated with the handshake negotiation operation are obtained, wherein the target transmission parameters are the data for data transmission determined between the operating system kernel state of the first device and the operating system kernel state of the second device by performing the handshake negotiation operation; The data packet is encapsulated using the target transmission parameters to obtain the target data packet; The target data packet is transmitted to the operating system kernel mode of the second device.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program can be executed by a terminal device or computer at runtime as described in any one of claims 1 to 9.
12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in any one of claims 1 to 9.
13. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 9 through the computer program.
