Data encryption method and related equipment
By using Ascon encryption algorithm and CKKS homomorphic encryption algorithm on terminal devices, the complexity problem of existing encryption algorithms on terminal devices is solved, and low-latency, high throughput and secure data transmission is achieved.
Patent Information
- Application Number
- CN202411629980.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-14
AI Technical Summary
The existing encryption algorithms have complex encryption and decryption processes on terminal devices such as firewalls that handle large amounts of data traffic, making it difficult to achieve low latency, high throughput and security.
The lightweight Ascon encryption algorithm is used for symmetric encryption, and combined with the CKKS homomorphic encryption algorithm, the encryption of floating-point numbers and approximate calculations is realized to ensure safe and efficient information transmission.
The rapid encryption and decryption process on the terminal device is realized, ensuring the secure transmission of information, reducing latency and improving throughput.
Smart Images

Figure CN119544284A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a data encryption method and related equipment. Background Art
[0002] With the widespread application of IoT technology, the demand for protecting resource-constrained devices from security threats continues to grow. Therefore, secure communication must be achieved on limited hardware computing resources. For example, when a firewall based on the MQTT (Message Queuing Telemetry Transport) protocol exchanges data with a server, the device-related data involved needs to be encrypted, such as authentication passwords, firewall user information, and URLs. Even if the authentication of keys and certificates is performed, the plaintext passwords and message carriers before authentication may still be vulnerable to differential power analysis attacks.
[0003] In order to ensure the security and privacy of information, encrypting user information and message carriers can effectively prevent data from being intercepted or tampered with during transmission. The existing encryption algorithm has a complex encryption process, and a fast encryption and decryption algorithm is particularly important. In the face of terminal devices such as firewalls that handle large amounts of data traffic, the use of efficient and lightweight encryption and decryption algorithms can ensure low latency, high throughput, and security of terminal devices. Therefore, a new data encryption method is urgently needed. Summary of the invention
[0004] The present invention provides a data encryption method for a data encryption method based on a lightweight Ascon encryption algorithm and CKKS homomorphic encryption, which has the characteristics of strong data real-time performance and light weight, and ensures information security and efficient transmission when a terminal device publishes and subscribes to data. It ensures low latency, high throughput and security for terminal devices with a lot of traffic data.
[0005] In a first aspect, the present application provides a data encryption method, which is applied to a first terminal device, and the method includes:
[0006] Encrypting the login information of the first terminal device using the Ascon encryption algorithm to obtain the encrypted login information and an authentication tag corresponding to the encrypted login information, wherein the login information is related information for indicating that the user logs in to the first terminal device;
[0007] Sending the encrypted login information and the authentication tag to a server, so that the server authenticates the encrypted login information based on the encrypted login information and the authentication tag to obtain an authentication result;
[0008] receiving the authentication result sent by the server, and when it is determined that the authentication result is authentication passed, logging in to the first terminal device using the login information;
[0009] When receiving the target message sent by the user, the target message is encrypted using the CKKS encryption algorithm to obtain the encrypted target message;
[0010] The encrypted target message is sent to the server so that the server forwards the encrypted target message to the second terminal device, so that the second terminal device decrypts the encrypted target message using the CKKS decryption algorithm to obtain the target message.
[0011] In the embodiment of the present application, the lightweight Ascon encryption algorithm of symmetric encryption is used to encrypt application layer data packets quickly. In addition, the CKKS homomorphic encryption algorithm is combined to realize floating point and approximate calculations. The important part of the target message in the first terminal device is processed by CKKS homomorphic encryption to ensure the secure transmission of client message data; thus, the information security and efficient transmission when the terminal device publishes and subscribes data are guaranteed. Low latency, high throughput and security of firewall gateway devices are guaranteed.
[0012] In a possible implementation, the login information includes public data and private data;
[0013] The method of encrypting the login information of the first terminal device by using the Ascon encryption algorithm to obtain the encrypted login information and the authentication tag corresponding to the encrypted login information includes:
[0014] Using a preset key and a random number, an initial vector generation state is obtained, wherein the initial vector generation state is used to encrypt login information;
[0015] Using the public data to update the initial vector generation state to obtain an updated vector generation state;
[0016] Encrypting the private data by using the updated vector generation state to obtain the encrypted login information; and updating the updated vector generation state by using the private data to obtain a first target vector generation state;
[0017] An authentication tag corresponding to the encrypted login information is obtained according to the first target vector generation state and the key.
[0018] In a possible implementation manner, encrypting the target message using the CKKS encryption algorithm to obtain the encrypted target message includes:
[0019] Performing data cleaning on the target message to obtain a cleaned target message;
[0020] Encrypting the cleaned target message using a public key to obtain an encrypted intermediate target message;
[0021] The encrypted intermediate target message is processed using a preset data processing algorithm to obtain the encrypted target message.
[0022] In a second aspect, the present application provides a data encryption algorithm, which is applied to a server, and the method includes:
[0023] Receiving the encrypted login information and the authentication tag sent by the first terminal device, wherein the encrypted login information is obtained by the first terminal device encrypting the login information of the first terminal device using the Ascon encryption algorithm, and the login information is used to indicate the relevant information of the user logging in to the first terminal device;
[0024] Using the encrypted login information and the authentication tag to verify the authentication and obtain an authentication result;
[0025] The authentication result is sent to the first terminal device, so that if the first terminal device determines that the authentication is passed based on the authentication result, the first terminal device uses the login information to log in to the first terminal device; and when receiving the target message sent by the user, the target message is encrypted using the CKKS encryption algorithm to obtain the encrypted target message;
[0026] After receiving the encrypted target message sent by the first terminal device, the encrypted target message is forwarded to each second terminal device.
[0027] In the embodiment of the present application, the lightweight Ascon encryption algorithm of symmetric encryption is used to encrypt application layer data packets quickly. In addition, the CKKS homomorphic encryption algorithm is combined to realize floating point and approximate calculations. The important part of the target message in the first terminal device is processed by CKKS homomorphic encryption to ensure the secure transmission of client message data; thus, the information security and efficient transmission when the terminal device publishes and subscribes data are guaranteed. Low latency, high throughput and security of firewall gateway devices are guaranteed.
[0028] In a possible implementation manner, the receiving of the encrypted login information and the authentication tag sent by the first terminal device further includes:
[0029] Receiving public data, a preset key and a random number sent by the first terminal device; wherein the public data is the data in the login information;
[0030] The using the encrypted login information and the authentication tag to verify the authority and obtain the verification result includes:
[0031] Using the key and the random number, an initial vector generation state is obtained, wherein the initial vector generation state is used to encrypt login information;
[0032] Using the public data to update the initial vector generation state to obtain an updated vector generation state;
[0033] Using the encrypted target message to update the updated vector generation state to obtain a second target vector generation state;
[0034] Obtaining the tag to be authenticated by using the second target vector generation state and the key;
[0035] The authentication result is obtained according to the authentication tag and the tag to be authenticated.
[0036] In a possible implementation manner, obtaining the authentication result according to the authentication tag and the tag to be authenticated includes:
[0037] If the authentication tag and the tag to be authenticated are the same, then the authentication result is determined to be authentication passed; or,
[0038] If the authentication label and the to-be-authenticated label are not the same, the authentication result is determined to be authentication failure.
[0039] In a third aspect, the present application provides a data encryption device, the device comprising:
[0040] A first encryption module, used to encrypt the login information of the first terminal device using the Ascon encryption algorithm to obtain the encrypted login information and an authentication tag corresponding to the encrypted login information, wherein the login information is related information used to indicate that the user logs in to the first terminal device;
[0041] A first sending module, configured to send the encrypted login information and the authentication tag to a server, so that the server authenticates the encrypted login information based on the encrypted login information and the authentication tag;
[0042] An authentication module, configured to log in to the first terminal device using the login information when it is determined that the server authentication has passed;
[0043] The second encryption module is used to encrypt the target message using the CKKS encryption algorithm when receiving the target message sent by the user to obtain the encrypted target message;
[0044] The second sending module is used to send the encrypted target message to the server, so that the server forwards the encrypted target message to the second terminal device, so that the second terminal device uses the CKKS decryption algorithm to decrypt the encrypted target message to obtain the target message.
[0045] In a fourth aspect, the present application provides a data encryption device, the device comprising:
[0046] a receiving module, configured to receive the encrypted login information and the authentication tag sent by the first terminal device, wherein the encrypted login information is obtained by the first terminal device encrypting the login information of the first terminal device using the Ascon encryption algorithm, and the login information and the related information used to indicate that the user has logged in to the first terminal device;
[0047] An authentication module, used to perform authentication using the encrypted login information and the authentication tag to obtain an authentication result;
[0048] The third sending module is used to send the authentication result to the first terminal device, so that if the first terminal device determines that the authentication result is authentication passed, it uses the login information to log in to the first terminal device; and when receiving the target message sent by the user, it uses the CKKS encryption algorithm to encrypt the target message to obtain the encrypted target message;
[0049] A forwarding module is used to forward the encrypted target message to the second terminal device after receiving the encrypted target message sent by the first terminal device.
[0050] In a fifth aspect, an embodiment of the present application provides a first terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the data encryption method when executing the computer program.
[0051] In a sixth aspect, an embodiment of the present application provides a server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the data encryption method when executing the computer program.
[0052] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps in the above-mentioned data encryption method of the present application are implemented.
[0053] In an eighth aspect, an embodiment of the present application provides a computer program product, including a computer program, which is stored in a computer-readable storage medium; when the processor of a memory access device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the memory access device executes the steps in the above-mentioned data encryption method of the present application.
[0054] For each aspect from the second to the eighth aspect and the technical effects that may be achieved by each aspect, please refer to the technical effects that can be achieved by various possible solutions in the first aspect, and no further details will be given here. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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.
[0056] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;
[0057] Figure 2 One of the flow charts of a data encryption method provided in an embodiment of the present application;
[0058] Figure 3 A schematic diagram of a process for encrypting login information of a first terminal device using the Ascon encryption algorithm provided in an embodiment of the present application;
[0059] Figure 4 A schematic diagram of a flow chart for authentication provided in an embodiment of the present application;
[0060] Figure 5 A schematic diagram of a process for encrypting a target message using the CKKS encryption algorithm provided in an embodiment of the present application;
[0061] Figure 6 One of the schematic diagrams of a data encryption device provided in an embodiment of the present application;
[0062] Figure 7 A second schematic diagram of a device for determining data encryption provided in an embodiment of the present application;
[0063] Figure 8 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the present application more clear, the present application will be further described in detail below in conjunction with the accompanying drawings. The specific operation method in the method embodiment can also be applied to the device embodiment or the system embodiment.
[0065] In the description of this application, "multiple" is understood to be "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. A is connected to B, which can represent two situations: A is directly connected to B and A is connected to B through C. In addition, in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0066] The encryption process of the encryption algorithm in the existing technology is complicated, and a fast encryption and decryption algorithm is particularly important. In the face of gateway devices such as firewalls that handle a large amount of data traffic, the use of efficient and lightweight encryption and decryption algorithms can ensure low latency, high throughput and security of firewall-type gateway devices. Therefore, a new data encryption method is urgently needed.
[0067] In this regard, the embodiment of the present application provides a data encryption method, which uses the lightweight Ascon encryption algorithm of symmetric encryption to encrypt application layer data packets quickly. In addition, the CKKS homomorphic encryption algorithm is combined to realize floating point and approximate calculations. The important part of the target message in the first terminal device is processed by the CKKS homomorphic encryption method to ensure the secure transmission of client message data; thereby, the information security and efficient transmission when the terminal device publishes and subscribes to data are guaranteed. Low latency, high throughput and security of firewall-type gateway devices are guaranteed.
[0068] like Figure 1 As shown, an application scenario of a data encryption method includes a first terminal device 110, a server 120 and a second terminal device 130.
[0069] In a possible application scenario, the first terminal device 110 uses the Ascon encryption algorithm to encrypt the login information of the first terminal device to obtain the encrypted login information and the authentication tag corresponding to the encrypted login information, wherein the login information is related information used to indicate that the user has logged in to the first terminal device; then the first terminal device sends the encrypted login information and the authentication tag to the server 120, and the server 120 verifies the encrypted login information based on the encrypted login information and the authentication tag, obtains the authentication result, and sends the authentication result to the first terminal device 110; the first terminal device When the terminal device 110 determines that the authentication result sent by the server is authenticated, it uses the login information to log in to the first terminal device; and when receiving the target message sent by the user, it uses the CKKS encryption algorithm to encrypt the target message to obtain the encrypted target message; then the first terminal device 110 sends the encrypted target message to the server 120, so that the server 120 forwards the encrypted target message to the second terminal device 130, so that the second terminal device 130 uses the CKKS decryption algorithm to decrypt the encrypted target message to obtain the target message.
[0070] in, Figure 1 The first terminal device 110 and the server 120, as well as the server 120 and the second terminal device 130 can exchange information through a communication network, wherein the communication mode adopted by the communication network can be divided into a wireless communication mode or a wired communication mode.
[0071] Exemplarily, the first terminal device 110 and the second terminal device 130 can access the network through cellular mobile communication technology to communicate with the server 120, wherein the cellular mobile communication technology, for example, includes the fifth generation mobile communication (5th Generation Mobile Networks, 5G) technology.
[0072] Optionally, the first terminal device 110 and the second terminal device 130 may access the network and communicate with the server 120 via short-range wireless communication, wherein the short-range wireless communication method, for example, includes Wireless Fidelity (Wi-Fi) technology.
[0073] Among them, the description in this application only details a single first terminal device 110, a single server 120, and a single second terminal device 130, but those skilled in the art should understand that the illustrated first terminal device 110, server 120, and second terminal device 130 are intended to represent the operations of the first terminal device 110, server 120, and second terminal device 130 involved in the technical solution of this application. It does not imply a limitation on the number, type, or location of the first terminal device 110, server 120, and second terminal device 130. It should be noted that if additional modules are added to the illustrated environment or individual modules are removed therefrom, the underlying concepts of the exemplary embodiments of this application will not be changed.
[0074] It should be noted that the data encryption method proposed in this application is not only applicable to Figure 1 The application scenario shown is also applicable to any data encryption device.
[0075] The following describes the data encryption method in an exemplary implementation of the present application in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the methods and principles of the present application, and the implementation of the present application is not limited in this regard.
[0076] The present application is further described in detail below in conjunction with the accompanying drawings. Figure 1 The figure is a flow chart of a data encryption method provided in an embodiment of the present application, and the specific implementation process of the method is as follows:
[0077] Step 201: The first terminal device encrypts the login information of the first terminal device using the Ascon encryption algorithm to obtain the encrypted login information and an authentication tag corresponding to the encrypted login information, wherein the login information is related information used to indicate that the user logs in to the first terminal device;
[0078] The login information in the embodiment of the present application includes public data and private data, wherein the public data is the user name, and the private data is the user password, certificate, key path and other data.
[0079] Next, the method of encrypting the login information of the first terminal device using the Ascon encryption algorithm is introduced. Figure 3 FIG. 1 is a flow chart of encrypting the login information of the first terminal device using the Ascon encryption algorithm, which may specifically include the following steps:
[0080] Step 301: using a preset key and a random number to obtain an initial vector generation state, wherein the initial vector generation state is used to encrypt login information;
[0081] The following is a detailed description of the method for generating the initial vector generation state in step 301:
[0082] Step 1: According to Ascon-128, construct a 64-bit initial vector IV, where the initial vector IV can be obtained by formula (1):
[0083] IV=k‖r‖a‖b‖0...(1);
[0084] Among them, k is the length of the key, r is the length of the preset input data speed, a is the preset number of trust operations, b is the preset number of permutation operations, and || represents data splicing.
[0085] In the embodiment of the present application, k=128, r=60, a=12, and b=6. However, the embodiment of the present application does not limit the specific values of the length k of the key, the length r of the speed of input data, and the number of times a and b of the two permutation operations. In the embodiment of the present application, the specific values of the length k of the key, the length r of the speed of input data, and the number of times a and b of the two permutation operations can be set according to the specific actual situation.
[0086] Step 2: Concatenate the initial vector, the key and the random number to obtain an intermediate vector, where the intermediate vector S can be obtained by formula (2): ′ :
[0087] S ′ =IV‖K‖N……(2);
[0088] Wherein, K is the key and N is the random number.
[0089] Step 3: Use a preset permutation algorithm to perform a round of confidence operations on the intermediate vector to obtain a permuted intermediate vector, perform an XOR operation on the permuted intermediate vector and the key to obtain an initial vector generation state.
[0090] The length of the initial vector, intermediate vector and initial vector generation state in the embodiment of the present application is 320 bits. Therefore, when the intermediate vector and the key are XORed, 320-k zeros need to be filled in front of the key. Among them, the initial vector generation state can be obtained by formula (3):
[0091] S=p a (S ′ )⊕(0 320-k ∥K)……(3);
[0092] Among them, p a (S ′ ) represents the intermediate vector S ′ Perform a round of permutation operation, 0320-k Indicates 320-k zeros.
[0093] Step 302: using the public data to update the initial vector generation state to obtain an updated vector generation state;
[0094] Step 1: Divide the public data into blocks of a first specified length to obtain divided data blocks.
[0095] The first specified length in the embodiment of the present application is the length r of the speed of the pre-set input data as described above. As r is 64 as described above. Before dividing the public data, it is necessary to determine whether the length of the public data is less than the first specified length. If so, and it is not 0, it is necessary to fill the target number of 0s after the public data; if so, and it is 0, the public data is not divided; if not, the public data is divided using the above-mentioned method of dividing the data. Among them, the target number can be obtained by formula (4):
[0096] n=L-1-(l mod L)……(4);
[0097] Wherein, n is the target number, L is the first specified length, and l is the length of the public data.
[0098] In the embodiment of the present application, L=r, but the specific value of the first specified length is not limited in the embodiment of the present application and can be set according to specific actual conditions.
[0099] Step 2: For any data block, perform data XOR on the data block and the i-th data block in the initial vector generation state to obtain a target data block, use the target data block to replace the i-th data block in the initial vector generation state to obtain a first intermediate vector generation state, use a permutation algorithm to perform b rounds of permutation operations on the first intermediate vector generation state to obtain a second intermediate vector generation state.
[0100] In the embodiment of the present application, the number of bits and the length of the data block in the initial vector generation state are the same as the number of bits and the length of the data block in the public data. For example, the first data block in the public data is XORed with the first data block in the initial vector generation state, where the first data block in the initial vector generation state is the data block composed of the data corresponding to the first first specified length.
[0101] For example, the initial vector generation state is xaxbxnxxmxxtxxrxxvxu. Taking the first specified length as 4 as an example, the first data block in the initial vector generation state is xaxb, the second data block is xnxx, the third data block is mxxt, the fourth data block is xxrx, and the fifth data block is xvxu.
[0102] The second intermediate vector generation state can be obtained by formula (5):
[0103]
[0104] in, is the data block corresponding to the i-th first specified length n in the initial vector generation state, S″ is the second intermediate vector generation state, AD i is the ith data block in the public data, S c The data other than the data block corresponding to the first specified length n in the initial vector generation state, p b () is the b-round permutation operation.
[0105] It should be noted that the replacement algorithm is not limited in the embodiments of the present application, and the replacement algorithm in the embodiments of the present application can be set according to specific actual conditions.
[0106] Step 3: Perform an XOR operation on the second intermediate vector generation state and the specified data to obtain the updated vector generation state.
[0107] The specified data in the embodiment of the present application is 0...01, where the number of 0s is 319. The updated vector generation state can be obtained by formula (6):
[0108]
[0109] Among them, S * Generates state for the updated vector, 0 319 Represents 319 zeros.
[0110] Step 303: encrypting the private data by using the updated vector generation state to obtain the encrypted login information; and updating the updated vector generation state by using the private data to obtain a first target vector generation state;
[0111] The following is a detailed description of the method of encrypting the private data and determining the generation state of the first target vector in step 303:
[0112] Step 1: Determine whether the length of the private data is the first specified length. If so, divide the private data into multiple private data blocks at intervals of the first specified length. If not, fill the private data to obtain private data blocks, wherein the length of the padded private data is the first specified length.
[0113] Step 2: Traverse each private data block, and for any traversed private data block, determine whether the private data block is the last private data block. If not, perform an XOR operation on the private data block and the target data block in the updated vector generation state to obtain a ciphertext corresponding to the private data block, and use the ciphertext to replace the target data block in the updated vector generation state to obtain a replaced vector generation state, and perform b rounds of permutation operation on the replaced vector generation state, and determine the vector generation state after the permutation operation as the updated vector generation state; if yes, perform an XOR operation on the private data block and the target data block in the updated vector generation state to obtain target ciphertext data, and determine the data of the first target length of the target ciphertext data as the ciphertext corresponding to the private data block; and use the target ciphertext data to replace the target data block to obtain a replaced vector generation state, and determine the replaced vector generation state as the first target vector generation state; according to the ciphertext corresponding to each private data block, obtain the encrypted login information.
[0114] The updated vector generation state is also divided according to the first specified length to obtain each data block. The number of bits of the target data block corresponding to any private data block in the updated vector generation state is the same. If the private data block is the first data block in the private data, then the corresponding target data block is also the first data block in the updated vector generation state.
[0115] The target length in the embodiment of the present application is the length of the last private data block.
[0116] Step 304: Obtain an authentication tag corresponding to the encrypted login information according to the first target vector generation state and the key.
[0117] In one embodiment, step 304 can be specifically implemented as follows: performing an XOR operation on the first target vector generation state and the key to obtain fused data, performing a round of permutation operations on the fused data using a permutation algorithm to obtain permuted fused data, and obtaining an authentication tag corresponding to the encrypted login information based on the permuted fused data and the key. The permuted fused data can be obtained by formula (7):
[0118]
[0119] Among them, S τ is the replaced fusion data, K is the key, k is the length of the key, S 1 Generate state for the first target vector, 0 r Represents r 0,0 320-r-k Represents 320-rk zeros, and ∥ represents splicing.
[0120] In one embodiment, obtaining the authentication tag corresponding to the encrypted login information according to the replaced fusion data and the key may be specifically implemented as follows:
[0121] An XOR operation is performed on the data of the second specified length after the replaced fusion data and the data of the second specified length after the key to obtain an authentication tag corresponding to the encrypted login information.
[0122] Step 202: The first terminal device sends the encrypted login information and the authentication tag to the server;
[0123] Step 203: The server verifies the encrypted login information based on the encrypted login information and the authentication tag to obtain a verification result;
[0124] In the embodiment of the present application, the first terminal device sends the encrypted login information and the authentication tag while also sending public data, a key and a random number.
[0125] Next, the steps of performing the authentication in step 203 are described. Figure 4 The figure is a schematic diagram of the verification process, which may include the following steps:
[0126] Step 401: using the key and the random number, obtaining an initial vector generation state, wherein the initial vector generation state is used to encrypt login information;
[0127] The method of determining the initial vector generation state in step 401 in the embodiment of the present application is the same as the method of determining the initial vector generation state in step 301 described above, and the embodiment of the present application will not be repeated here.
[0128] Step 402: using the public data to update the initial vector generation state to obtain an updated vector generation state;
[0129] The updated vector generation state obtained in step 402 in the embodiment of the present application is the same as that in step 302, and the embodiment of the present application will not be described in detail here.
[0130] Step 403: using the encrypted target message to update the updated vector generation state to obtain a second target vector generation state;
[0131] In the embodiment of the present application, the encrypted target message includes multiple ciphertexts.
[0132] In one embodiment, step 403 may be specifically implemented as follows:
[0133] Traversing the ciphertexts, for any traversed ciphertext, determining whether the ciphertext is the last ciphertext, and if not, performing an XOR operation on the ciphertext and the first target data block in the updated vector generation state to obtain a privacy data block corresponding to the ciphertext, wherein the position of the first target data block in the updated vector generation state is the same as the position of the ciphertext in the encrypted target message, and the length of the first target data block is the same as the length of the ciphertext; replacing the target data block in the updated vector generation state with the ciphertext, performing b rounds of permutation operations on the replaced vector generation state, and determining the vector generation state after the permutation operation as the updated vector generation state;
[0134] If so, an XOR operation is performed on the ciphertext and the data of the previous target length in the second target data block in the updated vector generation state to obtain a privacy data block corresponding to the ciphertext, wherein the second target data block is the last data block in the updated vector generation state, and the target length is the same as the length of the ciphertext; and the privacy data block is padded to a specified length to obtain a padded privacy data block, and an XOR operation is performed on the padded privacy data block and the target data block to obtain a third target data block, and the third data block is used to replace the second target data block in the updated vector generation state to obtain the second target vector generation state.
[0135] In the embodiment of the present application, the method of filling the private data block is to fill multiple zeros after the private data block so that the length of the private data block is a specified length, and the specified length is the length of other ciphertexts except the last ciphertext.
[0136] Step 404: obtaining the tag to be authenticated by generating the state and the key through the second target vector;
[0137] The method of generating the tag to be authenticated in the embodiment of the present application is the same as the method of generating the authenticated tag described above, that is, replacing the first target vector generation state with the second target vector generation state, and the other methods are the same, and the embodiment of the present application will not be repeated here.
[0138] Step 405: Obtain the authentication result according to the authentication tag and the tag to be authenticated.
[0139] In one embodiment, step 405 may be specifically implemented as follows:
[0140] If the authentication tag and the tag to be authenticated are the same, the authentication result is determined to be authentication passed; or if the authentication tag and the tag to be authenticated are different, the authentication result is determined to be authentication failed.
[0141] Step 204: The server sends the authentication result to the first terminal device;
[0142] Step 205: If the authentication result is authentication passed, the first terminal device uses the login information to log in to the first terminal device;
[0143] In the embodiment of the present application, the user name and password in the login information can be used to log in, and the specific method of the embodiment of the present application will not be repeated here.
[0144] Step 206: When the first terminal device receives the target message sent by the user, it encrypts the target message using the CKKS encryption algorithm to obtain the encrypted target message;
[0145] Next, the method of encrypting the target message using the CKKS encryption algorithm in step 206 is introduced. Figure 5 As shown, it is a schematic diagram of the process of encrypting the target message using the CKKS encryption algorithm, which may specifically include the following steps:
[0146] Step 501: performing data cleaning on the target message to obtain a cleaned target message;
[0147] Data cleaning can be performed according to a pre-set format, such as retaining a timestamp field and a device interface flow field, etc. It can be set according to specific actual needs, and the embodiment of the present application is not limited here.
[0148] Step 502: Encrypt the cleaned target message using a public key to obtain an encrypted intermediate target message;
[0149] The encryption method in step 502 is introduced below:
[0150] 1. Key Generation
[0151] Key generation is divided into the generation of private keys and public keys and the generation of CKKS keys for auxiliary calculations. The public key is used for encryption on the client side, and the private key is generated at the receiving end (i.e., the second terminal device in this application). The CKKS key generation for auxiliary calculations will be used in the subsequent calculation of average traffic, and the CKKS key should be held during data processing.
[0152] Step 1: Instantiate the private key distribution χ s , get the first intermediate value s; instantiate the plaintext space R Q , get the second intermediate value d; instantiate the error distribution χ e , obtain the third intermediate value e; obtain the private key according to the first intermediate value; obtain the public key according to the first intermediate value, the second intermediate value and the third intermediate value. Wherein, formula (8) is the instantiation of the private key distribution χ s , plaintext space R Q and the error distribution χ e The formula is:
[0153] s←χ s , d←R Q , e←χ e ……(8);
[0154] Among them, the private key sk can be obtained by formula (9):
[0155] sk←(1,s)……(9);
[0156] The public key pk can be obtained by formula (10):
[0157] b=(-d·s+e)mod Q
[0158]
[0159] Among them, b is the fourth intermediate value, and Q is the pre-set first weight value.
[0160] Step 2: Instantiate the modulus range distribution R PQ , get the fifth intermediate value, instantiate the error distribution χ e , and obtain the sixth intermediate value; and obtain the CKKS key according to the fifth intermediate value and the sixth intermediate value. The fifth intermediate value and the sixth intermediate value can be obtained by formula (11):
[0161] a ′ ←R PQ , e ′ ←χ e ………(11);
[0162] Among them, a ′ is the fifth intermediate value, e ′is the sixth intermediate value.
[0163] The CKKS key can be obtained by formula (12):
[0164] b ′ =(-a ′ ·s+e ′ +P·s 2 )mod P·Q
[0165]
[0166] Among them, b ′ is the seventh intermediate value, and P is a preset second weight value.
[0167] 2. Data encryption:
[0168] For any data in the target message, instantiate the random distribution to obtain the eighth intermediate value; instantiate the error distribution to obtain the ninth intermediate value; obtain the encrypted data according to the eighth intermediate value, the ninth intermediate value, the public key and the any data; obtain the encrypted target message according to the encrypted data. The encrypted data can be obtained by formula (13):
[0169] c=f·pk+(m+e0)mod Q……(13);
[0170] Among them, c is the encrypted data, f is the eighth intermediate value, pk is the public key, m is the target message, and e0 is the ninth intermediate value.
[0171] The encrypted target message in the embodiment of the present application includes encrypted data.
[0172] Step 503: Perform data processing on the encrypted intermediate target message using a preset data processing algorithm to obtain the encrypted target message.
[0173] The data processing algorithm in the embodiment of the present application may be addition or multiplication, that is, the encrypted data of the same field is added or multiplied. For example, the data corresponding to the device interface flow field is added to obtain the total flow. The specific data processing algorithm can be set according to the specific actual situation, and the embodiment of the present application is not limited here.
[0174] In the embodiment of the present application, the encrypted target message obtained after data processing is sent to the server.
[0175] Step 207: The first terminal device sends the encrypted target message to the server;
[0176] Step 208: The server forwards the encrypted target message to the second terminal device;
[0177] The second terminal device may be a device subscribed to the first terminal device, or may be a device where a display platform is located. All users logged in to the display platform can receive the encrypted target message.
[0178] Step 209: After receiving the encrypted target message, the second terminal device uses the CKKS decryption algorithm to decrypt the encrypted target message to obtain the target message.
[0179] In one embodiment, step 209 may be specifically implemented as follows:
[0180] For any encrypted data in the encrypted target message, the encrypted data is decrypted using a private key to obtain decrypted data; and the target message is obtained according to each encrypted data. The decrypted data can be obtained by formula (14):
[0181] m ′ =<c,sk> mod Q...(14);
[0182] Among them, m ′ is the decrypted data, c is the encrypted data, and sk is the private key.
[0183] The private key in the embodiment of the present application is generated in the second terminal device, but the generation method and the generation method of the public key are written together. For the specific method, please refer to formula (9), and the embodiment of the present application will not be repeated here. The target message in the embodiment of the present application includes the decrypted data, and the target message is obtained by obtaining the decrypted data.
[0184] In this application, a sufficiently large Q can be set to reduce the error in the encryption process. A larger Q provides more space to store and process encrypted data, thereby reducing the impact of errors on the results. Decrypting json data based on this formula can obtain the decrypted result after sending the encrypted addition and encrypted multiplication.
[0185] Based on the same inventive concept, the present application also provides a data encryption device 600, see Figure 6 , the device comprises:
[0186] The first encryption module 601 is used to encrypt the login information of the first terminal device using the Ascon encryption algorithm to obtain the encrypted login information and the authentication tag corresponding to the encrypted login information, wherein the login information is related information used to indicate that the user logs in to the first terminal device;
[0187] A first sending module 602 is used to send the encrypted login information and the authentication tag to a server, so that the server verifies the encrypted login information based on the encrypted login information and the authentication tag to obtain a verification result;
[0188] The authentication module 603 is used to receive the authentication result sent by the server, and when it is determined that the authentication result is authentication passed, log in to the first terminal device using the login information;
[0189] The second encryption module 604 is used to encrypt the target message using the CKKS encryption algorithm when receiving the target message sent by the user to obtain the encrypted target message;
[0190] The second sending module 605 is used to send the encrypted target message to the server, so that the server forwards the encrypted target message to the second terminal device, so that the second terminal device uses the CKKS decryption algorithm to decrypt the encrypted target message to obtain the target message.
[0191] In a possible implementation, the login information includes public data and private data;
[0192] The first encryption module 601 is specifically used for:
[0193] Using a preset key and a random number, an initial vector generation state is obtained, wherein the initial vector generation state is used to encrypt login information;
[0194] Using the public data to update the initial vector generation state to obtain an updated vector generation state;
[0195] Encrypting the private data by using the updated vector generation state to obtain the encrypted login information; and updating the updated vector generation state by using the private data to obtain a first target vector generation state;
[0196] An authentication tag corresponding to the encrypted login information is obtained according to the first target vector generation state and the key.
[0197] In a possible implementation manner, the second encryption module 604 is specifically configured to:
[0198] Performing data cleaning on the target message to obtain a cleaned target message;
[0199] Encrypting the cleaned target message using a public key to obtain an encrypted intermediate target message;
[0200] The encrypted intermediate target message is processed using a preset data processing algorithm to obtain the encrypted target message.
[0201] Based on the same inventive concept, the present application also provides a data encryption device 700, such as Figure 7 As shown, the device comprises:
[0202] The receiving module 701 is used to receive the encrypted login information and the authentication tag sent by the first terminal device, wherein the encrypted login information is obtained by the first terminal device encrypting the login information of the first terminal device using the Ascon encryption algorithm, and the login information is used to indicate the relevant information of the user logging in to the first terminal device;
[0203] The authentication module 702 is used to perform authentication using the encrypted login information and the authentication tag to obtain an authentication result;
[0204] The third sending module 703 is used to send the authentication result to the first terminal device, so that if the first terminal device determines that the authentication is passed based on the authentication result, the first terminal device uses the login information to log in to the first terminal device; and when receiving the target message sent by the user, the target message is encrypted using the CKKS encryption algorithm to obtain the encrypted target message;
[0205] The forwarding module 704 is used to forward the encrypted target message to the second terminal device after receiving the encrypted target message sent by the first terminal device.
[0206] In a possible implementation manner, the receiving module 701 is further configured to:
[0207] Receiving public data, a preset key and a random number sent by the first terminal device; wherein the public data is the data in the login information;
[0208] The authentication module 702 is specifically used for:
[0209] Using the key and the random number, an initial vector generation state is obtained, wherein the initial vector generation state is used to encrypt login information;
[0210] Using the public data to update the initial vector generation state to obtain an updated vector generation state;
[0211] Using the encrypted target message to update the updated vector generation state to obtain a second target vector generation state;
[0212] Obtaining the tag to be authenticated by using the second target vector generation state and the key;
[0213] The authentication result is obtained according to the authentication tag and the tag to be authenticated.
[0214] In a possible implementation manner, the authentication module 702 is specifically configured to:
[0215] If the authentication tag and the tag to be authenticated are the same, then the authentication result is determined to be authentication passed; or,
[0216] If the authentication label and the to-be-authenticated label are not the same, the authentication result is determined to be authentication failure.
[0217] Based on the same inventive concept, an electronic device is also provided in the embodiment of the present application. The electronic device can be one of the first terminal device, the server and the second terminal device. The electronic device can realize the function of the aforementioned data storage device, referring to Figure 8 , the electronic device comprises:
[0218] At least one processor 801, and a memory 802 connected to the at least one processor 801. The specific connection medium between the processor 801 and the memory 802 is not limited in the embodiment of the present application. Figure 8 In the example, the processor 801 and the memory 802 are connected via a bus 800. Figure 8 The connection between other components is shown by bold lines, and is not intended to be limiting. The bus 800 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 801 can also be called a controller, and there is no limitation on the name.
[0219] In the embodiment of the present application, the memory 802 stores instructions that can be executed by at least one processor 801. The at least one processor 801 can execute the data encryption method discussed above by executing the instructions stored in the memory 802. The processor 801 can implement Figure 6 The functions of each module in the device shown.
[0220] Among them, the processor 801 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 802 and calling the data stored in the memory 802, the various functions of the device and processing data, the device can be monitored as a whole.
[0221] In one possible design, the processor 801 may include one or more processing units, and the processor 801 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 801. In some embodiments, the processor 801 and the memory 802 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.
[0222] Processor 801 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, 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 various 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 data encryption method disclosed in the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.
[0223] The memory 802 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 802 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 802 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 802 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.
[0224] By programming the processor 801, the code corresponding to the data encryption method described in the above embodiment can be fixed into the chip, so that the chip can execute the encryption method when running. Figure 2The steps of the data encryption method of the embodiment shown are as follows: How to design and program the processor 801 is a technology well known to those skilled in the art and will not be described in detail here.
[0225] An embodiment of the present application also provides a computer-readable storage medium that stores computer-executable instructions required to execute the above-mentioned processor, which includes a program required to execute the above-mentioned processor.
[0226] In some possible implementations, various aspects of the data encryption method provided by the present application may also be implemented in the form of a program product, which includes a program code. When the above-mentioned program product is run on an electronic device, the above-mentioned program code is used to enable the above-mentioned electronic device to execute the steps of the data encryption method according to various exemplary implementations of the present application described above in this specification.
[0227] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, 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 on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0228] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (apparatus), and computer program products according to the embodiments of 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 generate 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 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0229] 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.
[0230] 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. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0231] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0232] 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. A data encryption method, characterized in that: Applied in a first terminal device, the method includes: Encrypting the login information of the first terminal device using the Ascon encryption algorithm to obtain the encrypted login information and an authentication tag corresponding to the encrypted login information, wherein the login information is related information for indicating that the user logs in to the first terminal device; Sending the encrypted login information and the authentication tag to a server, so that the server authenticates the encrypted login information based on the encrypted login information and the authentication tag to obtain an authentication result; receiving the authentication result sent by the server, and when it is determined that the authentication result is authentication passed, logging in to the first terminal device using the login information; When receiving the target message sent by the user, the target message is encrypted using the CKKS encryption algorithm to obtain the encrypted target message; The encrypted target message is sent to the server so that the server forwards the encrypted target message to the second terminal device, so that the second terminal device decrypts the encrypted target message using the CKKS decryption algorithm to obtain the target message.
2. The method according to claim 1, characterized in that: The login information includes public data and private data; The method of encrypting the login information of the first terminal device by using the Ascon encryption algorithm to obtain the encrypted login information and the authentication tag corresponding to the encrypted login information includes: Using a preset key and a random number, an initial vector generation state is obtained, wherein the initial vector generation state is used to encrypt the login information; Using the public data to update the initial vector generation state to obtain an updated vector generation state; Encrypting the private data by using the updated vector generation state to obtain the encrypted login information; and updating the updated vector generation state by using the private data to obtain a first target vector generation state; An authentication tag corresponding to the encrypted login information is obtained according to the first target vector generation state and the key.
3. The method according to claim 1, characterized in that The method of encrypting the target message by using the CKKS encryption algorithm to obtain the encrypted target message includes: Performing data cleaning on the target message to obtain a cleaned target message; Encrypting the cleaned target message using a public key to obtain an encrypted intermediate target message; The encrypted intermediate target message is processed using a preset data processing algorithm to obtain the encrypted target message.
4. A data encryption method, characterized in that: Applied in a server, the method comprises: Receiving the encrypted login information and the authentication tag sent by the first terminal device, wherein the encrypted login information is obtained by the first terminal device encrypting the login information of the first terminal device using the Ascon encryption algorithm, and the login information is used to indicate the relevant information of the user logging in to the first terminal device; Using the encrypted login information and the authentication tag to verify the authentication and obtain an authentication result; The authentication result is sent to the first terminal device, so that if the first terminal device determines that the authentication result is authentication passed, the first terminal device uses the login information to log in to the first terminal device; and when receiving the target message sent by the user, the target message is encrypted using the CKKS encryption algorithm to obtain the encrypted target message; After receiving the encrypted target message sent by the first terminal device, the encrypted target message is forwarded to the second terminal device.
5. The method according to claim 4, characterized in that The receiving of the encrypted login information and authentication tag sent by the first terminal device, the method further comprises: Receiving public data, a preset key and a random number sent by the first terminal device; wherein the public data is the data in the login information; The using the encrypted login information and the authentication tag to verify the authority and obtain the verification result includes: Using the key and the random number, an initial vector generation state is obtained, wherein the initial vector generation state is used to encrypt login information; Using the public data to update the initial vector generation state to obtain an updated vector generation state; Using the encrypted target message to update the updated vector generation state to obtain a second target vector generation state; Obtaining the tag to be authenticated by using the second target vector generation state and the key; The authentication result is obtained according to the authentication tag and the tag to be authenticated.
6. The method according to claim 5, characterized in that The obtaining the authentication result according to the authentication tag and the tag to be authenticated includes: If the authentication tag and the tag to be authenticated are the same, then the authentication result is determined to be authentication passed; or, If the authentication label and the to-be-authenticated label are not the same, the authentication result is determined to be authentication failure.
7. A data encryption device, characterized in that: The device comprises: A first encryption module, used to encrypt the login information of the first terminal device using the Ascon encryption algorithm to obtain the encrypted login information and an authentication tag corresponding to the encrypted login information, wherein the login information is related information used to indicate that the user logs in to the first terminal device; A first sending module, configured to send the encrypted login information and the authentication tag to a server, so that the server authenticates the encrypted login information based on the encrypted login information and the authentication tag; An authentication module, configured to log in to the first terminal device using the login information when it is determined that the server authentication has passed; The second encryption module is used to encrypt the target message using the CKKS encryption algorithm when receiving the target message sent by the user to obtain the encrypted target message; The second sending module is used to send the encrypted target message to the server, so that the server forwards the encrypted target message to the second terminal device, so that the second terminal device uses the CKKS decryption algorithm to decrypt the encrypted target message to obtain the target message.
8. A first terminal device, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method according to any one of claims 1 to 4 when executing a computer program stored in the memory.
9. A server, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method of any one of claims 5-6 when executing a computer program stored in the memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data protection method and system based on homomorphic encryption
CN103036884A
Platform software having video monitoring and intelligent image analysis functions
CN106817562A
Multi-malicious-software hybrid detection method, system and device with privacy protection
CN111417121A
Execution process of binary code of function secured by microprocessor
US20190080096A1
Cited By
Privacy protection decision tree coding method based on CKKS homomorphic encryption
CN120658368A