Data encryption method and device based on hash algorithm, equipment and storage medium
By using the information expansion and round key calculation method based on the grid problem framework in the hash function algorithm, the problems of complex computing logic and low quantum security resistance in the prior art are solved, and efficient quantum security resistance and ability Reconstructive.
Patent Information
- Application Number
- CN202411522515.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-10-29
AI Technical Summary
The existing hash function algorithms have complex calculation logic, high overhead, weak quantum attack resistance and low quantum security resistance in low power consumption scenarios.
The information expansion and wheel key calculation method based on the grid problem framework are adopted, and the wheel key is calculated using a random matrix, which completely decouples the information expansion, wheel key calculation and hash value calculation process.
It improves the quantum security resistance of the one-way data encryption process, reduces the cost of cryptographic algorithm replacement, and has high reconfigurable characteristics, making it easy to apply in scenarios such as the Internet of Things.
Smart Images

Figure CN119402185A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data encryption technology, and in particular to a data encryption method, device, equipment and storage medium based on a hash algorithm. Background Art
[0002] Hash functions, such as hash functions, are the most common concepts in modern cryptography and are widely used in network security communication protocols, random number generation, identity authentication, evidence storage, blockchain and other scenarios. Existing hash algorithms include MD5 (Message-Digest Algorithm), SHA1 (Secure Hash Algorithm), SHA256, SHA3 and SM3 (State Encryption Algorithm).
[0003] Although the existing hash function technology can be applied to various information encryption scenarios, there are still two major problems: the existing hash function algorithm relies on bit operations, modular addition operations and S-box structure, etc., the calculation logic is relatively complex and the overhead is large, which is not conducive to application in low-power scenarios; secondly, the existing hash algorithm relies on traditional technologies such as bit replacement in message expansion, and has weak resistance to quantum attacks, resulting in low anti-quantum security. Summary of the invention
[0004] The present invention provides a data encryption method, device, equipment and storage medium method, device, equipment and storage medium of a hash algorithm to improve the quantum security of a one-way data encryption process.
[0005] According to one aspect of the present invention, a data encryption method based on a hash algorithm is provided, the method comprising:
[0006] Obtaining a current round key in a current hash value calculation cycle; the current round key includes at least one subkey; wherein the current round key is generated based on the obtained plaintext data to be encrypted;
[0007] Obtain the historical hash key of the previous historical hash value calculation cycle;
[0008] Generate a current hash key in the current hash value calculation period according to the historical hash key and based on each subkey in the current round key;
[0009] If the current hash value calculation period meets the preset period cycle end condition, a hash value of the plaintext data to be encrypted is generated according to the current hash key under the current hash value calculation period and the historical hash keys under each historical hash value calculation period, and the hash value is used as the ciphertext data of the plaintext data to be encrypted.
[0010] According to another aspect of the present invention, there is provided a data encryption device based on a hash algorithm, the device comprising:
[0011] A round key acquisition module, used to acquire a current round key in a current hash value calculation cycle; the current round key includes at least one subkey; wherein the current round key is generated based on the acquired plaintext data to be encrypted;
[0012] A historical hash key acquisition module is used to obtain the historical hash key in the previous historical hash value calculation cycle;
[0013] A current hash key generation module, configured to generate a current hash key in the current hash value calculation period according to the historical hash key and based on each subkey in the current round key;
[0014] The ciphertext data generating module is used to generate a hash value of the plaintext data to be encrypted according to a current hash key in the current hash value calculation period and historical hash keys in each historical hash value calculation period if the current hash value calculation period meets a preset period cycle end condition, and use the hash value as the ciphertext data of the plaintext data to be encrypted.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data encryption method based on the hash algorithm described in any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data encryption method based on a hash algorithm described in any embodiment of the present invention when executed.
[0020] The embodiment of the present invention uses an information expansion and round key calculation method based on a lattice problem framework, uses a random matrix to calculate the round key, has high innovation, and improves the anti-quantum security of the one-way data encryption process; the information expansion and round key calculation process are completely decoupled from the hash value calculation process, and the information expansion and key calculation modules and hash value calculation modules can be deployed in different components, with high reconfigurability, which is convenient for application in scenarios such as the Internet of Things. The hash value calculation logic rules are independent of the key expansion, and the hash calculation is reconfigurable, that is, the round key calculation and information expansion modules change, but the hash value module and code remain unchanged, which reduces the cost of replacing the cryptographic algorithm.
[0021] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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 creative work.
[0023] Figure 1 is a flow chart of a data encryption method based on a hash algorithm provided according to Embodiment 1 of the present invention;
[0024] Figure 2 is a schematic diagram of the structure of a data encryption device based on a hash algorithm provided according to Embodiment 2 of the present invention;
[0025] Figure 3 It is a structural schematic diagram of an electronic device for implementing the data encryption method based on a hash algorithm according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] Embodiment 1
[0029] Figure 1 This is a flowchart of a data encryption method based on a hash algorithm provided in the first embodiment of the present invention. This embodiment is applicable to data encryption and decryption situations where there is a need for one-way encryption of plaintext data to be encrypted, and the encryption process has anti-quantity security. This method can be executed by a data encryption device based on a hash algorithm. The data encryption device based on a hash algorithm can be implemented in the form of hardware and / or software. The data encryption device based on a hash algorithm can be configured in an electronic device. Figure 1 As shown, the method includes:
[0030] S110, obtaining a current round key in a current hash value calculation cycle; the current round key includes at least one subkey; wherein the current round key is generated based on the obtained plaintext data to be encrypted.
[0031] S120: Obtain a historical hash key in a previous historical hash value calculation cycle.
[0032] S130. Generate a current hash key in a current hash value calculation period according to the historical hash key and based on each subkey in the current round key.
[0033] S140. If the current hash value calculation period meets the preset period cycle end condition, a hash value of the plaintext data to be encrypted is generated according to the current hash key in the current hash value calculation period and the historical hash keys in each historical hash value calculation period, and the hash value is used as the ciphertext data of the plaintext data to be encrypted.
[0034] The round key may be a key for performing hash value calculation, which is pre-generated based on the plaintext data to be encrypted. The plaintext data to be encrypted is plaintext data with a one-way encryption requirement. The round key generated based on the plaintext data to be encrypted may include at least one group, and each group of round keys includes at least one subkey for hash calculation.
[0035] In a specific embodiment, the round key and its subkeys are generated as follows:
[0036] Step a1: Obtain the plaintext data to be encrypted.
[0037] Step a2: divide the plaintext data to be encrypted according to a preset first unit length to obtain at least one group of intermediate plaintext data and the number of data groups of the intermediate plaintext data.
[0038] Optionally, data segmentation is performed on the encrypted plaintext data according to a preset first unit length to obtain at least one group of intermediate plaintext data, including: performing binary conversion on the encrypted plaintext data to obtain binary plaintext data; according to the data length of the binary plaintext data, based on a preset padding value, data padding the binary plaintext data to obtain padded plaintext data; according to the preset first unit length, data segmentation is performed on the padded plaintext data to obtain at least one group of intermediate plaintext data.
[0039] Specifically, the encrypted plaintext data msg is subjected to bit string expansion, i.e., binary conversion, to obtain binary plaintext data. The data length of the binary plaintext data is calculated, and bit padding is performed according to an integer multiple of the preset length W to obtain padded plaintext data. The preset padding value can be pre-set by relevant technical personnel according to actual needs. For example, the preset padding value can be set to 0. The specific padding method is as follows:
[0040] msg||0…0||msg…||…0…;
[0041] The data length of the padded plaintext data is an integer multiple of the preset length W.
[0042] Based on the preset first unit length, the padded plaintext data is segmented to obtain at least one set of intermediate plaintext data msg i The first unit length can be preset by relevant technical personnel, and can be the same as the above-mentioned preset length W. The specific segmentation method is as follows:
[0043] msg||0…0||msg...||...0=msg1||…msg i …||msg v ;
[0044] Among them, each group of intermediate plaintext data msg i The length of is exactly W; i=1,...,v.
[0045] Step a3: According to the preset second unit length, each group of intermediate plaintext data is divided into data to obtain the plaintext sub-data corresponding to each group of intermediate plaintext data.
[0046] The second unit length can be preset by relevant technical personnel according to actual needs, and the specific requirement is that the first unit length can be divided by the second unit length. If the second unit length is set to T, the first unit length is W, and W / T=v, then for any set of intermediate plaintext data msg i , for the intermediate plaintext data msg i Perform bit string segmentation to obtain plaintext sub-data (bit string) S 1,i , S 2,i , …, S N,i , the specific segmentation method is as follows:
[0047] msg i =S 1,i ||S 2,i ||…||S N,i ;
[0048] Each plaintext subdata S 1,i , S 2,i , …, S N,i The length is T.
[0049] Step a4: Generate subkeys under at least one round key equal to the number of data groups according to the plaintext subdata corresponding to each group of intermediate plaintext data.
[0050] Optionally, based on the plaintext sub-data corresponding to each group of intermediate plaintext data, sub-keys under at least one round key equal to the number of data groups are generated, including: for any group of intermediate plaintext data, generating a plaintext sub-data matrix based on the plaintext sub-data of the group of intermediate plaintext data; generating a lattice basis matrix, and generating a target matrix under the round key generation round corresponding to the group of intermediate plaintext data based on the plaintext sub-data matrix and the lattice basis matrix; generating at least one sub-key under the key generation round based on the matrix value in the target matrix.
[0051] Specifically, for any set of intermediate plaintext data msg i , according to the plaintext sub-data S of the group of intermediate plaintext data 1,i , S 2,i , …, S N,i , convert it into an integer (decimal) to obtain the plaintext sub-data S 1,i , S 2,i , …, S N,i The corresponding integer data a 1,i , …, a N,i , convert the integer data into vector (matrix) form, and obtain the plaintext sub-data matrix a i :
[0052] a i =(a 1,i , …, aN,i );
[0053] Perform the above operation on each group of intermediate plaintext data to obtain a1, ... a i ......a v .
[0054] Generate a lattice matrix, or read a lattice matrix. The lattice matrix can be generated in advance. You can randomly generate a lattice matrix of normal integer modulo q The integer modulus q is preset according to actual needs, where the size of N is the same as the number of elements in the plaintext sub-data matrix.
[0055] According to the plaintext sub-data matrix a i And the lattice basis matrix B, generate the target matrix Q under the round key generation round corresponding to the group of intermediate plaintext data:
[0056]
[0057] Among them, t means matrix transpose, not power meaning.
[0058] The matrix value b in the target matrix 1,i , b 2,i , …, b M,i , converted into M binary bit strings (T 1,i , T 2,i ,…,T M,i )=(b 1,i , b 2,i , …, b M,i ). Merge the converted binary bit strings to get According to the specified rules, Calculate or extract valid bits to form R subkeys, denoted as Key 1,i ,…,Key R,i , the bit length of each subkey is L. After i=1,…,v are operated in this way, a total of v round keys can be obtained, and each round key includes R subkeys Key 1,i ,…,Key R,i .
[0059] Among them, the current round key in the current hash value calculation cycle can be the i-th round key, and the i-th round key includes R subkeys Key 1,i ,…,Key R,i .
[0060] Get the historical hash key X1,…,X1 in the previous historical hash value calculation cycle C The initial hash key in the initial hash calculation cycle is generated by randomly generating an initial bit string Z1, ...Z i…, Z C , each bit string Z i The length can be set to L, and the initial bit string is (X1, ..., X C )=(Z1,…,Z C ), each X i are converted into integer form.
[0061] In a specific embodiment, generating a current hash key in a current hash value calculation period based on the historical hash key and each subkey in the current round key includes:
[0062] Step b1: Generate intermediate hash parameters based on the historical hash key.
[0063] If the historical hash key is (X1, ..., X C ), the generation process of the intermediate hash parameter Y is as follows:
[0064] Y=X1+X2+…X C-1 ;
[0065] Among them, "+" is a modular addition operation.
[0066] Step b2: performing a bit string cyclic shift operation on the intermediate hash parameter to obtain a reference hash parameter.
[0067] The intermediate hash parameter Y is converted into a bit string form, and the intermediate hash parameter is subjected to a bit string cyclic shift. For example, the low-order bits can be converted to high-order bits by cyclic right shift to obtain a new bit string Y, and the bit string Y is converted into an integer to obtain a reference hash parameter Y. * .
[0068] Step b3: Generate the current hash key in the current hash value calculation period based on the reference hash parameter and the subkeys in the current round key.
[0069] According to the reference hash parameter Y * , and perform modular addition operations based on each subkey in the current round key. If the current round key is the first round and the subkey is the first subkey, calculate the modular addition U:
[0070] U=Y * +Key 1,1 ;
[0071] Among them, "+" is a modular addition operation.
[0072] Update calculation Update calculation X j =X j-1 , j = 1, 2, ... C; output updated X1, ..., X CAs the calculation result of the first round of small cycle. In the current hash calculation cycle, after R rounds of cycles, the difference between each round is only the round key (the order of using the round key is Key 1,1 ,Key 2,1 ,…,Key R,1 ), and obtain the output X1,…,X1 after R rounds of small cycles. C , as the current hash key in the current hash value calculation cycle.
[0073] If the current hash value calculation period meets the preset period cycle end condition, a hash value of the plaintext data to be encrypted is generated according to the current hash key under the current hash value calculation period and the historical hash keys under each historical hash value calculation period, and the hash value is used as the ciphertext data of the plaintext data to be encrypted.
[0074] It can be understood that the number of data groups of intermediate plaintext data is v, and it is necessary to complete the loop traversal of each group of intermediate plaintext data. Therefore, the cycle end condition is set based on the number of data groups of the intermediate plaintext data. The input result of each round is the output result of the previous round. After v rounds of loops, the X1...X generated by the last round of loop is obtained. C If the current hash value calculation cycle is the last cycle, then the X1…X generated by the current hash value calculation cycle C Concatenate and obtain the hash value X=X1||…||X of the plaintext data to be encrypted C The hash value is used as the ciphertext data of the plaintext data to be encrypted.
[0075] The embodiment of the present invention uses an information expansion and round key calculation method based on a lattice problem framework, uses a random matrix to calculate the round key, has high innovation, and improves the anti-quantum security of the one-way data encryption process; the information expansion and round key calculation process are completely decoupled from the hash value calculation process, and the information expansion and key calculation modules and hash value calculation modules can be deployed in different components, with high reconfigurability, which is convenient for application in scenarios such as the Internet of Things. The hash value calculation logic rules are independent of the key expansion, and the hash calculation is reconfigurable, that is, the round key calculation and information expansion modules change, but the hash value module and code remain unchanged, which reduces the cost of replacing the cryptographic algorithm.
[0076] Based on the above embodiments, this embodiment also provides a preferred embodiment, and the specific implementation method is as follows.
[0077] This scheme includes five main steps: algorithm initialization, data initialization, data padding and trimming, round key calculation and hash value calculation. Each step is described in detail below:
[0078] 1. Algorithm initialization
[0079] Determine the basic parameters of the algorithm: including output length = P, usually 128, 256, 512, etc.; data unit length = W; plaintext group length = L, also known as word length, usually 16, 32, etc.; number of groups P / L = C; modulus = D, usually 2^16, 2^32, etc.; number of iterations = R, usually 16, 32, 48, 64, etc.; lattice basis parameters q, M, N, that is, the relevant parameters of the lattice basis matrix B∈Z_q^(M×N), generally requiring D≤q. This solution has no special restrictions and constraints on the parameters, and the parameter values in the solution content are for reference only.
[0080] 2. Data initialization
[0081] 1. Generate C initial group bit strings Z1, ..., Z according to the specified length using a pseudo-random number generator or other methods C , the length of each string is L, Z1,…,Z C After being generated, it is stored for a long time as the initialization data of the hash function. If this initialization data is updated, it means that the hash function has changed and updated.
[0082] 2. Randomly generate a lattice matrix of integer modulo q After B is generated, it is stored for a long time as the initialization data of the hash function. If this initialization data is updated, it means that the hash function has changed and updated.
[0083] 3. Data filling and cutting
[0084] 1. The user expands the bit string of the input data msg to be calculated for the hash value to obtain the input data msg in binary representation, calculates the bit length of msg, and performs bit padding according to an integer multiple of W, that is, padding a certain number of 0s so that the length of msg||0…0 is exactly a multiple of W. The input data after segmentation is recorded as msg||0…0=msg1||…||msg v , satisfy each msg i The length of is exactly W.
[0085] 2. For i=1,…,v, each msg i According to the unit length = T, it is divided into W / T = v sub-bit strings, and the requirement is that W can be divided by T. The sub-bit string is recorded as S 1,i , S 2,i , …, S N,i , meet msg i =S 1,i ||S 2,i ||…||S N,i The length of each sub-bit string is T.
[0086] 3. Convert each sub-bit string (binary) into an integer (decimal), then (S1,i , S 2,i , …, S N,i )=(a 1,i , …, a N,i )=a i The same operation is performed for i=1,…,v.
[0087] 4. Calculate the round key
[0088] 1. Read the lattice matrix
[0089] 2. Calculate the matrix multiplication by the vector t represents matrix transpose, not power meaning, and the addition is modulo q addition.
[0090] 3. The integer b 1,i , b 2,i , …, b M,i Converted into M binary bit strings (T 1,i , T 2,i , …, T M,i )=(b 1,i , b 2,i , …, b M,i ).
[0091] 4. Combine the above bit strings to get a long bit string
[0092] 5. According to the specified rules, Calculate or extract valid bits to form R round keys, denoted as Key 1,i ,…,Key R,i , the bit length of each round key is L.
[0093] 6. After following the same operation for i=1, ..., v, a total of R*v round keys (Key 1,i ,…,Key R,i ) i=1,…,v .
[0094] 5. Hash value calculation
[0095] The large cycle consists of v rounds, and each large cycle is divided into R small cycles. The calculation logic of all cycles is exactly the same. Here we only introduce the first large cycle in detail.
[0096] 1. Read the initial bit string Z1, ..., Z C , each Z i The length L of the loop is (it should be noted that only the first large loop needs to read the initial bit string as the starting point of calculation, and the input of other large loops is the output of the previous large loop).
[0097] 2. Let (X1,…,X C )=(Z1,…,Z C ), and each X i are converted into integer form.
[0098] 3. Calculate integer modular addition Y = X1 + v2 + ... X C-1 (mod D).
[0099] 4. Convert Y to bit string form.
[0100] 5. Circularly shift the bit string calculated in the previous step. For example, you can convert the low-order bits to high-order bits by circularly shifting right to obtain a new bit string Y * , and convert the bit string Y * Convert to integer.
[0101] 6. Calculate the modular addition U=Y * +Key 1,1 (mod D).
[0102] 7. Update calculation (mod D).
[0103] 8. Update calculation X j =X j-1 , j=1,2,…C.
[0104] 9. Output the updated X1,…,X C As the calculation result of the first round of small cycle.
[0105] 10. In this round of large cycle, after R rounds of small cycle calculations, the difference between each round is only the round key (the order of using the round key is Key 1,1 ,Key 2,1 ,…,Key R,1 ), and obtain the output X1,…,X1 after R rounds of small cycles. C , thus completing the first round of the cycle.
[0106] 11. In the subsequent large cycle (for example, the jth large cycle), read the output X1, ..., X1 of the previous large cycle (j-1th round) C , execute the algorithm of steps 1-10, using the order of round keys as Key 1,j ,Key 2,j ,…,Key R,j After a total of v rounds of large cycles, the final hash output is X=X1||…||X C .
[0107] Embodiment 2
[0108] Figure 2A schematic diagram of the structure of a data encryption device based on a hash algorithm provided in the second embodiment of the present invention. A data encryption device based on a hash algorithm provided in the embodiment of the present invention can be applied to data encryption and decryption situations where there is a need for one-way encryption of plaintext data to be encrypted, and the encryption process has anti-quantity security. The data encryption device based on the hash algorithm can be implemented in the form of hardware and / or software, such as Figure 2 As shown, the device specifically includes: a round key acquisition module 201, a historical hash key acquisition module 202, a current hash key generation module 203 and a ciphertext data generation module 204. Among them,
[0109] The round key acquisition module 201 is used to acquire the current round key in the current hash value calculation cycle; the current round key includes at least one subkey; wherein the current round key is generated based on the acquired plaintext data to be encrypted;
[0110] A historical hash key acquisition module 202 is used to acquire a historical hash key in a previous historical hash value calculation cycle;
[0111] A current hash key generation module 203, configured to generate a current hash key in the current hash value calculation period according to the historical hash key and based on each subkey in the current round key;
[0112] The ciphertext data generating module 204 is used to generate a hash value of the plaintext data to be encrypted according to the current hash key in the current hash value calculation period and the historical hash keys in each historical hash value calculation period if the current hash value calculation period meets the preset period cycle end condition, and use the hash value as the ciphertext data of the plaintext data to be encrypted.
[0113] The embodiment of the present invention uses an information expansion and round key calculation method based on a lattice problem framework, uses a random matrix to calculate the round key, has high innovation, and improves the anti-quantum security of the one-way data encryption process; the information expansion and round key calculation process are completely decoupled from the hash value calculation process, and the information expansion and key calculation modules and hash value calculation modules can be deployed in different components, with high reconfigurability, which is convenient for application in scenarios such as the Internet of Things. The hash value calculation logic rules are independent of the key expansion, and the hash calculation is reconfigurable, that is, the round key calculation and information expansion modules change, but the hash value module and code remain unchanged, which reduces the cost of replacing the cryptographic algorithm.
[0114] Optionally, the device further includes a round key generation module; the round key generation module is specifically used to:
[0115] A plaintext data acquisition unit, used to acquire the plaintext data to be encrypted;
[0116] A plaintext data segmentation unit, configured to segment the plaintext data to be encrypted according to a preset first unit length, to obtain at least one group of intermediate plaintext data, and to obtain the number of data groups of the intermediate plaintext data;
[0117] The intermediate data segmentation unit is used to segment each group of intermediate plaintext data according to a preset second unit length to obtain plaintext sub-data corresponding to each group of intermediate plaintext data;
[0118] The subkey generation unit is used to generate subkeys under at least one round key equal to the number of the data groups according to the plaintext subdata corresponding to each group of intermediate plaintext data.
[0119] Optional, plaintext data segmentation unit, specifically used for:
[0120] Performing binary conversion on the plaintext data to be encrypted to obtain binary plaintext data;
[0121] According to the data length of the binary plaintext data, based on a preset padding value, the binary plaintext data is padded with data to obtain padded plaintext data;
[0122] According to a preset first unit length, the padded plaintext data is segmented to obtain at least one group of intermediate plaintext data.
[0123] Optionally, a subkey generation unit is specifically used to:
[0124] For any group of intermediate plaintext data, generating a plaintext sub-data matrix according to the plaintext sub-data of the group of intermediate plaintext data;
[0125] Generate a lattice basis matrix, and generate a target matrix under a round key generation round corresponding to the group of intermediate plaintext data according to the plaintext sub-data matrix and the lattice basis matrix;
[0126] At least one sub-key in the key generation round is generated according to the matrix value in the target matrix.
[0127] Optionally, the current hash key generation module 203 is specifically used for:
[0128] generating intermediate hash parameters according to the historical hash key;
[0129] Performing a bit string cyclic shift operation on the intermediate hash parameter to obtain a reference hash parameter;
[0130] According to the reference hash parameter, based on each subkey in the current round key, a current hash key in the current hash value calculation period is generated.
[0131] Optionally, the periodic cycle end condition is set based on the number of data groups of the intermediate plaintext data.
[0132] The data encryption device based on the hash algorithm provided in the embodiment of the present invention can execute the data encryption method based on the hash algorithm provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0133] Embodiment 3
[0134] Figure 3 A schematic diagram of the structure of an electronic device 30 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0135] like Figure 3 As shown, the electronic device 30 includes at least one processor 31, and a memory connected to the at least one processor 31, such as a read-only memory (ROM) 32, a random access memory (RAM) 33, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 31 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 32 or the computer program loaded from the storage unit 38 to the random access memory (RAM) 33. In the RAM 33, various programs and data required for the operation of the electronic device 30 can also be stored. The processor 31, the ROM 32, and the RAM 33 are connected to each other through a bus 34. An input / output (I / O) interface 35 is also connected to the bus 34.
[0136] A number of components in the electronic device 30 are connected to the I / O interface 35, including: an input unit 36, such as a keyboard, a mouse, etc.; an output unit 37, such as various types of displays, speakers, etc.; a storage unit 38, such as a disk, an optical disk, etc.; and a communication unit 39, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 39 allows the electronic device 30 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0137] The processor 31 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 31 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 31 executes the various methods and processes described above, such as a data encryption method based on a hash algorithm.
[0138] In some embodiments, the data encryption method based on the hash algorithm can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 38. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 30 via the ROM 32 and / or the communication unit 39. When the computer program is loaded into the RAM 33 and executed by the processor 31, one or more steps of the data encryption method based on the hash algorithm described above can be performed. Alternatively, in other embodiments, the processor 31 can be configured to perform the data encryption method based on the hash algorithm by any other appropriate means (for example, by means of firmware).
[0139] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0140] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0141] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0142] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0143] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0144] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0145] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0146] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A data encryption method based on a hash algorithm, characterized in that: include: Get the current round key in the current hash value calculation cycle; The current round key includes at least one subkey; wherein the current round key is generated based on the obtained plaintext data to be encrypted; Obtain the historical hash key of the previous historical hash value calculation cycle; Generate a current hash key in the current hash value calculation period according to the historical hash key and based on each subkey in the current round key; If the current hash value calculation period meets the preset period cycle end condition, a hash value of the plaintext data to be encrypted is generated according to the current hash key under the current hash value calculation period and the historical hash keys under each historical hash value calculation period, and the hash value is used as the ciphertext data of the plaintext data to be encrypted.
2. The method according to claim 1, characterized in that The subkeys in the round key are generated as follows: Obtain the plaintext data to be encrypted; According to a preset first unit length, data segmentation is performed on the plaintext data to be encrypted to obtain at least one group of intermediate plaintext data, and the number of data groups of the intermediate plaintext data is obtained; According to the preset second unit length, each group of intermediate plaintext data is divided into data to obtain plaintext sub-data corresponding to each group of intermediate plaintext data; According to the plaintext sub-data respectively corresponding to each group of intermediate plaintext data, sub-keys under at least one round key equal to the number of the data groups are generated.
3. The method according to claim 2, characterized in that The step of dividing the plaintext data to be encrypted according to the preset first unit length to obtain at least one set of intermediate plaintext data includes: Performing binary conversion on the plaintext data to be encrypted to obtain binary plaintext data; According to the data length of the binary plaintext data, based on a preset padding value, the binary plaintext data is padded with data to obtain padded plaintext data; According to a preset first unit length, the padded plaintext data is segmented to obtain at least one group of intermediate plaintext data.
4. The method according to claim 2, characterized in that: The step of generating, according to the plaintext sub-data corresponding to each group of intermediate plaintext data, sub-keys under at least one round key equal to the number of the data groups, comprises: For any group of intermediate plaintext data, generating a plaintext sub-data matrix according to the plaintext sub-data of the group of intermediate plaintext data; Generate a lattice basis matrix, and generate a target matrix under a round key generation round corresponding to the group of intermediate plaintext data according to the plaintext sub-data matrix and the lattice basis matrix; At least one sub-key in the key generation round is generated according to the matrix value in the target matrix.
5. The method according to claim 1, characterized in that The step of generating the current hash key in the current hash value calculation period based on the historical hash key and each subkey in the current round key includes: generating intermediate hash parameters according to the historical hash key; Performing a bit string cyclic shift operation on the intermediate hash parameter to obtain a reference hash parameter; According to the reference hash parameter, based on each subkey in the current round key, a current hash key in the current hash value calculation period is generated.
6. The method according to claim 2 is characterized in that the periodic cycle end condition is set based on the number of data groups of the intermediate plaintext data.
7. A data encryption device based on a hash algorithm, characterized in that: include: A round key acquisition module is used to obtain the current round key in the current hash value calculation cycle; The current round key includes at least one subkey; wherein the current round key is generated based on the obtained plaintext data to be encrypted; A historical hash key acquisition module is used to obtain the historical hash key in the previous historical hash value calculation cycle; A current hash key generation module, configured to generate a current hash key in the current hash value calculation period according to the historical hash key and based on each subkey in the current round key; The ciphertext data generating module is used to generate a hash value of the plaintext data to be encrypted according to a current hash key in the current hash value calculation period and historical hash keys in each historical hash value calculation period if the current hash value calculation period meets a preset period cycle end condition, and use the hash value as the ciphertext data of the plaintext data to be encrypted.
8. The device according to claim 7, characterized in that The device also includes a round key generation module; The round key generation module comprises: A plaintext data acquisition unit, used to acquire the plaintext data to be encrypted; A plaintext data segmentation unit, configured to segment the plaintext data to be encrypted according to a preset first unit length, to obtain at least one group of intermediate plaintext data, and to obtain the number of data groups of the intermediate plaintext data; The intermediate data segmentation unit is used to segment each group of intermediate plaintext data according to a preset second unit length to obtain plaintext sub-data corresponding to each group of intermediate plaintext data; The subkey generation unit is used to generate subkeys under at least one round key equal to the number of the data groups according to the plaintext subdata corresponding to each group of intermediate plaintext data.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data encryption method based on the hash algorithm according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data encryption method based on a hash algorithm as described in any one of claims 1 to 6 when executed.
Citation Information
Patent Citations
Digital signature method and device, equipment and storage medium
CN116055029A
Message authentication code generation method and device, computer equipment and storage medium
CN116405223A
Anti-quantum ciphertext equivalent test public key encryption method and system based on lattice
CN118400197A
Encryption And Decryption Method And Device Based On Random Hash And Bit Operation
US20220109566A1
Method and system for a lattice-based homomorphic proxy re-encryption scheme
US20240195618A1