Encryption method, device, equipment and storage medium

By using multiple candidate key generation algorithms and encryption algorithms between the first device and the second device for encryption and decryption processing, the risk of key brute force cracking is solved and communication security is improved.

CN115037458BActive Publication Date: 2025-01-17CHINA UNIONPAY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210524811.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-13
Publication Date
2025-01-17
Estimated Expiration
2042-05-13

AI Technical Summary

Technical Problem

As computer computing power increases, it is easy to brute force to crack the key stored by the first device or the second device, thereby affecting the security of communication between the first device and the second device.

Method used

When transmitting encryption request and response messages between the first device and the second device, a plurality of candidate key generation algorithms and encryption algorithms are selected to generate encrypted data, and decryption processing is performed using the corresponding decryption algorithm in the second device. Avoid direct transmission of encryption keys and enhance communication security.

Benefits of technology

The communication security between the first device and the second device is effectively improved, the risk of key being cracked is reduced, and the security of data transmission is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115037458B_ABST
    Figure CN115037458B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide an encryption method, apparatus, device and storage medium, which relate to the field of encryption technology. The method includes: a first device sends an encryption request to a second device, the second device generates a response message for the encryption request, and the second device sends a response message to the first device. The first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm, obtains the encrypted data, and sends the encrypted data to the second device. The second device decrypts the encrypted data based on the second key generation algorithm and the target decryption algorithm to obtain the data to be processed. Since the second device does not directly send the encryption key to the first device, but sends the first key generation algorithm and the target encryption algorithm, the communication security between the first device and the second device is effectively guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of encryption technology, and in particular to an encryption method, device, equipment and storage medium. Background Art

[0002] With the development of the Internet and communication technology, more and more people transmit information through the network, and the types of information transmitted are becoming more and more diverse and more and more important, and the requirements for information security are also becoming higher and higher.

[0003] During the communication between the first device and the second device, in order to protect the security of the communication content, the first device uses a key to encrypt the communication content and sends the encrypted communication content to the second device. The second device uses the corresponding key to decrypt the encrypted communication content to obtain the communication content.

[0004] However, with the growth of computer computing power, it is easy to brute force the key stored in the first device or the second device, thereby affecting the security of communication between the first device and the second device. Summary of the invention

[0005] Embodiments of the present application provide an encryption method, apparatus, device, and storage medium for improving the security of communication between a first device and a second device.

[0006] On the one hand, an embodiment of the present application provides an encryption method, applied to a first device, the method comprising:

[0007] receiving a response message sent by a second device to an encryption request, wherein the encryption request is sent by the first device to the second device; the response message includes a first key generation algorithm selected from N candidate key generation algorithms and a target encryption algorithm selected from M candidate encryption algorithms; wherein N>1, M>1;

[0008] Encrypt the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data;

[0009] The encrypted data is sent to the second device so that the second device decrypts the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed; the second key generation algorithm corresponds to the first key generation algorithm, and the target decryption algorithm corresponds to the target encryption algorithm.

[0010] Optionally, after receiving a response message to the encryption request sent by the second device, the method further includes:

[0011] The response message is loaded into a memory, and the response message is parsed in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes the first key generation algorithm and the target encryption algorithm.

[0012] Optionally, the target encryption dynamic link library also includes an encryption key acquisition interface and a data encryption interface;

[0013] The encrypting the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data includes:

[0014] Obtaining the first key generation algorithm by calling the encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key;

[0015] The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data.

[0016] Optionally, the response message further includes second device information of the second device;

[0017] The obtaining the first key generation algorithm by calling the encryption key acquisition interface includes:

[0018] Using the first device information and the second device information of the first device as input parameters of the encryption key acquisition interface, calling the encryption key acquisition interface, and obtaining the first key generation algorithm;

[0019] The step of obtaining the target encryption algorithm by calling the data encryption interface includes:

[0020] The encryption key is used as an input parameter of the data encryption interface, and the data encryption interface is called to obtain the target encryption algorithm.

[0021] On the one hand, an embodiment of the present application provides an encryption method, which is applied to a second device, and the method includes:

[0022] Receiving an encryption request sent by a first device, and generating a response message for the encryption request, the response message including a first key generation algorithm selected from N candidate key generation algorithms and a target encryption algorithm selected from M candidate encryption algorithms, where N>1 and M>1;

[0023] Sending the response message to the first device, so that the first device performs encryption processing on the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data;

[0024] Receive the encrypted data sent by the first device, and decrypt the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed; the second key generation algorithm corresponds to the first key generation algorithm, and the target decryption algorithm corresponds to the target encryption algorithm.

[0025] Optionally, the generating a response message for the encryption request includes:

[0026] Encapsulating the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, wherein the target encryption dynamic link library includes an encryption key acquisition interface and a data encryption interface;

[0027] The response message is generated based on the target encryption dynamic link library and the second device information of the second device.

[0028] Optionally, the encryption request includes first device information of the first device;

[0029] The step of encapsulating the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library comprises:

[0030] The first device information and the second device information are used as keys, and the encryption key acquisition interface and the data encryption interface are used as values, and the first key generation algorithm and the target encryption algorithm are encapsulated to obtain the target encryption dynamic link library.

[0031] Optionally, the receiving the encrypted data sent by the first device, and decrypting the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed includes:

[0032] receiving the encrypted data sent by the first device and the third device information of the first device;

[0033] If the first device information and the third device information meet a preset condition, generating a decryption key based on the second key generation algorithm;

[0034] Based on the decryption key and the target decryption algorithm, the encrypted data is decrypted to obtain the data to be processed.

[0035] On the one hand, an embodiment of the present application provides an encryption device, the device comprising:

[0036] A first receiving module receives a response message sent by a second device to an encryption request, wherein the encryption request is sent by the first device to the second device; the response message includes a first key generation algorithm selected from N candidate key generation algorithms and a target encryption algorithm selected from M candidate encryption algorithms; wherein N>1, M>1;

[0037] An encryption module, used for encrypting the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data;

[0038] The first sending module is used to send the encrypted data to the second device, so that the second device decrypts the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed; the second key generation algorithm corresponds to the first key generation algorithm, and the target decryption algorithm corresponds to the target encryption algorithm.

[0039] Optionally, a parsing module is further included, wherein the parsing module is specifically used for:

[0040] After receiving the response message to the encryption request sent by the second device, the response message is loaded into the memory, and the response message is parsed in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes the first key generation algorithm and the target encryption algorithm.

[0041] Optionally, the target encryption dynamic link library also includes an encryption key acquisition interface and a data encryption interface;

[0042] The encryption module is specifically used for:

[0043] Obtaining the first key generation algorithm by calling the encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key;

[0044] The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data.

[0045] Optionally, the response message further includes second device information of the second device;

[0046] The encryption module is specifically used for:

[0047] Using the first device information and the second device information of the first device as input parameters of the encryption key acquisition interface, calling the encryption key acquisition interface, and obtaining the first key generation algorithm;

[0048] The communication encryption module is specifically used for:

[0049] The encryption key is used as an input parameter of the data encryption interface, and the data encryption interface is called to obtain the target encryption algorithm.

[0050] On the one hand, an embodiment of the present application provides an encryption device, the device comprising:

[0051] A second receiving module, configured to receive an encryption request sent by the first device, and generate a response message for the encryption request, wherein the response message includes a first key generation algorithm selected from N candidate key generation algorithms and a target encryption algorithm selected from M candidate encryption algorithms, where N>1 and M>1;

[0052] A second sending module is used to send the response message to the first device, so that the first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data;

[0053] A decryption module is used to receive the encrypted data sent by the first device, and decrypt the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed; the second key generation algorithm corresponds to the first key generation algorithm, and the target decryption algorithm corresponds to the target encryption algorithm.

[0054] Optionally, the second receiving module is specifically configured to:

[0055] Encapsulating the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, wherein the target encryption dynamic link library includes an encryption key acquisition interface and a data encryption interface;

[0056] The response message is generated based on the target encryption dynamic link library and the second device information of the second device.

[0057] Optionally, the encryption request includes first device information of the first device;

[0058] The second receiving module is specifically used for:

[0059] The first device information and the second device information are used as keys, and the encryption key acquisition interface and the data encryption interface are used as values, and the first key generation algorithm and the target encryption algorithm are encapsulated to obtain the target encryption dynamic link library.

[0060] Optionally, the decryption module is specifically used for:

[0061] receiving the encrypted data sent by the first device and the third device information of the first device;

[0062] If the first device information and the third device information meet a preset condition, generating a decryption key based on the second key generation algorithm;

[0063] Based on the decryption key and the target decryption algorithm, the encrypted data is decrypted to obtain the data to be processed.

[0064] On the one hand, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned encryption method when executing the program.

[0065] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program that can be executed by a computer device. When the program is run on the computer device, the computer device executes the steps of the above-mentioned encryption method.

[0066] In an embodiment of the present application, the first device sends an encryption request to the second device, the second device generates a response message for the encryption request, and the second device sends a response message to the first device. The first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm, obtains the encrypted data, and sends the encrypted data to the second device. The second device decrypts the encrypted data based on the second key generation algorithm and the target decryption algorithm to obtain the data to be processed. Since the second device does not directly send the encryption key to the first device, but sends the first key generation algorithm and the target encryption algorithm, the communication security between the first device and the second device is effectively guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0068] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present application;

[0069] Figure 2 A schematic diagram of a flow chart of an encryption method provided in an embodiment of the present application;

[0070] Figure 3 A flowchart of a method for loading a target encrypted dynamic link library provided in an embodiment of the present application;

[0071] Figure 4A flowchart of a method for a first device to obtain encrypted data provided in an embodiment of the present application;

[0072] Figure 5 A flowchart of a method for a second device to obtain data to be processed provided in an embodiment of the present application;

[0073] Figure 6 A schematic diagram of a flow chart of an encryption method provided in an embodiment of the present application;

[0074] Figure 7 A schematic diagram of the structure of an encryption device provided in an embodiment of the present application;

[0075] Figure 8 A schematic diagram of the structure of an encryption device provided in an embodiment of the present application;

[0076] Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical solution and beneficial effects of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0078] refer to Figure 1 , which is an encryption system architecture diagram applicable to an embodiment of the present application, and the encryption system architecture diagram at least includes a first device 101 and a second device 102.

[0079] The first device 101 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.

[0080] The first device 101 is installed with a target application for encryption, which may be a pre-installed client, a web application, or a small program embedded in other applications, etc. The first device 101 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited thereto.

[0081] The second device 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0082] The first device 101 and the second device 102 may be connected directly or indirectly via wired or wireless communication, which is not limited in the present application.

[0083] based on Figure 1 The system architecture diagram, the embodiment of the present application provides a process of an encryption method, such as Figure 2 As shown, the process of this method is Figure 1 The first device 101 and the second device 102 shown interact with each other and perform the following steps:

[0084] Step S201: The first device sends an encryption request to the second device.

[0085] Specifically, the first device may be a terminal device or a server, and the second device may be a terminal device or a server, which is not limited here.

[0086] The encryption request includes first device information of the first device. The first device information includes at least one of the following: MAC address, IP address, port number, CPU model, device model, device serial number, system version number, timestamp, and random number.

[0087] Step S202: The second device generates a response message for the encryption request.

[0088] Specifically, the second device obtains the first device information in the encryption request, and generates a unique identifier corresponding to the first device based on the first device information, which is used to manage the session connection between the first device and the second device.

[0089] The second device selects a first key generation algorithm from N candidate key generation algorithms, and selects a target encryption algorithm from M candidate encryption algorithms, and generates a response message based on the first key generation algorithm, the target encryption algorithm, and the second device information of the second device, where N>1 and M>1. The second device information includes at least one of the following: MAC address, IP address, port number, CPU model, device model, device serial number, system version number, timestamp, and random number.

[0090] The second device determines a corresponding second key generation algorithm based on the first key generation algorithm, and determines a corresponding target decryption algorithm based on the target encryption algorithm.

[0091] Finally, the second device establishes an encryption and decryption algorithm correspondence relationship between the unique identifier corresponding to the first device, the first key generation algorithm, the target encryption algorithm, the second key generation algorithm and the target decryption algorithm, and stores it in the second device.

[0092] Step S203: The second device sends a response message to the first device.

[0093] Step S204: The first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data.

[0094] Specifically, the first device generates an encryption key based on a first key generation algorithm, and then encrypts the data to be processed based on the encryption key and a target encryption algorithm to obtain encrypted data.

[0095] Step S205: the first device sends the encrypted data to the second device.

[0096] Specifically, the first device sends the encrypted data and the third device information of the first device to the second device.

[0097] Step S206: The second device decrypts the encrypted data based on the second key generation algorithm and the target decryption algorithm to obtain data to be processed.

[0098] Specifically, if the first device information and the third device information meet the preset conditions, a decryption key is generated based on the second key generation algorithm, and then the encrypted data is decrypted based on the decryption key and the target decryption algorithm to obtain the data to be processed. The second device determines the second key generation algorithm corresponding to the first key generation algorithm and the target decryption algorithm corresponding to the target encryption algorithm according to the stored encryption and decryption algorithm correspondence relationship.

[0099] If the first device information and the third device information do not meet the preset conditions, it means that the encrypted data sent by the first device is incorrect, or the session connection between the first device and the second device has timed out, and the second device directly discards the obtained encrypted data.

[0100] The preset conditions satisfied by the first device information and the third device information include the following two:

[0101] If the first device information and the third device information are any one of a MAC address, an IP address, a port number, a CPU model, a device model, a device serial number, a system version number, and a random number, then the preset condition satisfied by the first device information and the third device information is that the first device information and the third device information are the same.

[0102] If the first device information and the third device information are timestamps, the preset condition satisfied by the first device information and the third device information is that the difference between the timestamp in the first device information and the timestamp in the third device information is less than a preset value.

[0103] In an embodiment of the present application, the first device sends an encryption request to the second device, the second device generates a response message for the encryption request, and the second device sends a response message to the first device. The first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm, obtains the encrypted data, and sends the encrypted data to the second device. The second device decrypts the encrypted data based on the second key generation algorithm and the target decryption algorithm to obtain the data to be processed. Since the second device does not directly send the encryption key to the first device, but sends the first key generation algorithm and the target encryption algorithm, the communication security between the first device and the second device is effectively guaranteed.

[0104] Optionally, in the above step S202, the candidate key generation algorithm may be a message digest algorithm selected according to requirements, such as MD5 algorithm, SHA algorithm, etc. The length of the encryption key generated by the candidate key generation algorithm may be dynamically adjusted, such as 128 bits, 256 bits, etc.

[0105] The encryption key generated by the candidate key generation algorithm can be a symmetric key or an asymmetric key. The candidate encryption algorithm can be a symmetric encryption algorithm, such as the AES algorithm (Advanced Encryption Standard) and the TEA algorithm (Tiny Encryption Algorithm); it can also be an asymmetric encryption algorithm, such as the RSA algorithm and the ECC algorithm (Ellipse Curve Ctyptography).

[0106] When the encryption key generated by the first key generation algorithm is a symmetric key, the target encryption algorithm is a symmetric encryption algorithm. The decryption key generated by the second key generation algorithm is the same as the encryption key. The target decryption algorithm is a symmetric decryption algorithm corresponding to the target encryption algorithm.

[0107] When the encryption key generated by the first key generation algorithm is an asymmetric key, the target encryption algorithm is an asymmetric encryption algorithm. The decryption key generated by the second key generation algorithm is an asymmetric key. The target decryption algorithm is an asymmetric decryption algorithm corresponding to the target encryption algorithm. Among them, the encryption key is used as the public key in the asymmetric key, and the decryption key is used as the private key in the asymmetric key.

[0108] Optionally, in the above step S202, the second device generates a response message for the encryption request, including the following two possible implementations:

[0109] In implementation mode 1, the second device encapsulates the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, wherein the target encryption dynamic link library includes an encryption key acquisition interface and a data encryption interface, and then generates a response message based on the target encryption dynamic link library and the second device device information of the second device.

[0110] Specifically, the second device uses the first device information and the second device information as keys, and the encryption key acquisition interface and the data encryption interface as values, encapsulates the first key generation algorithm and the target encryption algorithm, and obtains the target encryption dynamic link library.

[0111] The second device encapsulates the second key generation algorithm and the target decryption algorithm into a target decryption dynamic link library, and stores the target decryption dynamic link library in the second device, wherein the target decryption dynamic link library includes a decryption key acquisition interface and a data decryption interface.

[0112] In the embodiment of the present application, the second device encapsulates the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, and the target encryption dynamic link library only provides external interfaces, namely, an encryption key acquisition interface and a data encryption interface, which can effectively hide the first key generation algorithm and the target encryption algorithm. At the same time, since the first key generation algorithm and the target encryption algorithm are encapsulated into a dynamic link library, the efficiency of subsequent loading of the dynamic link library by the first device can be effectively improved.

[0113] In implementation mode 2, the second device encapsulates the first key generation algorithm into a first dynamic link library and encapsulates the target encryption algorithm into a second dynamic link library, wherein the first dynamic link library includes an encryption key acquisition interface and the second dynamic link library includes a data encryption interface. Then, based on the first dynamic link library, the second dynamic link library and the second device information of the second device, a response message is generated.

[0114] Specifically, the first device information and the second device information are used as keys, the encryption key acquisition interface is used as a value, the first key generation algorithm is encapsulated, and the first dynamic link library is obtained. The first device information and the second device information are used as keys, the data encryption interface is used as a value, the target encryption algorithm is encapsulated, and the second dynamic link library is obtained.

[0115] The second device encapsulates the second key generation algorithm into a third dynamic link library, and encapsulates the target decryption algorithm into a fourth dynamic link library, wherein the third dynamic link library includes a decryption key acquisition interface, and the fourth dynamic link library includes a data decryption interface.

[0116] In the embodiment of the present application, the first key generation algorithm is encapsulated as a first dynamic link library, and the target encryption algorithm is encapsulated as a second dynamic link library. The first dynamic link library only provides an encryption key acquisition interface to the outside, and the second dynamic link library only provides a data encryption interface to the outside, which can effectively hide the first key generation algorithm and the target encryption algorithm. At the same time, since the first key generation algorithm and the target encryption algorithm are respectively encapsulated as different dynamic link libraries, the possibility of simultaneously cracking and obtaining the first key generation algorithm and the target encryption algorithm is reduced, and the communication security between the first device and the second device is enhanced.

[0117] Optionally, in the above step S203, the second device sends a response message to the first device. After the first device receives the response message, two possible implementation methods are provided for parsing the response message:

[0118] In a first possible implementation, the first device saves the response message in a local disk, parses the response message in the local disk, obtains the target encryption dynamic link library and the second device information of the second device, and then loads the target encryption dynamic link library into the memory. The target encryption dynamic link library includes a first key generation algorithm and a target encryption algorithm.

[0119] In an embodiment of the present application, the target encryption dynamic link library in the response message only includes the first key generation algorithm and the target encryption algorithm, and does not include the encryption key. Even if the first device encounters a network attack, the encryption key will not be leaked, thereby effectively ensuring the communication security between the first device and the second device.

[0120] In a second possible implementation, the first device loads the response message into a memory, and parses the response message in the memory to obtain a target encryption dynamic link library and second device information of the second device, wherein the target encryption dynamic link library includes a first key generation algorithm and a target encryption algorithm.

[0121] In the embodiment of the present application, the target encryption dynamic link library in the response message only includes the first key generation algorithm and the target encryption algorithm, and does not include the encryption key. Even if the first device encounters a network attack, it will not cause the leakage of the encryption key, which effectively ensures the communication security between the first device and the second device. Since the first device in the present application directly loads the response message into the memory for parsing, and does not parse it in the local disk, and no files are retained in the local disk, the communication security of the first device can be further improved.

[0122] Optionally, after receiving the response message, the first device applies for a readable, writable and executable memory, loads the target encrypted dynamic link library into the memory, and then converts the target encrypted dynamic link library from the elf format to the program format through the dynamic loading method, that is, converts the static file format to the running state format. The specific process is as follows:

[0123] Step S301, obtaining the target encrypted dynamic link library so.

[0124] Step S302, apply for a section of memory, and apply for read, write and execute permissions for the section of memory.

[0125] Step S303, load the target encrypted dynamic link library so into the memory segment.

[0126] Step S304, read the section header in the target encrypted dynamic link library so, parse the target encrypted dynamic link library so according to the offset information of the section in the section header, and obtain the section information.

[0127] Step S305, read the segment header in the target encrypted dynamic link library so, parse the target encrypted dynamic link library so according to the offset information of the segment in the segment header, and obtain the segment information.

[0128] Step S306, determine whether the target encrypted dynamic link library so is linked to other dynamic link libraries, if so, execute step S307; otherwise, end.

[0129] Step S307, load other dynamic link libraries into the memory, parse them, and end.

[0130] In an embodiment of the present application, the target encryption dynamic link library is loaded into the memory for parsing, which effectively avoids the leakage of the first key generation algorithm and the target encryption algorithm.

[0131] Optionally, in the above step S204, the first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm, and obtaining the encrypted data specifically includes the following steps:

[0132] In step S401, the first device obtains a first key generation algorithm by calling an encryption key acquisition interface, and generates an encryption key using the first key generation algorithm.

[0133] Specifically, the first device information and the second device information of the first device are used as input parameters of the encryption key acquisition interface, the encryption key acquisition interface is called, the first key generation algorithm is obtained, and the encryption key is generated by using the first key generation algorithm.

[0134] The input parameter may be any combination of the first device information and the second device information, and is not limited here. For example, the input parameter may be the MAC address and port number in the first device information, and the IP address and CPU model in the second device information.

[0135] In step S402, the first device obtains a target encryption algorithm by calling a data encryption interface, and encrypts the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data.

[0136] Specifically, the encryption key is used as an input parameter of the data encryption interface, the data encryption interface is called, a target encryption algorithm is obtained, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data.

[0137] In the embodiment of the present application, the first device obtains the first key generation algorithm by calling the encryption key acquisition interface, and uses the first key generation algorithm to generate the encryption key, instead of directly receiving the encryption key sent by the second device, which effectively improves the security of the encryption key. The first device obtains the target encryption algorithm by calling the data encryption interface, and encrypts the data to be processed based on the encryption key and the target encryption algorithm to obtain the encrypted data, instead of the first device directly storing the target encryption algorithm, which can further ensure the security of data encryption.

[0138] Optionally, in the above step S206, the second device decrypts the encrypted data based on the second key generation algorithm and the target decryption algorithm to obtain the data to be processed, which specifically includes the following steps:

[0139] Step S501: The second device obtains a second key generation algorithm by calling a decryption key acquisition interface, and uses the second key generation algorithm to generate a decryption key.

[0140] Specifically, the second device uses the first device information and the second device information of the first device as input parameters of the decryption key acquisition interface, calls the decryption key acquisition interface, obtains the second key generation algorithm, and uses the second key generation algorithm to generate a decryption key.

[0141] The input parameter may be any combination of the first device information and the second device information, and is not limited here. For example, the input parameter may be the MAC address and port number in the first device information, and the IP address and CPU model in the second device information.

[0142] In step S502, the second device obtains a target decryption algorithm by calling a data decryption interface, and decrypts the encrypted data based on a decryption key and the target decryption algorithm to obtain data to be processed.

[0143] Specifically, the second device uses the decryption key as an input parameter of the data decryption interface, calls the data decryption interface, obtains the target decryption algorithm, and decrypts the encrypted data based on the decryption key and the target decryption algorithm to obtain the data to be processed.

[0144] In the embodiment of the present application, the second device obtains the second key generation algorithm by calling the decryption key acquisition interface, and uses the second key generation algorithm to generate the decryption key, instead of directly storing the decryption key, which effectively improves the security of the decryption key. The second device obtains the target decryption algorithm by calling the data decryption interface, and decrypts the encrypted data based on the decryption key and the target decryption algorithm to obtain the data to be processed, instead of the second device directly storing the target decryption algorithm, which can further ensure the security of the encrypted data.

[0145] In order to better explain the embodiment of the present application, the following takes a specific implementation scenario as an example to introduce a process of a session encryption method provided by the embodiment of the present application. The method consists of Figure 1 The first device 101 and the second device 102 in the embodiment interact with each other, such as Figure 6 As shown, the following steps are included:

[0146] Step S601: The first device sends an encryption request to the second device, wherein the encryption request includes first device information of the first device.

[0147] Step S602: The second device selects a first key generation algorithm from N candidate key generation algorithms.

[0148] Step S603: The second device selects a target encryption algorithm from M candidate encryption algorithms.

[0149] Step S604: The second device encapsulates the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library.

[0150] Step S605: The second device generates a response message based on the target encrypted dynamic link library and the second device information of the second device.

[0151] Step S606: The second device sends a response message to the first device.

[0152] Step S607, the first device loads the response message into the memory, and parses the response message in the memory to obtain the target encryption dynamic link library and the second device information of the second device. The target encryption dynamic link library includes an encryption key acquisition interface and a data encryption interface.

[0153] Step S608, obtaining a first key generation algorithm by calling an encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key.

[0154] Step S609, obtain the target encryption algorithm by calling the data encryption interface, and encrypt the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data.

[0155] Step S610: The first device sends encrypted data and third device information of the first device to the second device.

[0156] Step S611, the second device determines whether the first device information and the third device information meet the preset conditions, if so, execute step S612; otherwise, end.

[0157] Step S612: Generate a decryption key based on a second key generation algorithm, where the second key generation algorithm corresponds to the first key generation algorithm.

[0158] Step S613, decrypting the encrypted data based on the decryption key and the target decryption algorithm to obtain data to be processed, wherein the target decryption algorithm corresponds to the target encryption algorithm.

[0159] In the embodiment of the present application, since the second device does not directly send the encryption key to the first device, but sends the first key generation algorithm and the target encryption algorithm, the communication security between the first device and the second device is effectively guaranteed.

[0160] The second device encapsulates the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, which only provides external interfaces, namely, an encryption key acquisition interface and a data encryption interface, and can effectively hide the first key generation algorithm and the target encryption algorithm. At the same time, since the first key generation algorithm and the target encryption algorithm are encapsulated into a dynamic link library, the efficiency of subsequent loading of the dynamic link library by the first device can be effectively improved.

[0161] Since the first device in the present application directly loads the response message into the memory for parsing and does not parse it in the local disk, and no files are retained in the local disk, the communication security of the first device can be further improved.

[0162] Based on the same technical concept, the embodiment of the present application provides an encryption device, such as Figure 7 As shown, the device 700 includes:

[0163] The first receiving module 701 receives a response message to an encryption request sent by a second device, wherein the encryption request is sent by the first device to the second device; the response message includes a first key generation algorithm selected from N candidate key generation algorithms and a target encryption algorithm selected from M candidate encryption algorithms; wherein N>1, M>1;

[0164] An encryption module 702 is used to encrypt the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data;

[0165] The first sending module 703 is used to send the encrypted data to the second device so that the second device decrypts the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed; the second key generation algorithm corresponds to the first key generation algorithm, and the target decryption algorithm corresponds to the target encryption algorithm.

[0166] Optionally, a parsing module 704 is further included, and the parsing module 704 is specifically used to:

[0167] After receiving the response message to the encryption request sent by the second device, the response message is loaded into the memory, and the response message is parsed in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes the first key generation algorithm and the target encryption algorithm.

[0168] Optionally, the target encryption dynamic link library also includes an encryption key acquisition interface and a data encryption interface;

[0169] The encryption module 702 is specifically used for:

[0170] Obtaining the first key generation algorithm by calling the encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key;

[0171] The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data.

[0172] Optionally, the response message further includes second device information of the second device;

[0173] The encryption module 702 is specifically used for:

[0174] Using the first device information and the second device information of the first device as input parameters of the encryption key acquisition interface, calling the encryption key acquisition interface, and obtaining the first key generation algorithm;

[0175] The encryption module 702 is specifically used for:

[0176] The encryption key is used as an input parameter of the data encryption interface, and the data encryption interface is called to obtain the target encryption algorithm.

[0177] Based on the same technical concept, the embodiment of the present application provides an encryption device, such as Figure 8 As shown, the device 800 includes:

[0178] The second receiving module 801 is used to receive the encryption request sent by the first device, and generate a response message for the encryption request, wherein the response message includes a first key generation algorithm selected from N candidate key generation algorithms and a target encryption algorithm selected from M candidate encryption algorithms, where N>1 and M>1;

[0179] A second sending module 802 is used to send the response message to the first device, so that the first device encrypts the data to be processed based on the first key generation algorithm and the target encryption algorithm to obtain encrypted data;

[0180] The decryption module 803 is used to receive the encrypted data sent by the first device, and decrypt the encrypted data based on a second key generation algorithm and a target decryption algorithm to obtain the data to be processed; the second key generation algorithm corresponds to the first key generation algorithm, and the target decryption algorithm corresponds to the target encryption algorithm.

[0181] Optionally, the second receiving module 801 is specifically configured to:

[0182] Encapsulating the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, wherein the target encryption dynamic link library includes an encryption key acquisition interface and a data encryption interface;

[0183] The response message is generated based on the target encryption dynamic link library and the second device information of the second device.

[0184] Optionally, the encryption request includes first device information of the first device;

[0185] The second receiving module 801 is specifically used for:

[0186] The first device information and the second device information are used as keys, and the encryption key acquisition interface and the data encryption interface are used as values, and the first key generation algorithm and the target encryption algorithm are encapsulated to obtain the target encryption dynamic link library.

[0187] Optionally, the decryption module 803 is specifically used for:

[0188] receiving the encrypted data sent by the first device and the third device information of the first device;

[0189] If the first device information and the third device information meet a preset condition, generating a decryption key based on the second key generation algorithm;

[0190] Based on the decryption key and the target decryption algorithm, the encrypted data is decrypted to obtain the data to be processed.

[0191] Based on the same technical concept, the embodiment of the present application provides a computer device, which may be a terminal or a server, such as Fig. 9 As shown, it includes at least one processor 901 and a memory 902 connected to the at least one processor. The specific connection medium between the processor 901 and the memory 902 is not limited in the embodiment of the present application. Fig. 9 For example, the processor 901 and the memory 902 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.

[0192] In the embodiment of the present application, the memory 902 stores instructions that can be executed by at least one processor 901, and the at least one processor 901 can execute the steps included in the above encryption method by executing the instructions stored in the memory 902.

[0193] Among them, the processor 901 is the control center of the computer device, which can use various interfaces and lines to connect various parts of the computer device, and encrypt by running or executing instructions stored in the memory 902 and calling data stored in the memory 902. Optionally, the processor 901 may include one or more processing units, and the processor 901 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 901. In some embodiments, the processor 901 and the memory 902 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.

[0194] Processor 901 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware processor for execution, or can be executed by a combination of hardware and software modules in the processor.

[0195] The memory 902 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 902 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 902 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 902 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.

[0196] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by a computer device. When the program runs on the computer device, the computer device executes the steps of the above encryption method.

[0197] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0198] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0199] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0200] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0201] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. An encryption method, applied to a first device, characterized in that: include: receiving a response message sent by a second device to an encryption request, where the encryption request is sent by the first device to the second device; Loading the response message into a memory, and parsing the response message in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes a first key generation algorithm, a target encryption algorithm, an encryption key acquisition interface, and a data encryption interface; Obtaining the first key generation algorithm by calling the encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key; The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data; Sending the encrypted data to the second device, so that the second device obtains a second key generation algorithm by calling a decryption key acquisition interface, and generates a decryption key using the second key generation algorithm; By calling the data decryption interface, the target decryption algorithm is obtained, and the encrypted data is decrypted based on the decryption key and the target decryption algorithm to obtain the data to be processed; wherein the second key generation algorithm and the target decryption algorithm are encapsulated as a target decryption dynamic link library, and the target decryption dynamic link library is stored in the second device, wherein the target decryption dynamic link library includes the decryption key acquisition interface and the data decryption interface.

2. The method according to claim 1, characterized in that The response message also includes second device information of the second device; The obtaining the first key generation algorithm by calling the encryption key acquisition interface includes: Using the first device information and the second device information of the first device as input parameters of the encryption key acquisition interface, calling the encryption key acquisition interface, and obtaining the first key generation algorithm; The step of obtaining the target encryption algorithm by calling the data encryption interface includes: The encryption key is used as an input parameter of the data encryption interface, and the data encryption interface is called to obtain the target encryption algorithm.

3. An encryption method, applied to a second device, characterized in that: include: Receiving an encryption request sent by the first device, and generating a response message for the encryption request; Sending the response message to the first device so that the first device loads the response message into a memory, and parses the response message in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes a first key generation algorithm, a target encryption algorithm, an encryption key acquisition interface, and a data encryption interface; Obtaining the first key generation algorithm by calling the encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key; The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data; receiving the encrypted data sent by the first device, obtaining a second key generation algorithm by calling a decryption key acquisition interface, and generating a decryption key by using the second key generation algorithm; By calling the data decryption interface, the target decryption algorithm is obtained, and the encrypted data is decrypted based on the decryption key and the target decryption algorithm to obtain the data to be processed; wherein the second key generation algorithm and the target decryption algorithm are encapsulated as a target decryption dynamic link library, and the target decryption dynamic link library is stored in the second device, wherein the target decryption dynamic link library includes the decryption key acquisition interface and the data decryption interface.

4. The method according to claim 3, characterized in that The generating a response message for the encryption request includes: Encapsulating the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library, wherein the target encryption dynamic link library includes an encryption key acquisition interface and a data encryption interface; The response message is generated based on the target encryption dynamic link library and the second device information of the second device.

5. The method according to claim 4, characterized in that The encryption request includes first device information of the first device; The step of encapsulating the first key generation algorithm and the target encryption algorithm into a target encryption dynamic link library comprises: The first device information and the second device information are used as keys, and the encryption key acquisition interface and the data encryption interface are used as values, and the first key generation algorithm and the target encryption algorithm are encapsulated to obtain the target encryption dynamic link library.

6. The method according to claim 5, characterized in that The receiving the encrypted data sent by the first device, and decrypting the encrypted data based on the second key generation algorithm and the target decryption algorithm to obtain the data to be processed includes: receiving the encrypted data sent by the first device and the third device information of the first device; If the first device information and the third device information meet a preset condition, generating a decryption key based on the second key generation algorithm; Based on the decryption key and the target decryption algorithm, the encrypted data is decrypted to obtain the data to be processed.

7. An encryption device, characterized in that: include: A first receiving module receives a response message to an encryption request sent by a second device, where the encryption request is sent by the first device to the second device; Loading the response message into a memory, and parsing the response message in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes a first key generation algorithm, a target encryption algorithm, an encryption key acquisition interface, and a data encryption interface; An encryption module, configured to obtain the first key generation algorithm by calling the encryption key acquisition interface, and generate an encryption key by using the first key generation algorithm; The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data; A first sending module, used for sending the encrypted data to the second device, so that the second device obtains a second key generation algorithm by calling a decryption key acquisition interface, and generates a decryption key by using the second key generation algorithm; By calling the data decryption interface, the target decryption algorithm is obtained, and the encrypted data is decrypted based on the decryption key and the target decryption algorithm to obtain the data to be processed; wherein the second key generation algorithm and the target decryption algorithm are encapsulated as a target decryption dynamic link library, and the target decryption dynamic link library is stored in the second device, wherein the target decryption dynamic link library includes the decryption key acquisition interface and the data decryption interface.

8. An encryption device, characterized in that: include: A second receiving module, used to receive the encryption request sent by the first device, and generate a response message for the encryption request; a second sending module, configured to send the response message to the first device, so that the first device loads the response message into a memory, and parses the response message in the memory to obtain a target encryption dynamic link library, wherein the target encryption dynamic link library includes a first key generation algorithm, a target encryption algorithm, an encryption key acquisition interface, and a data encryption interface; Obtaining the first key generation algorithm by calling the encryption key acquisition interface, and using the first key generation algorithm to generate an encryption key; The target encryption algorithm is obtained by calling the data encryption interface, and encryption processing is performed on the data to be processed based on the encryption key and the target encryption algorithm to obtain encrypted data; a decryption module, configured to receive the encrypted data sent by the first device, obtain a second key generation algorithm by calling a decryption key acquisition interface, and generate a decryption key using the second key generation algorithm; By calling the data decryption interface, the target decryption algorithm is obtained, and the encrypted data is decrypted based on the decryption key and the target decryption algorithm to obtain the data to be processed; wherein the second key generation algorithm and the target decryption algorithm are encapsulated as a target decryption dynamic link library, and the target decryption dynamic link library is stored in the second device, wherein the target decryption dynamic link library includes the decryption key acquisition interface and the data decryption interface.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of any method described in claims 1 to 6 are implemented.

10. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computer device, and when the program is run on the computer device, the computer device executes the steps of any method described in claims 1 to 6.

Citation Information

Patent Citations

  • Information processing method and device

    CN105450620A