A data communication method, apparatus, device, and storage medium

By using a key dynamic library to generate and manage asymmetric key pairs between the client and server, the problem of low data security during data communication is solved, achieving higher data security and flexibility.

CN119094120BActive Publication Date: 2026-01-06CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411236808.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2026-01-06
Estimated Expiration
2044-09-04

AI Technical Summary

Technical Problem

In existing technologies, data security is low during data communication between devices, and key leakage, abnormal interception, or data tampering are likely to occur.

Method used

By employing a dynamic key library generation and management mechanism, and loading asymmetric key pairs between the client and server, data encryption and decryption are performed using the first private key and the second public key, thus avoiding the key transmission and reception process and improving data security.

Benefits of technology

It reduces the possibility of key leakage, improves data security during data communication, and is highly flexible, reduces memory resource consumption, and supports updates to the key dynamic library.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094120B_ABST
    Figure CN119094120B_ABST
Patent Text Reader

Abstract

The application provides a data communication method, device and equipment and a storage medium, which can be applied to the field of data analysis and the like, and is used to solve the problem of low data security in the data communication process. The method comprises the following steps: obtaining a first private key and a second public key based on a key dynamic library loaded in a target application; encrypting a data request generated by the target application by using the second public key to obtain an encrypted data request; sending the encrypted data request to a server, so that the server decrypts the received encrypted data request by using a second private key in a second key pair, obtains a data request, and returns an encrypted data response encrypted by using a pre-stored first public key based on the data request; wherein the first public key is a public key in a first key pair; and when the encrypted data response is received, the encrypted data response is decrypted by using the first private key to obtain a data response of the target application.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data analysis, and more particularly to a data communication method, apparatus, device, and storage medium. Background Technology

[0002] With the continuous development of technology, more and more devices can communicate with each other, enabling multiple devices to collaborate on data processing. For example, a client with an application installed can send transaction data to a server running the application via a network request, allowing the server to process the transaction data.

[0003] In related technologies, to ensure data security during data communication between devices and to prevent data leakage, interception, or tampering, the data communication method typically involves the server generating a symmetric key and sending it to the client; the client storing the symmetric key and, when generating a data request, encrypting the request using the stored symmetric key to obtain an encrypted data request, which is then sent to the server; the server decrypting the received encrypted data request using the symmetric key to obtain the corresponding data request and returning a data response based on the data request.

[0004] However, since symmetric encryption uses the same key for encryption and decryption, the key can be leaked through various channels, which can easily affect data security. Furthermore, the key transmission and reception process is also completed between devices, so during the data transmission and reception process, there is a risk of abnormal interception or abnormal tampering with the data, which can also easily affect data security.

[0005] Therefore, the data security of data communication processes under related technologies is relatively low. Summary of the Invention

[0006] This application provides a data communication method, apparatus, device, and storage medium to address the problem of low data security during data communication.

[0007] Firstly, a data communication method is provided, applied to a client with the target application installed, including:

[0008] Based on the key dynamic library loaded in the target application, a first private key and a second public key are obtained; wherein, the first private key is: the private key in the first key pair generated by the key dynamic library for the target application; the second public key is: the public key in the second key pair generated by the server running the target application for the target application;

[0009] Using the second public key, the data request generated by the target application is encrypted to obtain the encrypted data request;

[0010] The encrypted data request is sent to the server, so that the server uses the second private key in the second key pair to decrypt the received encrypted data request, obtain the data request, and return an encrypted data response encrypted with a pre-stored first public key based on the data request; wherein, the first public key is: the public key in the first key pair;

[0011] Upon receiving the encrypted data response, the encrypted data response is decrypted using the first private key to obtain the data response from the target application.

[0012] Optionally, before obtaining the first private key and the second public key based on the key dynamic library loaded in the target application, the method further includes:

[0013] Based on the pre-stored dynamic library acquisition interface, the download address and reference hash value of the key dynamic library are obtained from the server.

[0014] Download the key dynamic library from the download address;

[0015] Based on the binary format, the key dynamic library is converted to obtain the binary file of the key dynamic library;

[0016] The binary file is hashed to obtain the target hash value;

[0017] When it is determined that the target hash value matches the reference hash value, the key dynamic library is loaded into the sandbox environment of the target application.

[0018] Optionally, obtaining the first private key and the second public key based on the key dynamic library loaded in the target application includes:

[0019] Using the aforementioned key dynamic library, perform the following steps:

[0020] A first key pair is generated based on a key generation strategy; wherein, the first key pair includes: a first public key and a first private key;

[0021] The first public key is encrypted using the symmetric key obtained from the server to obtain the symmetric encryption public key;

[0022] The symmetric encryption public key is sent to the server, so that the server decrypts the received symmetric encryption public key using the symmetric key pair to obtain the first public key, generates a second key pair based on the key generation strategy, encrypts the second public key in the second key pair using the first public key to obtain the second encryption public key, and returns the second encryption public key; wherein, the second key pair contains the second public key and the second private key;

[0023] The second public key is obtained by decrypting the second public key using the first private key.

[0024] Optionally, before encrypting the first public key using the symmetric key obtained from the server to obtain the symmetric encryption public key, the method further includes:

[0025] A symmetric key retrieval command is sent to the server, so that the server returns a symmetric encryption key and a reference key; wherein, the symmetric encryption key is obtained by the server encrypting the generated symmetric key using the reference key;

[0026] Using the aforementioned key dynamic library, perform the following steps:

[0027] The symmetric encryption key is segmented to obtain multiple encryption key segments;

[0028] The multiple encrypted key segments are reversed to obtain the corresponding reversed key segments;

[0029] Store the obtained reverse key segments and the reference key.

[0030] Optionally, the step of encrypting the first public key using the symmetric key obtained from the server to obtain the symmetric encryption public key includes:

[0031] Obtain the stored reverse key segments and the reference key;

[0032] Each reversed key segment is reversed to obtain the corresponding encrypted key segment;

[0033] The obtained encryption key segments are concatenated to obtain the symmetric encryption key;

[0034] The symmetric encryption key is decrypted using the reference key to obtain the symmetric key;

[0035] The first public key is encrypted using the obtained symmetric key to obtain the symmetric encryption public key.

[0036] Secondly, a data communication method is provided, applied to a server running the target application, including:

[0037] The system receives encrypted data requests sent by clients that have the target application installed; wherein the encrypted data request is obtained by the client encrypting a data request generated by the target application using a second public key; the second public key is the public key in a second key pair generated by the target application and obtained from a key dynamic library loaded in the target application.

[0038] The encrypted data request is decrypted using the second private key from the second key pair to obtain the data request;

[0039] The data response obtained based on the data request is encrypted using a pre-stored first public key to obtain an encrypted data response.

[0040] The encrypted data response is sent to the client so that the client can decrypt the received encrypted data response using a first private key to obtain the data response of the target application; wherein, the first private key is: the private key in the first key pair generated by the key dynamic library for the target application.

[0041] Optionally, before decrypting the encrypted data request using the second private key from the second key pair to obtain the data request, the method further includes:

[0042] Generate a symmetric key based on a symmetric encryption strategy;

[0043] When the key dynamic library receives the instruction to obtain the symmetric key for the symmetric key, it returns the symmetric key to the key dynamic library so that the key dynamic library uses the symmetric key to encrypt the first public key and obtain the symmetric encryption public key;

[0044] Upon receiving the symmetric encryption public key, the symmetric key is used to decrypt the symmetric encryption public key to obtain the first public key;

[0045] Based on the key generation strategy, a second key pair is generated; wherein the second key pair includes a second public key and a second private key;

[0046] The second public key is encrypted using the first public key to obtain the second encryption public key;

[0047] The second encrypted public key is returned to the key dynamic library so that the key dynamic library can decrypt the second encrypted public key using the first private key to obtain the second public key.

[0048] Optionally, before returning the symmetric key to the key dynamic library upon receiving the symmetric key retrieval instruction for the symmetric key from the key dynamic library, the method further includes:

[0049] The symmetric key is encrypted using a preset reference key to obtain a symmetric encryption key;

[0050] The symmetric encryption key is segmented to obtain multiple encryption key segments;

[0051] The multiple encrypted key segments are reversed to obtain the corresponding reversed key segments;

[0052] The obtained reverse key segments and the reference key are stored.

[0053] Optionally, when receiving the symmetric key retrieval instruction for the symmetric key from the key dynamic library loaded in the client, returning the symmetric key to the key dynamic library includes:

[0054] Based on the symmetric key acquisition instruction, multiple reverse key segments and the reference key are acquired;

[0055] The multiple reversed key segments are reversed respectively to obtain the corresponding encrypted key segments;

[0056] The obtained multiple encryption key segments are concatenated to obtain the symmetric encryption key;

[0057] The symmetric encryption key is decrypted using the reference key to obtain the symmetric key.

[0058] Return the symmetric key to the key dynamic library.

[0059] Thirdly, a data communication device is provided for use on a client with a target application installed, comprising:

[0060] Processing module: used to obtain a first private key and a second public key based on the key dynamic library loaded in the target application; wherein, the first private key is: the private key in the first key pair generated by the key dynamic library for the target application; the second public key is: the public key in the second key pair generated by the server running the target application for the target application;

[0061] The processing module is further configured to: use the second public key to encrypt the data request generated by the target application, and obtain the encrypted data request;

[0062] Transceiver module: used to send the encrypted data request to the server, so that the server uses the second private key in the second key pair to decrypt the received encrypted data request, obtain the data request, and return an encrypted data response encrypted with a pre-stored first public key based on the data request; wherein, the first public key is: the public key in the first key pair;

[0063] The transceiver module is further configured to: upon receiving the encrypted data response, decrypt the encrypted data response using the first private key to obtain the data response of the target application.

[0064] Optionally, the processing module is further configured to:

[0065] Before obtaining the first private key and the second public key based on the key dynamic library loaded in the target application, the download address and reference hash value of the key dynamic library are obtained from the server based on the pre-stored dynamic library acquisition interface;

[0066] Download the key dynamic library from the download address;

[0067] Based on the binary format, the key dynamic library is converted to obtain the binary file of the key dynamic library;

[0068] The binary file is hashed to obtain the target hash value;

[0069] When it is determined that the target hash value matches the reference hash value, the key dynamic library is loaded into the sandbox environment of the target application.

[0070] Optionally, the processing module is specifically used for:

[0071] Using the aforementioned key dynamic library, perform the following steps:

[0072] A first key pair is generated based on a key generation strategy; wherein, the first key pair includes: a first public key and a first private key;

[0073] The first public key is encrypted using the symmetric key obtained from the server to obtain the symmetric encryption public key;

[0074] The symmetric encryption public key is sent to the server, so that the server decrypts the received symmetric encryption public key using the symmetric key pair to obtain the first public key, generates a second key pair based on the key generation strategy, encrypts the second public key in the second key pair using the first public key to obtain the second encryption public key, and returns the second encryption public key; wherein, the second key pair contains the second public key and the second private key;

[0075] The second public key is obtained by decrypting the second public key using the first private key.

[0076] Optionally, the transceiver module is further configured to:

[0077] Before encrypting the first public key using the symmetric key obtained from the server to obtain the symmetric encryption public key, a symmetric key retrieval instruction is sent to the server so that the server returns the symmetric encryption key and a reference key; wherein, the symmetric encryption key is obtained by the server encrypting the generated symmetric key using the reference key;

[0078] The processing module is also used for:

[0079] Using the aforementioned key dynamic library, perform the following steps:

[0080] The symmetric encryption key is segmented to obtain multiple encryption key segments;

[0081] The multiple encrypted key segments are reversed to obtain the corresponding reversed key segments;

[0082] Store the obtained reverse key segments and the reference key.

[0083] Optionally, the processing module is specifically used for:

[0084] Obtain the stored reverse key segments and the reference key;

[0085] Each reversed key segment is reversed to obtain the corresponding encrypted key segment;

[0086] The obtained encryption key segments are concatenated to obtain the symmetric encryption key;

[0087] The symmetric encryption key is decrypted using the reference key to obtain the symmetric key;

[0088] The first public key is encrypted using the obtained symmetric key to obtain the symmetric encryption public key.

[0089] Fourthly, a data communication device is provided for use on a server running a target application, comprising:

[0090] Transceiver module: used to receive encrypted data requests sent by clients with the target application installed; wherein, the encrypted data request is obtained by the client encrypting the data request generated by the target application using a second public key; the second public key is obtained based on the key dynamic library loaded in the target application, and the server is the public key in the second key pair generated by the target application;

[0091] Processing module: used to decrypt the encrypted data request using the second private key in the second key pair to obtain the data request;

[0092] The processing module is further configured to: encrypt the data response obtained based on the data request using a pre-stored first public key to obtain an encrypted data response;

[0093] The transceiver module is further configured to: send the encrypted data response to the client, so that the client can decrypt the received encrypted data response using a first private key to obtain the data response of the target application; wherein, the first private key is: the private key in the first key pair generated by the key dynamic library for the target application.

[0094] Optionally, the processing module is further configured to:

[0095] Before decrypting the encrypted data request using the second private key from the second key pair to obtain the data request, a symmetric key is generated based on a symmetric encryption strategy.

[0096] The transceiver module is also used for:

[0097] When the key dynamic library receives the instruction to obtain the symmetric key for the symmetric key, it returns the symmetric key to the key dynamic library so that the key dynamic library uses the symmetric key to encrypt the first public key and obtain the symmetric encryption public key;

[0098] The processing module is also used for:

[0099] Upon receiving the symmetric encryption public key, the symmetric key is used to decrypt the symmetric encryption public key to obtain the first public key;

[0100] Based on the key generation strategy, a second key pair is generated; wherein the second key pair includes a second public key and a second private key;

[0101] The second public key is encrypted using the first public key to obtain the second encryption public key;

[0102] The transceiver module is also used for:

[0103] The second encrypted public key is returned to the key dynamic library so that the key dynamic library can decrypt the second encrypted public key using the first private key to obtain the second public key.

[0104] Optionally, the processing module is further configured to:

[0105] Before returning the symmetric key to the key dynamic library when the symmetric key acquisition instruction for the symmetric key is received from the key dynamic library, the symmetric key is encrypted using a preset reference key to obtain a symmetric encryption key.

[0106] The symmetric encryption key is segmented to obtain multiple encryption key segments;

[0107] The multiple encrypted key segments are reversed to obtain the corresponding reversed key segments;

[0108] The obtained reverse key segments and the reference key are stored.

[0109] Optionally, the processing module is specifically used for:

[0110] Based on the symmetric key acquisition instruction, multiple reverse key segments and the reference key are acquired;

[0111] The multiple reversed key segments are reversed respectively to obtain the corresponding encrypted key segments;

[0112] The obtained multiple encryption key segments are concatenated to obtain the symmetric encryption key;

[0113] The symmetric encryption key is decrypted using the reference key to obtain the symmetric key.

[0114] Return the symmetric key to the key dynamic library.

[0115] Fifthly, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method as described in the first or second aspect.

[0116] Sixthly, a computer device is provided, comprising:

[0117] Memory, used to store program instructions;

[0118] A processor is configured to invoke program instructions stored in the memory and execute the method described in the first or second aspect according to the obtained program instructions.

[0119] A seventh aspect provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method as described in the first or second aspect.

[0120] In this embodiment, the key is generated and managed through a key dynamic library. Key exchange is achieved by loading the key dynamic library into the application, eliminating the need for key sending and receiving processes. This reduces the possibility of key leakage and other abnormal situations, and improves data security during data communication.

[0121] Furthermore, employing asymmetric encryption methods increases the difficulty of key leakage, which can improve data security during data communication to some extent.

[0122] Furthermore, since the key dynamic library is not bound to the target application but loaded into it, it can be linked to the target application during its runtime. Each application can share the key dynamic library to generate and manage its own passwords, reducing unnecessary memory consumption. Moreover, the key dynamic library can be updated without recompiling the target program, thus improving the flexibility of data communication. Attached Figure Description

[0123] Figure 1 This is one application scenario of the data communication method provided in the embodiments of this application;

[0124] Figure 2 A flowchart illustrating a data communication method provided in an embodiment of this application. Figure 1 ;

[0125] Figure 3 A schematic diagram illustrating the principle of the data communication method provided in this application embodiment;

[0126] Figure 4 A flowchart illustrating a data communication method provided in an embodiment of this application. Figure 2 ;

[0127] Figure 5 An interactive schematic diagram of the data communication method provided in the embodiments of this application;

[0128] Figure 6 A schematic diagram of the data communication method provided in the embodiments of this application. Figure 1 ;

[0129] Figure 7 A schematic diagram of the structure of a data communication device provided in the embodiments of this application. Figure 2 ;

[0130] Figure 8 A schematic diagram of the structure of a data communication device provided in the embodiments of this application. Figure 3 . Detailed Implementation

[0131] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0132] The terms "first" and "second" in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive protection. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. The term "multiple" in this application can mean at least two, for example, two, three, or more, and the embodiments of this application do not impose limitations.

[0133] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of this application, including various details to aid understanding. These embodiments should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this application. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description. It should be noted that in the embodiments of this application, certain existing industry solutions such as software, components, and models may be mentioned. These should be considered exemplary, intended only to illustrate the feasibility of implementing the technical solutions of this application, and do not imply that the applicant has already used or necessarily used such solutions.

[0134] The acquisition, transmission, storage, and use of data in this application all comply with the requirements of relevant national laws and regulations.

[0135] The application fields of the data communication method provided in the embodiments of this application will be briefly introduced below.

[0136] With the continuous development of technology, more and more devices can communicate with each other, enabling multiple devices to collaborate on data processing. For example, a client with an application installed can send transaction data to a server running the application via a network request, allowing the server to process the transaction data.

[0137] In related technologies, to ensure data security during data communication between devices and to prevent data leakage, interception, or tampering, the data communication method typically involves the server generating a symmetric key and sending it to the client; the client storing the symmetric key and, when generating a data request, encrypting the request using the stored symmetric key to obtain an encrypted data request, which is then sent to the server; the server decrypting the received encrypted data request using the symmetric key to obtain the corresponding data request and returning a data response based on the data request.

[0138] For example, the server uses the Advanced Encryption Standard (AES) algorithm to generate a symmetric key AESKey_01. The server provides AESKey_01 to the client offline. The client writes AESKey_01 into its source code. After generating a data request, the client uses AESKey_01 to package the data request into an encrypted request message and generates a key update request. The client sends the encrypted request message and the key update request to the server, which receives them. Based on the key update request, the server uses the AES algorithm to generate a symmetric key AESKey_02. The server encrypts AESKey_02 using AESKey_01 to obtain the encrypted symmetric key AESKey_02. The server sends the encrypted symmetric key AESKey_02 to the client, which decrypts it using AESKey_01 to obtain the symmetric key AESKey_02. The client replaces the symmetric key AESKey_01 written in the source code with symmetric key AESKey_02, and subsequently uses symmetric key AESKey_02 for encryption and decryption. The server uses symmetric key AESKey_01 to decrypt the encrypted request message, obtain the data request, and obtain the data response based on the data request. The server uses symmetric key AESKey_02 to package the data response into an encrypted response message. The server sends the encrypted response message to the client, and the client uses symmetric key AESKey_02 to decrypt the received encrypted response message, obtaining the data response.

[0139] However, since symmetric encryption uses the same key for encryption and decryption, the key can be leaked through various channels, which can easily affect data security. Furthermore, the key transmission and reception process is also completed between devices, so during the data transmission and reception process, there is a risk of abnormal interception or abnormal tampering with the data, which can also easily affect data security.

[0140] Therefore, the data security of data communication processes under related technologies is relatively low.

[0141] To address the issue of low data security during data communication, this application proposes a data communication method. When applied to a client with a target application installed, this method obtains a first private key and a second public key based on a key dynamic library loaded in the target application. The first private key is the private key in a first key pair generated by the key dynamic library for the target application; the second public key is the public key in a second key pair generated by the server running the target application for the target application.

[0142] Using the second public key, the data request generated by the target application is encrypted to obtain the encrypted data request. The encrypted data request is then sent to the server, causing the server to decrypt the received encrypted data request using the second private key from the second key pair, thus obtaining the data request. Based on the data request, the server returns an encrypted data response encrypted using the pre-stored first public key. The first public key is the public key in the first key pair. Upon receiving the encrypted data response, the first private key is used to decrypt the encrypted data response to obtain the data response from the target application.

[0143] When this method is applied to a server running the target application, it receives encrypted data requests sent by clients that have the target application installed. The encrypted data request is obtained by the client encrypting a data request generated by the target application using a second public key. The second public key is the public key in a second key pair generated by the server for the target application, obtained from a key dynamic library loaded in the target application.

[0144] The encrypted data request is decrypted using the second private key from the second key pair to obtain the data request. The data response obtained based on the data request is encrypted using the pre-stored first public key to obtain the encrypted data response. The encrypted data response is sent to the client, enabling the client to decrypt the received encrypted data response using the first private key to obtain the target application's data response. The first private key is the private key in the first key pair generated for the target application by the key dynamic library.

[0145] In this embodiment, the key is generated and managed through a key dynamic library. Key exchange is achieved by loading the key dynamic library into the application, eliminating the need for key sending and receiving processes. This reduces the possibility of key leakage and other abnormal situations, and improves data security during data communication.

[0146] Furthermore, employing asymmetric encryption methods increases the difficulty of key leakage, which can improve data security during data communication to some extent.

[0147] Furthermore, since the key dynamic library is not bound to the target application but loaded into it, it can be linked to the target application during its runtime. Each application can share the key dynamic library to generate and manage its own passwords, reducing unnecessary memory consumption. Moreover, the key dynamic library can be updated without recompiling the target program, thus improving the flexibility of data communication.

[0148] The application scenarios of the data communication method provided in this application are described below.

[0149] Please refer to Figure 1This is a schematic diagram illustrating an application scenario of the data communication method provided in this application. The application scenario includes a client 101 and a server 102. The client 101 and the server 102 can communicate with each other. The communication method can be wired, such as through a network cable or serial cable; or wireless, such as through Bluetooth or Wi-Fi. No specific limitation is imposed.

[0150] Client 101 generally refers to a device with the target application installed, such as a terminal device, a third-party application accessible by the terminal device, or a webpage accessible by the terminal device. Terminal devices include, but are not limited to, mobile phones, computers, smart medical devices, smart home appliances, vehicle terminals, or aircraft. Server 102 generally refers to a device running the target application, such as a terminal device or a server. Servers include, but are not limited to, cloud servers, local servers, or associated third-party servers. Both client 101 and server 102 can utilize cloud computing to reduce the consumption of local computing resources; similarly, they can also utilize cloud storage to reduce the consumption of local storage resources.

[0151] As one embodiment, the client 101 and the server 102 can be the same device or different devices, and there is no specific limitation.

[0152] The following is based on Figure 1 From the perspective of a client with the target application installed, the data communication method provided in this application embodiment will be described in detail. Please refer to... Figure 2 This is a flowchart illustrating a data communication method provided in an embodiment of this application.

[0153] S201, based on the key dynamic library loaded in the target application, obtain the first private key and the second public key.

[0154] The first private key is the private key in the first key pair generated by the key dynamic library for the target application. Each application can be associated with a key dynamic library that generates key pairs for it. Before being loaded into the corresponding application, each key dynamic library is the same dynamic library and executes the same key generation strategy. After being loaded into the corresponding application, it becomes the key dynamic library corresponding to the corresponding application, generating and managing the corresponding keys for the corresponding application. In this embodiment, only the key dynamic library of the target application is described; the key dynamic libraries of other applications are similar and will not be described in detail here.

[0155] The second public key is the public key in the second key pair generated by the server running the target application for the target application. This second public key can be stored in a key dynamic library, eliminating the need for message exchanges between the client and server. This reduces the possibility of key leakage and improves data security during data communication.

[0156] As one example, before loading the key dynamic library, the client can first verify whether the key dynamic library has been tampered with, etc., to ensure data security.

[0157] The server can provide a dynamic library retrieval interface for the client. The client can use this pre-stored interface to obtain the download address and reference hash value of the key dynamic library from the server. The client downloads the key dynamic library from the download address. Based on the binary format, the key dynamic library is converted to obtain a binary file. The binary file is then hashed to obtain the target hash value. If the target hash value matches the reference hash value, the key dynamic library is loaded into the target application's sandbox environment.

[0158] By loading it into a sandbox environment within the target application, you can restrict the application's permissions to prevent other malicious or erroneous applications from accessing the target application's private data or causing damage to the target application.

[0159] As one example, when obtaining the first private key and the second public key based on the key dynamic library loaded in the target application, the key dynamic library can be used to perform the following steps:

[0160] A first key pair is generated based on a key generation strategy. The first key pair includes a first public key and a first private key. The first public key is encrypted using a symmetric key obtained from the server to obtain a symmetric encryption public key. This symmetric encryption public key is sent to the server, which decrypts it using the symmetric key pair to obtain the first public key. Based on the key generation strategy, a second key pair is generated, and the second public key in the second key pair is encrypted using the first public key to obtain a second encryption public key, which is then returned. The second key pair contains both a second public key and a second private key. The second encryption public key is decrypted using the first private key to obtain the second public key.

[0161] Key generation strategies can be, for example, the GMSM library, etc., with no specific restrictions. Symmetric keys can be generated based on symmetric key generation strategies, such as the commercial cryptography SM4 (Cryptography Algorithm SM4) strategy or the AES strategy, with no specific restrictions.

[0162] As one embodiment, before encrypting the first public key using the symmetric key obtained from the server, the symmetric key can be obtained from the server and stored. For example, the symmetric key can be obtained in advance when the client's computing resources are low; or the symmetric key can be obtained in advance when the communication resources between the client and the server are low, so as to be used directly later, thereby improving the data processing efficiency in the data communication process.

[0163] The client can send a symmetric key retrieval command to the server, which will then return a symmetric encryption key and a reference key. The symmetric encryption key is obtained by the server encrypting the generated symmetric key using the reference key.

[0164] The client can then use a key dynamic library to perform the following steps: Segment the symmetric encryption key to obtain multiple encryption key segments. Reverse the order of each encryption key segment to obtain the corresponding reversed key segments. Store each obtained reversed key segment and a reference key.

[0165] Please refer to Figure 3 The symmetric encryption key contains 01, 02, ..., and 16. It can be segmented according to a preset number of segments (e.g., 4) to obtain four encryption key segments: a first encryption key segment, a second encryption key segment, a third encryption key segment, and a fourth encryption key segment. The first encryption key segment contains 01, 02, 03, and 04; the second encryption key segment contains 05, 06, 07, and 08; the third encryption key segment contains 09, 10, 11, and 12; and the fourth encryption key segment contains 13, 14, 15, and 16.

[0166] By reversing the order of each encryption key segment, four reversed key segments are obtained: a first reversed key segment, a second reversed key segment, a third reversed key segment, and a fourth reversed key segment. The first reversed key segment contains 04, 03, 02, and 01; the second reversed key segment contains 08, 07, 06, and 05; the third reversed key segment contains 12, 11, 10, and 09; and the fourth reversed key segment contains 16, 15, 14, and 13.

[0167] As one embodiment, when a symmetric key is needed, the stored reversed key segments and reference key can be obtained from a key dynamic library. Each reversed key segment is then reversed to obtain the corresponding encryption key segment. The obtained encryption key segments are then concatenated to obtain the symmetric encryption key. The symmetric encryption key is then decrypted using the reference key to obtain the symmetric key. Therefore, the obtained symmetric key can be used to encrypt the first public key to obtain the symmetric encryption public key.

[0168] S202, using the second public key, encrypts the data request generated by the target application and obtains the encrypted data request.

[0169] Since the second public key is generated by the server, the server also stores the corresponding second private key. Therefore, after receiving an encrypted data request, the server can use the second private key to decrypt the data request and return the corresponding response data.

[0170] S203, send an encrypted data request to the server.

[0171] The client sends an encrypted data request to the server, and the server receives the encrypted data request from the client. The server can use the second private key from the second key pair to decrypt the received encrypted data request, obtain the data request, and return an encrypted data response encrypted with the pre-stored first public key. The first public key is the public key in the first key pair. The key dynamic library can upload the first public key to the server after generating the first key pair, so that the server can obtain the pre-stored first public key.

[0172] Encrypted data requests can be sent via network requests or in the form of messages; there are no specific restrictions.

[0173] S204, Upon receiving an encrypted data response, the first private key is used to decrypt the encrypted data response to obtain the data response from the target application.

[0174] After receiving the encrypted data response from the server, the client can use the first private key to decrypt the encrypted data response and obtain the data response from the target application, thereby realizing data communication between the client and the server.

[0175] The following continues based on Figure 1 From the perspective of the server running the target application, this application provides a detailed description of the data communication method provided in its embodiments. Please refer to... Figure 4 This is a flowchart illustrating a data communication method provided in an embodiment of this application.

[0176] S401 receives encrypted data requests sent by clients that have the target application installed.

[0177] The encrypted data request is obtained by the client encrypting the data request generated by the target application using the second public key. Please refer to the previous section for details, which will not be repeated here. The second public key is obtained by the client from the key dynamic library loaded in the target application, and is the public key in the second key pair generated by the server for the target application. Please refer to the previous section for details, which will not be repeated here.

[0178] After a client with the target application installed sends an encrypted data request to the server, the server receives the encrypted data request sent by the client.

[0179] S402, using the second private key from the second key pair, decrypts the encrypted data request to obtain the data request.

[0180] The server uses the second private key from the second key pair to decrypt the encrypted data request and obtain the data request. It can then retrieve the corresponding response data based on the data request.

[0181] As one example, when the server exchanges the first public key and the second public key with the client through the key dynamic library, it can perform encryption to ensure key security.

[0182] The server, based on a symmetric encryption strategy, generates a symmetric key and then waits to receive a symmetric key retrieval command from the target application's key dynamic library. The symmetric encryption strategy can be, for example, SM4 or AES, and there are no specific restrictions.

[0183] Upon receiving a symmetric key retrieval instruction from the key dynamic library, the system returns the symmetric key to the key dynamic library. The key dynamic library then uses the symmetric key to encrypt the first public key, obtaining the symmetric encryption public key. Subsequently, when the server receives the symmetric encryption public key, it uses the symmetric key to decrypt it, obtaining the first public key.

[0184] The server generates a second key pair based on a key generation strategy. This second key pair contains a second public key and a second private key. The key generation strategy can be, for example, a GMSM library, and is not specifically limited in its application.

[0185] The server encrypts the second public key using the first public key to obtain the second encrypted public key. The server then returns the second encrypted public key to the key dynamic library, which uses the first private key to decrypt the second encrypted public key to obtain the second public key.

[0186] As one example, the server can store multiple reverse key segments and reference keys for the symmetric key to reduce the storage resources occupied by the key dynamic library. For details, please refer to the previous introduction, which will not be repeated here.

[0187] The server uses a preset reference key to encrypt the symmetric key, obtaining a symmetric encryption key. The symmetric encryption key is then segmented to obtain multiple encryption key segments. These segments are then reversed to obtain corresponding reversed key segments. The obtained reversed key segments and the reference key are stored.

[0188] As one implementation, when the server receives a symmetric key retrieval command from the client, it can obtain multiple reversed key segments and a reference key based on the command. The multiple reversed key segments are then reversed to obtain corresponding encrypted key segments. These encrypted key segments are then concatenated to obtain a symmetric encryption key. The reference key is used to decrypt the symmetric encryption key to obtain the symmetric key. This allows the server to return the symmetric key to the key dynamic library.

[0189] S403, use the pre-stored first public key to encrypt the data response obtained based on the data request, and obtain the encrypted data response.

[0190] The server uses the first public key uploaded by the target application's key dynamic library to encrypt the data response obtained based on the data request, thus obtaining an encrypted data response.

[0191] S404 sends an encrypted data response to the client.

[0192] The server sends an encrypted data response to the client, enabling the client to decrypt the received encrypted data response using the first private key and obtain the data response from the target application.

[0193] The server sends an encrypted data response to the client, for example, using a network protocol or message, so that the client can decrypt the received encrypted data response using a first private key to obtain the data response from the target application. The first private key is the private key in the first key pair generated for the target application by the key dynamic library.

[0194] The following describes the data communication method provided in the embodiments of this application with examples. Please refer to them. Figure 5 .

[0195] S501, the first server to create the key dynamic library can first create an initial dynamic library.

[0196] S502, add functional code to the initial dynamic library to complete the creation of the key dynamic library.

[0197] Adding functional code includes, for example, generating an SM2 key pair based on the GMSM library, namely a first public key SM2_PublicKey_C and a first private key SM2_PrivateKey_C. Obtaining a symmetric key SM4Key from a second server running the target application. Encrypting the first public key SM2_PublicKey_C using the symmetric key SM4Key to obtain the symmetric encryption public key SM2_PublicKey_C_E. The symmetric encryption public key SM2_PublicKey_C_E is uploaded to the second server. Upon receiving SM2_PublicKey_C_E, the second server decrypts it using the symmetric key SM4Ke to obtain the first public key SM2_Public_C. The second server then generates an SM2 key pair based on the GMSM library, including a second public key SM2_PublicKey_S and a second private key SM2_PrivateKey_S. The second server then encrypts the second public key SM2_PublicKey_S using the first public key SM2_PublicKey_C to obtain the second encrypted public key SM2_PublicKey_S_E. Finally, the second encrypted public key SM2_PublicKey_S_E is returned to the key dynamic library. The key dynamic library decrypts the second encrypted public key SM2_PublicKey_S_E using the first private key SM2_PrivateKey_C to obtain the second public key SM2_PublicKey_S. Therefore, a client with the target application installed can obtain the first private key and the second public key based on the key dynamic library after loading the key dynamic library.

[0198] The first server will add the above functional code to the initial dynamic library, package it into a key dynamic library, and denoted as DynamicCrypto.framework.

[0199] S503, the first server calculates the hash value of the key dynamic library DynamicCrypto.framework and obtains the reference hash value.

[0200] S504, the first server sends the key dynamic library DynamicCrypto.framework and its reference hash value to the second server. The second server then records the download address of the key dynamic library DynamicCrypto.framework and its reference hash value.

[0201] S505, the client starts the target application.

[0202] S506 After the client starts the target application, it can obtain the download address of the key dynamic library DynamicCrypto.framework and the reference hash value of the key dynamic library DynamicCrypto.framework through the interface provided by the second server.

[0203] S507: After the client downloads the key dynamic library DynamicCrypto.framework from the download address, it calculates the hash value of the key dynamic library DynamicCrypto.framework to obtain the target hash value.

[0204] S508, if it is determined that the target hash value is the same as or similar to the reference hash value obtained from the second server, load the key dynamic library DynamicCrypto.framework into the sandbox environment of the target application; otherwise, re-obtain the download address of the key dynamic library DynamicCrypto.framework and the hash value of the key dynamic library DynamicCrypto.framework; or re-download the key dynamic library DynamicCrypto.framework, etc.

[0205] S509: The client obtains the first private key and the second public key based on the loaded key dynamic library DynamicCrypto.framework.

[0206] S510, when the target application generates a data request, uses the second public key to encrypt the data request and generates an encrypted data request.

[0207] The S511 client sends an encrypted data request to the second server, and the second server receives the encrypted data request sent by the client.

[0208] S512, the second server uses the second private key to decrypt the encrypted data request and obtain the data request.

[0209] S513, the second server obtains the corresponding data response based on the data request.

[0210] S514 uses the first public key to encrypt the data response, thus obtaining an encrypted data response.

[0211] S515, the second server sends an encrypted data response to the client, and the client receives the encrypted data response sent by the second server.

[0212] S516, the client uses the first private key to decrypt the encrypted data response, obtain the data response, and thus complete the data communication between the client and the second server.

[0213] In this embodiment, the key exchange logic is implemented using a dynamic library, ensuring the logical security of the key exchange. The key used for encrypting the public key is not hard-coded directly into the application source code; it cannot be obtained through unpacking, decompilation, or other means, thus avoiding logical security vulnerabilities. The SM4Key used for encrypting the public key is encrypted and stored in segments in the dynamic library. This segment is dynamically loaded at runtime and is not directly packaged into the application, thereby protecting the SM4Key.

[0214] Based on the same inventive concept, embodiments of this application provide a data communication device capable of realizing the functions corresponding to the aforementioned data communication method applied to a client. Please refer to... Figure 6 The device includes a processing module 601 and a transceiver module 602, wherein:

[0215] Processing module 601: used to obtain a first private key and a second public key based on the key dynamic library loaded in the target application; wherein, the first private key is: the private key in the first key pair generated by the key dynamic library for the target application; the second public key is: the public key in the second key pair generated by the server running the target application for the target application;

[0216] The processing module 601 is also used to: encrypt the data request generated by the target application using the second public key, and obtain the encrypted data request;

[0217] Transceiver module 602: Used to send an encrypted data request to the server, so that the server uses the second private key in the second key pair to decrypt the received encrypted data request, obtain the data request, and return an encrypted data response encrypted with the pre-stored first public key based on the data request; wherein, the first public key is: the public key in the first key pair;

[0218] The transceiver module 602 is also used to: upon receiving an encrypted data response, decrypt the encrypted data response using the first private key to obtain the data response from the target application.

[0219] Optionally, the processing module 601 is also used for:

[0220] Before obtaining the first private key and the second public key based on the key dynamic library loaded in the target application, the download address and reference hash value of the key dynamic library are obtained from the server based on the pre-stored dynamic library acquisition interface.

[0221] Download the key dynamic library from the download address;

[0222] Based on the binary format, the key dynamic library is converted to obtain the binary file of the key dynamic library;

[0223] Perform hash processing on the binary file to obtain the target hash value;

[0224] When it is determined that the target hash value matches the reference hash value, the key dynamic library is loaded into the sandbox environment of the target application.

[0225] Optionally, the processing module 601 is specifically used for:

[0226] Using a key dynamic library, perform the following steps:

[0227] A first key pair is generated based on a key generation strategy; wherein the first key pair includes a first public key and a first private key;

[0228] The first public key is encrypted using the symmetric key obtained from the server to obtain the symmetric encryption public key;

[0229] The symmetric encryption public key is sent to the server, so that the server can decrypt the received symmetric encryption public key using a symmetric key pair to obtain the first public key. Based on the key generation strategy, the server generates a second key pair and encrypts the second public key in the second key pair using the first public key to obtain the second encryption public key, and returns the second encryption public key. The second key pair contains the second public key and the second private key.

[0230] The second public key is obtained by decrypting the second encryption public key using the first private key.

[0231] Optionally, the transceiver module 602 is also used for:

[0232] Before encrypting the first public key using the symmetric key obtained from the server and obtaining the symmetric encryption public key, a symmetric key retrieval instruction is sent to the server so that the server returns the symmetric encryption key and a reference key; wherein, the symmetric encryption key is obtained by the server encrypting the generated symmetric key using the reference key;

[0233] Processing module 601 is also used for:

[0234] Using a key dynamic library, perform the following steps:

[0235] The symmetric encryption key is segmented to obtain multiple encryption key segments;

[0236] Multiple encrypted key segments are reversed to obtain the corresponding reversed key segments;

[0237] Store the obtained reverse key segments and reference key.

[0238] Optionally, the processing module 601 is specifically used for:

[0239] Retrieve the stored reverse key segments and reference key;

[0240] Each reversed key segment is reversed to obtain the corresponding encrypted key segment;

[0241] The obtained encryption key segments are concatenated to obtain a symmetric encryption key.

[0242] The symmetric key is obtained by decrypting the symmetric encryption key using the reference key.

[0243] The obtained symmetric key is used to encrypt the first public key to obtain the symmetric encryption public key.

[0244] Based on the same inventive concept, embodiments of this application provide a data communication device capable of realizing the functions corresponding to the aforementioned data communication method applied to the server. Please refer to... Figure 7 The device includes a transceiver module 701 and a processing module 702, wherein:

[0245] Transceiver module 701: Used to receive encrypted data requests sent by clients with the target application installed; wherein, the encrypted data request is obtained by the client encrypting the data request generated by the target application using a second public key; the second public key is the public key in the second key pair generated by the server for the target application based on the key dynamic library loaded in the target application;

[0246] Processing module 702: Used to decrypt the encrypted data request using the second private key in the second key pair to obtain the data request;

[0247] The processing module 702 is also used to: encrypt the data response obtained based on the data request using a pre-stored first public key to obtain an encrypted data response;

[0248] The transceiver module 701 is also used to: send an encrypted data response to the client so that the client can use the first private key to decrypt the received encrypted data response and obtain the data response of the target application; wherein, the first private key is: the private key in the first key pair generated by the key dynamic library for the target application.

[0249] Optionally, the processing module 702 is also used for:

[0250] Before decrypting the encrypted data request using the second private key in the second key pair and obtaining the data request, a symmetric key is generated based on a symmetric encryption strategy.

[0251] The transceiver module 701 is also used for:

[0252] When a symmetric key retrieval instruction is received from the key dynamic library for a symmetric key, the symmetric key is returned to the key dynamic library so that the key dynamic library can use the symmetric key to encrypt the first public key and obtain the symmetric encryption public key.

[0253] Processing module 702 is also used for:

[0254] Upon receiving the symmetric encryption public key, the symmetric key is used to decrypt the symmetric encryption public key to obtain the first public key;

[0255] Based on the key generation strategy, a second key pair is generated; wherein the second key pair contains a second public key and a second private key;

[0256] The second public key is encrypted using the first public key to obtain the second encryption public key;

[0257] The transceiver module 701 is also used for:

[0258] Return the second public key to the key dynamic library so that the key dynamic library can decrypt the second public key using the first private key to obtain the second public key.

[0259] Optionally, the processing module 702 is also used for:

[0260] Upon receiving a symmetric key retrieval instruction from the key dynamic library for a symmetric key, before returning the symmetric key to the key dynamic library, the symmetric key is encrypted using a preset reference key to obtain the symmetric encryption key.

[0261] The symmetric encryption key is segmented to obtain multiple encryption key segments;

[0262] Reverse the order of multiple encrypted key segments to obtain the corresponding reversed key segments;

[0263] Store the obtained reverse key segments and reference key.

[0264] Optionally, the processing module 702 is specifically used for:

[0265] Based on the symmetric key acquisition command, multiple reverse key segments and a reference key are obtained;

[0266] Multiple reversed key segments are reversed to obtain the corresponding encrypted key segments;

[0267] The obtained multiple encryption key segments are concatenated to obtain a symmetric encryption key;

[0268] The symmetric key is obtained by decrypting the symmetric encryption key using the reference key.

[0269] Returns the symmetric key to the key dynamic library.

[0270] Please refer to Figure 8 This is a computer device 800 provided in the embodiments of this application. The computer device 800 can, for example, be... Figure 1The client 101 or server 102 in the system. The current and historical versions of the data storage program and the corresponding application software can be installed on a computer device 800, which includes a processor 880 and a memory 820. In some embodiments, the computer device 800 may include a display unit 840, which includes a display panel 841 for displaying a user-interactive interface, etc.

[0271] In one possible embodiment, the display panel 841 may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED).

[0272] The processor 880 is used to read a computer program and then execute the methods defined by the computer program. For example, the processor 880 reads a data storage program or file, thereby running the data storage program on the computer device 800 and displaying the corresponding interface on the display unit 840. The processor 880 may include one or more general-purpose processors, and may also include one or more DSPs (Digital Signal Processors) for performing related operations to implement the technical solutions provided in the embodiments of this application.

[0273] The memory 820 generally includes main memory and secondary storage. Main memory can be random access memory (RAM), read-only memory (ROM), and cache, etc. Secondary storage can be a hard disk, optical disk, USB flash drive, floppy disk, or tape drive, etc. The memory 820 is used to store computer programs and other data. The computer programs include applications corresponding to each client, and other data may include data generated after the operating system or applications are run, including system data (e.g., operating system configuration parameters) and user data. In this embodiment, the computer program is stored in the memory 820, and the processor 880 executes the computer program in the memory 820 to implement any of the methods described in the preceding figures.

[0274] The aforementioned display unit 840 is used to receive input digital information, character information, or contact touch operations / non-contact gestures, and to generate signal inputs related to user settings and function control of the computer device 800. Specifically, in this embodiment, the display unit 840 may include a display panel 841. The display panel 841, for example, is a touch screen, which can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or on the display panel 841), and drive corresponding connection devices according to a pre-set program.

[0275] In one possible embodiment, the display panel 841 may include two parts: a touch detection device and a touch controller. The touch detection device detects the player's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 880. It can also receive and execute commands from the processor 880.

[0276] The display panel 841 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the display unit 840, in some embodiments, the computer device 800 may also include an input unit 830. The input unit 830 may include an image input device 831 and other input devices 832, wherein the other input devices may include, but are not limited to, one or more of the following: a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, and a joystick.

[0277] In addition to the above, the computer device 800 may also include a power supply 890 for powering other modules, an audio circuit 860, a near-field communication module 870, and an RF circuit 810. The computer device 800 may also include one or more sensors 850, such as an accelerometer, a light sensor, and a pressure sensor. The audio circuit 860 specifically includes a speaker 861 and a microphone 862, for example, the computer device 800 can use the microphone 862 to collect the user's voice and perform corresponding operations.

[0278] As one embodiment, the number of processors 880 can be one or more, and the processors 880 and the memory 820 can be coupled together or relatively independent.

[0279] As one example, Figure 8 The processor 880 in the middle can be used to implement, for example Figure 6 The functions of the processing module 601 and the transceiver module 602 are also included; they can also be used to implement, for example... Figure 7 The functions of the transceiver module 701 and the processing module 702 in the middle.

[0280] As one example, Figure 8 The processor 880 in the document can be used to implement the functions of the server or terminal devices discussed above.

[0281] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by a computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the computer program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0282] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of software products, for example, through computer program products. These computer program products are stored in a storage medium and include computer programs used to cause a computer device to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.

[0283] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method of data communication, characterized by, Applied to a client installed with a target application, comprising: Based on the key dynamic library loaded in the target application, a first private key and a second public key are obtained; wherein the first private key is a private key in a first key pair generated by the key dynamic library for the target application; the second public key is a public key in a second key pair generated by a server running the target application for the target application; Using the second public key, the data request generated by the target application is encrypted to obtain an encrypted data request; Send the encrypted data request to the server to make the server use the second private key in the second key pair to decrypt the received encrypted data request, obtain the data request, and return an encrypted data response encrypted by a pre-stored first public key based on the data request; wherein the first public key is a public key in the first key pair; When the encrypted data response is received, the first private key is used to decrypt the encrypted data response to obtain the data response of the target application.

2. The method of claim 1, wherein, Before the first private key and the second public key are obtained based on the key dynamic library loaded in the target application, further comprising: Based on the pre-stored dynamic library acquisition interface, the download address and the reference hash value of the key dynamic library are obtained from the server; Download the key dynamic library from the download address; Based on the binary format, the key dynamic library is format-converted to obtain a binary file of the key dynamic library; Hash processing is performed on the binary file to obtain a target hash value; When it is determined that the target hash value matches the reference hash value, the key dynamic library is loaded in the sandbox environment of the target application.

3. The method according to claim 1 or 2, characterized in that, The first private key and the second public key are obtained based on the key dynamic library loaded in the target application, comprising: Using the key dynamic library, the following steps are performed: Generate a first key pair based on a key generation strategy; wherein the first key pair includes a first public key and a first private key; Using the symmetric key obtained from the server, the first public key is encrypted to obtain a symmetric encryption public key; The symmetric encryption public key is sent to the server to make the server decrypt the received symmetric encryption public key using the symmetric key to obtain the first public key, generate a second key pair based on the key generation strategy, and encrypt the second public key in the second key pair using the first public key to obtain a second encryption public key, and return the second encryption public key; wherein the second key pair includes the second public key and a second private key; The second encryption public key is decrypted using the first private key to obtain the second public key.

4. The method of claim 3, wherein, Before the symmetric encryption public key is obtained by encrypting the first public key using the symmetric key obtained from the server, further comprising: Send a symmetric key acquisition instruction to the server to make the server return a symmetric encryption key and a reference key; wherein the symmetric encryption key is obtained by encrypting the generated symmetric key using the reference key by the server; Using the key dynamic library, the following steps are performed: The symmetric encryption key is segmented to obtain a plurality of encryption key segments; The plurality of encryption key segments are processed in reverse order respectively to obtain corresponding reverse key segments; The obtained reverse key segments and the reference key are stored.

5. The method of claim 4, wherein, The symmetric encryption public key is obtained by encrypting the first public key using the symmetric key obtained from the server, including: The obtained reverse key segments and the reference key are stored. The reverse key segments are processed in reverse order respectively to obtain corresponding encryption key segments; The obtained encryption key segments are spliced to obtain the symmetric encryption key; The symmetric key is obtained by decrypting the symmetric encryption key using the reference key; The symmetric encryption public key is obtained by encrypting the first public key using the obtained symmetric key.

6. A data communication method characterized by comprising: The server for running a target application, including: Receiving an encrypted data request sent by a client installing the target application; wherein the encrypted data request is obtained by encrypting a data request generated by the target application using a second public key; the second public key is a public key in a second key pair generated by the server for the target application, and is obtained based on a key dynamic library loaded in the target application; Decrypting the encrypted data request using a second private key in the second key pair to obtain a data request; Encrypting a data response obtained based on the data request using a pre-stored first public key to obtain an encrypted data response; Sending the encrypted data response to the client, so that the client decrypts the received encrypted data response using a first private key to obtain a data response of the target application; wherein the first private key is a private key in a first key pair generated by the key dynamic library for the target application.

7. The method of claim 6, wherein, Before decrypting the encrypted data request using the second private key in the second key pair to obtain a data request, further including: Generating a symmetric key based on a symmetric encryption strategy; When receiving a symmetric key acquisition instruction for the symmetric key from the key dynamic library, returning the symmetric key to the key dynamic library, so that the key dynamic library encrypts the first public key using the symmetric key to obtain a symmetric encryption public key; When receiving the symmetric encryption public key, decrypting the symmetric encryption public key using the symmetric key to obtain the first public key; Generating a second key pair based on a key generation strategy; wherein the second key pair includes a second public key and a second private key; Encrypting the second public key using the first public key to obtain a second encrypted public key; Returning the second encrypted public key to the key dynamic library, so that the key dynamic library decrypts the second encrypted public key using the first private key to obtain the second public key.

8. The method of claim 7, wherein, Before returning the symmetric key to the key dynamic library when receiving the symmetric key acquisition instruction for the symmetric key from the key dynamic library, further including: Encrypting the symmetric key using a pre-set reference key to obtain a symmetric encryption key; The symmetric encryption key is segmented to obtain a plurality of encryption key segments; The plurality of encryption key segments are processed in reverse order respectively to obtain corresponding reverse order key segments; The obtained plurality of reverse order key segments and the reference key are stored.

9. The method of claim 8, wherein, When the symmetric key acquisition instruction for the symmetric key is received by the key dynamic library loaded in the client, the symmetric key is returned to the key dynamic library, including: Based on the symmetric key acquisition instruction, a plurality of reverse order key segments and the reference key are obtained; The plurality of reverse order key segments are processed in reverse order respectively to obtain corresponding encryption key segments; The obtained plurality of encryption key segments are spliced to obtain the symmetric encryption key; The symmetric encryption key is decrypted using the reference key to obtain the symmetric key; The symmetric key is returned to the key dynamic library.

10. A data communication device, characterized by Applied to a client installed with a target application, comprising: A processing module is configured to obtain a first private key and a second public key based on a key dynamic library loaded in the target application; wherein the first private key is a private key in a first key pair generated by the key dynamic library for the target application; and the second public key is a public key in a second key pair generated by a server running the target application for the target application; The processing module is further configured to encrypt a data request generated by the target application using the second public key to obtain an encrypted data request; A transceiver module is configured to send the encrypted data request to the server, so that the server decrypts the received encrypted data request using a second private key in the second key pair to obtain the data request, and returns an encrypted data response encrypted using a pre-stored first public key based on the data request; wherein the first public key is a public key in the first key pair; The transceiver module is further configured to decrypt the encrypted data response using the first private key to obtain a data response of the target application when the encrypted data response is received.

11. A data communication device, characterized by Applied to a server running a target application, comprising: A transceiver module is configured to receive an encrypted data request sent by a client installed with the target application; wherein the encrypted data request is obtained by encrypting a data request generated by the target application using a second public key; and the second public key is a public key in a second key pair generated by the server for the target application, and is obtained based on a key dynamic library loaded in the target application; A processing module is configured to decrypt the encrypted data request using a second private key in the second key pair to obtain a data request; The processing module is further configured to encrypt a data response obtained based on the data request using a pre-stored first public key to obtain an encrypted data response; The transceiver module is further configured to send the encrypted data response to the client, so that the client decrypts the received encrypted data response using a first private key to obtain a data response of the target application; wherein the first private key is a private key in a first key pair generated by the key dynamic library for the target application.

12. A computer program product comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the method of any one of claims 1-9.

13. A computer device, comprising: comprising: a memory for storing program instructions; a processor for invoking the program instructions stored in the memory to perform the method of any one of claims 1-9 according to the obtained program instructions.

14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions for causing a computer to perform the method of any one of claims 1-9.

Citation Information

Patent Citations

  • Method and apparatus for performing encryption and decryption by using white box library file and white box key file

    CN108183796A

  • Encrypted communication method and device

    CN112968899A