Data encryption processing method and device

By splitting the to-processed data into fixed-length operators and using multiple encryption calculation units for iterative calculations, the problem that the encryption algorithm hardware with fixed input data length cannot be reused is solved, and efficient processing of data of any length is achieved and resource conservation.

CN119094107AActive Publication Date: 2024-12-06SANECHIPS TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310619704.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-29
Publication Date
2024-12-06
Estimated Expiration
2043-05-29

AI Technical Summary

Technical Problem

In the prior art, the hardware implementation of the encryption algorithm with fixed input data length cannot be reused, resulting in high resource occupancy, increased cost and power consumption when processing long data, and increased optimization difficulty, and lack of effective processing methods for data of any length.

Method used

The microprocessor splits the to-process data into multiple operators of fixed lengths, and uses multiple encryption computing units to perform iterative calculations, realizing the encryption processing of data of any length, improving the reusability and hardware resources of the encryption computing unit utilization rate.

Benefits of technology

It improves the reusability of the encrypted computing unit and the speed of hardware algorithm calculation, saves hardware resources, and supports efficient processing of input data of any length.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094107A_ABST
    Figure CN119094107A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data encryption processing method and device, the method is applied to a microprocessor, the microprocessor is connected with n encryption calculation units, n is a positive integer, the method comprises the following steps: obtaining to-be-processed data and a secret key, generating first target data composed of m operators according to the to-be-processed data and the secret key, and sending the first operator in the m operators to the target encryption calculation unit for calculation, storing a calculation result returned by the target encryption calculation unit as a first first result, and sending the ith operator and the (i-1) th first result to the target encryption calculation unit for calculation, the calculation result returned by the target encryption calculation unit is stored as the ith first result, and i = 2,..., m. According to the embodiment of the invention, the problem that hardware implementation of an encryption algorithm with a fixed input data length cannot be reused and reconstructed in related technologies can be solved, the reusability of an encryption calculation unit is improved, hardware resources are saved, and the running speed is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communications, and in particular, to a data encryption processing method and device. Background Art

[0002] SHA-2 (Secure Hash Algorithm 2) is a one-way hash algorithm published in 2002. It can map messages of any length into information digests of fixed length. According to the length of the output message digest, it can be divided into SHA-224, SHA-256, SHA-384 and SHA-512. It can be applied to digital signatures, HMAC (Hash-based Message Authentication Code) authentication, password protection, data integrity verification, and network security protocols. Among them, SHA-256 can convert any limited length input message (less than 2^64 bits) into a message digest of 256 bits. The processing steps can be divided into three parts: data preprocessing, data expansion and data compression. HMAC is an algorithm based on SHA and a key. It is currently used by many security protocols to provide authentication services and is widely used. The implementation of HMAC-SHA can be seen as an integration of multiple SHA operations. In practical applications, the HMAC-SHA algorithm effect can be achieved by calling SHA operations according to the key and message respectively. HMAC-SHA-256 is based on the algorithm calculation of SHA-256 in the SHA algorithm.

[0003] SHA-2 can be implemented in software on general-purpose devices or in hardware using dedicated devices. Software implementation has the characteristics of low resource consumption, good usability and easy portability. However, with the development of communication technology, the amount of data that encryption algorithms need to process has exploded. In many applications, the simple SHA-2 software implementation has gradually failed to meet the speed requirements of the system. In order to improve the efficiency of system operation, many systems have begun to choose to use SHA-2 dedicated hardware devices.

[0004] At present, the hardware implementation of the SHA algorithm mainly uses a pipeline structure and performs calculations based on the fixed length of the input data. However, if the data is very long, the calculation path will be very long, occupying more resources, which means higher costs and power consumption. In the related art, the hardware implementation method is optimized specifically according to the situation of each input data, but the optimization scheme will introduce a complex control unit, and there are problems such as incompatibility with other optimization schemes or high process requirements. More importantly, these schemes can only perform algorithm calculations on fixed-length input data, are not reusable, and as the data length becomes longer and longer, the difficulty of optimization becomes greater and greater.

[0005] In summary, there is no good solution to the problem that the hardware implementation of the encryption algorithm with fixed input data length in the related art cannot be reused and reconstructed. Summary of the invention

[0006] The embodiments of the present application provide a data encryption processing method and device to at least solve the problem that the hardware implementation of the encryption algorithm with a fixed input data length in the related art cannot be reused and reconstructed.

[0007] According to an embodiment of the present application, a data encryption processing method is provided, which is applied to a microprocessor, and the microprocessor is connected to n encryption computing units, where n is a positive integer, and the method includes: obtaining data to be processed and a key; generating first target data according to the data to be processed and the key, wherein the first target data is composed of m operators, each operator corresponds to data of a first preset length, and m is an integer greater than 1; sending the first operator of the m operators to a target encryption computing unit for calculation, and saving the calculation result returned by the target encryption computing unit as the first first result, wherein the target encryption computing unit is any one of the n encryption computing units; for each operator from the 2nd to the mth operators of the m operators, sending the i-th operator and the i-1th first result to the target encryption computing unit for calculation, and saving the calculation result returned by the target encryption computing unit as the i-th first result, wherein i=2,...,m, and the i-1th first result is the calculation result of the target encryption computing unit calculating the i-1th operator.

[0008] According to another embodiment of the present application, a data encryption processing device is provided, which includes: a microprocessor and n encryption computing units, wherein n is a positive integer; the microprocessor is used to obtain data to be processed and a key, and generate first target data according to the data to be processed and the key, wherein the first target data is composed of m operators, each operator corresponds to data of a first preset length, and m is an integer greater than 1; the first operator of the m operators is sent to a target encryption computing unit for calculation, and the calculation result returned by the target encryption computing unit is saved as the first first result, wherein the target encryption computing unit is the first operator of the n encryption computing units. any one of; for each operator from the 2nd to the mth operators among the m operators, the ith operator and the i-1th first result are sent to the target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the ith first result, wherein i=2,...,m, and the i-1th first result is the calculation result of the target encryption calculation unit calculating the i-1th operator; an encryption calculation unit, for receiving each operator from the 1st to the mth operators and the 1st to the m-1th first results sent by the microprocessor, performing encryption calculation on each operator respectively, and sending the calculation result to the microprocessor.

[0009] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps of any of the above method embodiments when executed by a processor.

[0010] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0011] In an embodiment of the present application, a microprocessor is used to pre-process the data to be processed and the key to generate first target data consisting of multiple operators of fixed length, and each operator is sent to an encryption calculation unit for multiple data interactions and iterative operations. This can solve the problem that the hardware implementation of the encryption algorithm with a fixed input data length in the related technology cannot be reused and reconstructed, which not only improves the reusability of the encryption calculation unit and saves hardware resources, but also has the advantage of faster hardware algorithm calculation and operation speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 It is a hardware structure block diagram of the data encryption processing method of the embodiment of the present application;

[0013] Figure 2 is a hardware structure block diagram of a SHA-2 computing unit according to an embodiment of the present application;

[0014] Figure 3 It is a processing flow diagram of a SHA-256 calculation unit according to an embodiment of the present application;

[0015] Figure 4 is a flow chart of a data encryption processing method according to an embodiment of the present application;

[0016] Figure 5 is a flow chart of performing data encryption processing according to the HMAC-SHA-2 algorithm according to an embodiment of the present application;

[0017] Figure 6 It is a flowchart of a data encryption processing method based on SHA-256 according to an embodiment of the present application;

[0018] Figure 7 is a structural block diagram of a data encryption processing device according to an embodiment of the present application (I);

[0019] Figure 8 is a structural block diagram of a data encryption processing device according to an embodiment of the present application (II);

[0020] Fig. 9 It is a structural block diagram of a microprocessor for data encryption processing according to an embodiment of the present application. DETAILED DESCRIPTION

[0021] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0023] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 is a hardware structure block diagram of the data encryption processing method of the embodiment of the present application, such as Figure 1 As shown, the hardware board may include one or more ( Figure 1 Only one is shown in the figure) a processor 12 (the processor 12 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device) and a memory 14 for storing data, wherein the mobile terminal may also include a transmission device 16 for communication functions and an input and output device 18. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1Different configurations shown.

[0024] The memory 14 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data encryption processing method in the embodiment of the present application. The processor 12 executes various functional applications and data encryption processing methods by running the computer program stored in the memory 14, that is, to implement the above method. The memory 14 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 14 may further include a memory remotely arranged relative to the processor 12, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0025] The transmission device 16 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider. In one example, the transmission device 16 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 16 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0026] According to an embodiment of the present application, a data encryption processing method is provided, which is applied to a microprocessor, wherein the microprocessor is connected to n encryption calculation units, where n is a positive integer. The encryption calculation unit is implemented by a hardware structure.

[0027] In an exemplary embodiment, the encryption calculation unit is a hardware implementation of the encryption algorithm and can only process input data of a fixed length, and specifically may be a SHA-2 calculation unit.

[0028] Figure 2 is a hardware structure block diagram of a SHA-2 computing unit according to an embodiment of the present application, such as Figure 2 As shown, taking the SHA-256 computing unit as an example, the following structure may be included:

[0029] Counting unit 21, data expansion unit 22, data compression unit 23, constant selection unit 24, data preprocessing unit 25, data output unit 26.

[0030] In this embodiment, the counting unit 21 is used to count the current number of calculation rounds so that other units select calculation data according to the current number of calculation rounds. Further, each time the microprocessor sends an operator to the SHA-256 calculation unit, the SHA-256 calculation unit needs to perform 64 rounds of iterative calculations.

[0031] In this embodiment, the data expansion unit 22 is used to expand the input 512-bit operator into 64 32-bit data, and select the data involved in the calculation according to the number of calculation rounds in the counting unit 21.

[0032] In this embodiment, the constant selection unit 24 is used to select 64 K constants according to the number of calculation rounds to participate in the calculation.

[0033] In an exemplary embodiment, the 64 K constants (i.e., K0-K63) include, in order: 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe , 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5 cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6 351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e , 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x1 06aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6 ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2.

[0034] In an embodiment of the present application, the data preprocessing unit 25 is used to select the hash value of the iterative calculation. If it is the initial iterative calculation, the hash constant is selected, otherwise the result obtained by the previous round of calculation is selected as the hash value. Further, the embodiment of the present application only uses the hash constant when calculating the first operator, and uses the calculation result of the previous operator SHA-256 when calculating other operators.

[0035] In an exemplary embodiment, the hash constants include: 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19.

[0036] In this embodiment, the data compression unit 23 performs 64 rounds of iterative calculations according to the data selected in the above-mentioned units.

[0037] In an exemplary embodiment, each round of iterative calculation in the data compression unit 23 may include the following calculation steps:

[0038] sum0=a_reg>>>2^a_reg>>>13^a_reg>>>22

[0039] sum1=e_reg>>>>6^e_reg>>>>11^e_reg>>>>25

[0040] ch=(e_reg&f_reg)^(~e_reg&f_reg)

[0041] maj=(a_reg&b_reg)^(a_reg&c_reg)^(b_reg&c_reg)

[0042] t1=h_reg+sum1+ch+tmp_w+tem_k

[0043] t2=sum0+maj

[0044] a_reg=t1+t2

[0045] b_reg=a_reg

[0046] c_reg=b_reg

[0047] d_reg=c_reg

[0048] e_reg=d_reg+t1

[0049] f_reg=e_reg

[0050] g_reg=f_reg

[0051] h_reg=g_reg

[0052] Among them, >>> is a circular right shift, >> is a logical right shift, the initial a_reg to h_reg are eight hash values ​​selected by the data preprocessing unit 25, tmp_w is the data selected by the data expansion unit 21 in each round, and tem_k is the data selected by the constant selection unit 23 in each round.

[0053] In this embodiment, the data output unit 26 is only valid after the data compression unit 23 performs 64 rounds of calculation. It is used to perform the final calculation on the calculation result of the last round of the data compression unit 23 (the final a_reg to h_reg) and the initial hash value in the data preprocessing unit 25 (the hash constant or the iterative calculation result of the previous operator), and output the final calculation result.

[0054] The SHA-2 calculation unit in the embodiment of the present application is implemented by hardware and can only process input data of fixed length. However, the embodiment of the present application can split the input data of any finite length (length less than 2^64 bits) into multiple operators of fixed length through a microprocessor, and then iterate the calculation of multiple operators through the SHA-2 calculation unit, thereby completing the SHA-2 calculation of input data of any length in a hardware manner.

[0055] The embodiment of the present application does not limit the hardware structure of the SHA-2 calculation unit, and the SHA-2 calculation unit may also adopt other hardware implementation methods.

[0056] Figure 3 is a schematic diagram of a processing flow of a SHA-256 calculation unit according to an embodiment of the present application, such as Figure 3 As shown, taking the SHA-256 calculation unit as an example, the process includes: expanding the input data (data_in) into w0 to w63; selecting a 32-bit data from w0 to w63 and a constant from k0 to k63 in turn according to the calculation round, and performing 64 rounds of iterative calculations on the hash value (a to h); summing the calculation result of the 64th round with the initial hash value to obtain the final SHA-256 calculation result.

[0057] Through the embodiments of the present application, the SHA-2 algorithm can be implemented in hardware to improve the computing efficiency. The present application is not limited to the SHA-256 algorithm, and the SHA-2 computing unit can also be a dedicated hardware device for other SHA-2 algorithms.

[0058] Furthermore, the encryption calculation unit in the embodiment of the present application can also be replaced by other hardware encryption calculation units with fixed input length.

[0059] Figure 4 is a flow chart of a data encryption processing method according to an embodiment of the present application. Figure 4 As shown, the process includes the following steps:

[0060] Step S402, obtaining the data to be processed and the key;

[0061] Step S404, generating first target data according to the data to be processed and the key, wherein the first target data is composed of m operators, each operator corresponds to data of a first preset length, and m is an integer greater than 1;

[0062] Step S406, sending the first operator of the m operators to a target encryption calculation unit for calculation, and saving the calculation result returned by the target encryption calculation unit as the first first result, wherein the target encryption calculation unit is any one of the n encryption calculation units;

[0063] Step S408, for each of the 2nd to mth operators among the m operators, send the i-th operator and the i-1th first result to the target encryption calculation unit for calculation, and save the calculation result returned by the target encryption calculation unit as the i-th first result, where i=2,...,m, and the i-1th first result is the calculation result of the target encryption calculation unit calculating the i-1th operator.

[0064] In this embodiment, the microprocessor is connected to n encryption computing units, where n is a positive integer.

[0065] In an embodiment of the present application, through the above-mentioned steps S402 to S410, the problem that the hardware implementation of the encryption algorithm with a fixed input data length in the related technology cannot be reused and reconstructed can be solved. By exchanging data with the encryption computing unit through the microprocessor, the reusability of the encryption computing unit is improved, hardware resources are saved, and the hardware algorithm calculation has the advantage of faster running speed.

[0066] In an exemplary embodiment, the data to be processed may be input data to be encrypted, and the key may be a first key, which is an internal padding key of a second preset length generated according to an input initial key.

[0067] In another exemplary embodiment, the data to be processed may be an encryption result calculated using a secure hash algorithm on the input data to be encrypted and a first key, the key is a second key, and the first key and the second key are respectively an internal filling key and an external filling key of a second preset length generated based on the input initial key.

[0068] Furthermore, the method also includes: generating second target data based on the mth first result and the second key, wherein the second target data is composed of l operators, each operator corresponds to data of a first preset length, and l is an integer greater than 1; sending the first operator of the l operators to the target encryption calculation unit for calculation, and saving the calculation result returned by the target encryption calculation unit as the first second result; for each operator from the 2nd to the lth operators of the l operators, sending the jth operator and the j-1th second result to the target encryption calculation unit for calculation, and saving the calculation result returned by the target encryption calculation unit as the jth second result, wherein j=2,...,l, and the j-1th second result is the calculation result of the target encryption calculation unit calculating the j-1th operator.

[0069] The data encryption processing method adopted in the embodiment of the present application combines HMAC (Keyed-Hashing for Message Authentication) with an encryption algorithm with a fixed input length, such as SHA-2 (Secure Hash Algorithm 2). The HMAC-SHA-2 algorithm needs to first perform SHA-2 calculation on the input data and the internal padding key, and then perform SHA-2 calculation on the calculation result and the external padding key, that is, it corresponds to the method in the above embodiment of first performing encryption operation on the first key and the data to be encrypted (first target data), and then performing encryption operation on the encryption result and the external padding key (second target data).

[0070] In this embodiment, the microprocessor can extract the data to be processed and the key as an operator, and then send the operator to the SHA-2 calculation unit implemented by hardware, without the need for additional design of the SHA-2 calculation unit, thereby improving the reusability of the SHA-2 calculation unit. The embodiment of the present application can also make up for the disadvantage that the SHA-2 calculation unit can only perform algorithm calculations on input data of a fixed length, and even if very long input data needs to be processed, a large amount of hardware resources can be saved.

[0071] In an exemplary embodiment, step S404 may include the following steps:

[0072] Step S4042, concatenating the data to be processed and the key to obtain first concatenated data;

[0073] Step S4044: performing data filling on the first spliced ​​data to obtain the first target data.

[0074] In an exemplary embodiment, the first key can be obtained by the following method:

[0075] When the length of the initial key is greater than the second preset length, the initial key is sent to one of the n encryption calculation units for calculation to obtain an intermediate key of the second preset length;

[0076] An XOR operation is performed on the intermediate key and a preset internal filling sequence to obtain the first key.

[0077] In another exemplary embodiment, the first key and the second key may be obtained by the following method:

[0078] When the length of the initial key is greater than the second preset length, the initial key is sent to one of the n encryption calculation units for calculation to obtain an intermediate key of the second preset length;

[0079] Performing an XOR operation on the intermediate key and a preset internal padding sequence to obtain the first key;

[0080] An XOR operation is performed on the intermediate key and a preset external padding sequence to obtain the second key.

[0081] In an exemplary embodiment, the inner pad sequence (ipad for short) is a fixed-length byte sequence, which is filled with 0x36 (hexadecimal), that is, 0x36 is repeated multiple times to a first preset length. The outer pad sequence (opad for short) is similar to the inner pad sequence, which is filled with 0x5C (hexadecimal), that is, 0x5C is repeated multiple times to a first preset length.

[0082] In an exemplary embodiment, the encryption calculation unit may be a secure hash algorithm SHA-2 calculation unit.

[0083] Furthermore, when the SHA-2 calculation unit calculates the first operator among the m operators, the preset initial hash constant is used as the initial hash value of the secure hash algorithm; when the SHA-2 calculation unit calculates the i-th operator among the m operators, the i-1-th first result is used as the initial hash value of the secure hash algorithm.

[0084] In an exemplary embodiment, step S4044 may include: converting the total length of the first spliced ​​data into first length information of a third preset length; adding a bit tail identifier, multiple preset fillers and the first length information in sequence after the first spliced ​​data to fill the data to obtain the first target data, wherein the length of the first target data is m times the first preset length.

[0085] In an exemplary embodiment, when the SHA-2 calculation unit is a SHA-256 calculation unit, the first preset length is 256 bits, the second preset length is 512 bits, the third preset length is 64 bits, the end-of-bit identifier is 1, and the preset filler is 0. The first target data consists of input data (length is less than 2^64 bits), an internal padding key (256 bits), a 1 (end-of-bit identifier), multiple 0s (preset fillers), and 64 bits of first length information.

[0086] In an exemplary embodiment, the specific steps of generating the second target data according to the mth first result and the second key are similar to the steps of generating the first target data in the above embodiment, and are also obtained through splicing and data filling, except that the data to be encrypted is replaced by the mth first result obtained by iteratively processing the first target data.

[0087] Figure 5 is a flow chart of performing data encryption processing according to the HMAC-SHA-2 algorithm according to an embodiment of the present application, which is applied to a microprocessor, such as Figure 5 As shown, the following steps may be specifically included:

[0088] Step S502, obtaining input data and an initial key, and processing the initial key into an inner padding key and an outer padding key of a second preset length;

[0089] Step S504, concatenating the input data and the internal padding key to obtain first concatenated data, and performing data padding on the first concatenated data to obtain first target data including a plurality of operators, wherein each operator corresponds to data of a first preset length;

[0090] Step S506, sending the first target data to a secure hash algorithm SHA-2 calculation unit, and receiving an encryption result obtained by the SHA-2 calculation unit by performing SHA-2 calculation on the first target data in an iterative manner;

[0091] Step S508, concatenating the encryption result and the external padding key to obtain second concatenated data, and performing data padding on the second concatenated data to obtain second target data including multiple operators;

[0092] Step S510: Send the second target data to the SHA-2 calculation unit, and receive output data obtained by the SHA-2 calculation unit performing SHA-2 calculation on the second target data in an iterative manner.

[0093] In the embodiment of the present application, through the above-mentioned steps S502 to S510, the problem that the hardware implementation of the encryption algorithm with a fixed input data length in the related technology cannot be reused and reconstructed can be solved. By exchanging data with the SHA-2 calculation unit through the microprocessor, multiple reuse of the SHA-2 calculation unit is achieved, which not only saves hardware resources, but also has the advantage of faster hardware algorithm calculation and operation speed.

[0094] In this embodiment, the encryption result in step S506 is equivalent to the mth first result in the above embodiment, after m iterations of the SHA-2 algorithm, and the output data in step S510 is equivalent to the lth second result in the above embodiment, after l iterations. m and l are the number of fixed-length operators.

[0095] The data encryption processing method adopted in the embodiment of the present application combines HMAC (Keyed-Hashing for Message Authentication) and SHA-2 (Secure Hash Algorithm 2). The input data and the key are extracted as operators through a microprocessor, and the operators are then sent to a SHA-2 calculation unit implemented by hardware. There is no need for additional design of the SHA-2 calculation unit, thereby improving the reusability of the SHA-2 calculation unit.

[0096] In the related art, the hardware implementation method of the SHA-2 algorithm only processes data of a fixed input length (i.e., a first preset length). The method in the embodiment of the present application can make up for the shortcoming that the SHA-2 calculation unit can only perform algorithm calculations on input data of a fixed length. Even if very long input data needs to be processed, a large amount of hardware resources can be saved.

[0097] In this embodiment, the SHA-2 algorithm can convert any limited-length input message (less than 2^64 bits) into a fixed-length message digest. The SHA-2 algorithm is divided into four algorithms: SHA-224, SHA-256, SHA-384, and SHA-512, according to the length of the different output message digests. The second preset length in step S402 is the length of the message digest output by the SHA-2 calculation unit.

[0098] In an exemplary embodiment, the SHA-2 calculation unit is a SHA-256 calculation unit, and the length of the output data is 256 bits, that is, the second preset length is 256 bits.

[0099] In another exemplary embodiment, in a hardware implementation method of the SHA-256 calculation unit, the first preset length is 512 bits, that is, the microprocessor can only perform encryption operations on input data with a length of 512 bits at a time. By preprocessing the input data by the microprocessor, it is possible to split data of any length into operators of fixed length, and then send the operators to the SHA-256 calculation unit.

[0100] In an exemplary embodiment, processing the initial key into an inner padding key and an outer padding key of a second preset length in step S502 may include the following steps:

[0101] Step S5022, processing the initial key into an intermediate key of the second preset length;

[0102] Step S5024, performing an XOR operation on the intermediate key and a preset internal filling sequence to obtain the internal filling key;

[0103] Step S5026, performing an XOR operation on the intermediate key and a preset external filling sequence to obtain the external filling key.

[0104] In this embodiment, the inner filling sequence in step S5024 and the outer filling sequence in step S5026 are of a second preset length.

[0105] In an exemplary embodiment, the inner pad sequence (ipad for short) is a fixed-length byte sequence, which is filled with 0x36 (hexadecimal), that is, 0x36 is repeated multiple times to a second preset length. The outer pad sequence (opad for short) is similar to the inner pad sequence, which is filled with 0x5C (hexadecimal), that is, 0x5C is repeated multiple times to a second preset length.

[0106] In an exemplary embodiment, step S5022 may include any of the following situations:

[0107] When the length of the initial key is less than the second preset length, padding the initial key to the second preset length with a plurality of preset fillers to obtain the intermediate key;

[0108] When the length of the initial key is greater than the second preset length, sending the initial key to the SHA-2 calculation unit for calculation, and receiving the intermediate key obtained by the SHA-2 calculation unit performing SHA-2 calculation on the initial key;

[0109] When the length of the initial key is equal to the second preset length, the initial key is directly used as the intermediate key.

[0110] In an exemplary embodiment, the preset filler may be 0, and the initial key having a length less than the second preset length is padded to the second preset length by adding 0 after the initial key.

[0111] In an exemplary embodiment, performing data padding on the first spliced ​​data in step S504 to obtain first target data including multiple operators may include the following steps:

[0112] Step S5042, converting the total length of the first spliced ​​data into first length information of a third preset length;

[0113] Step S5044: Add a tail identifier, multiple preset fillers, and the first length information in sequence after the first spliced ​​data to perform data filling to obtain the first target data, wherein the length of the first target data is an integer multiple of the second preset length.

[0114] In an exemplary embodiment, when the SHA-2 calculation unit is a SHA-256 calculation unit, the second preset length is 256 bits, the second preset length is 512 bits, the third preset length is 64 bits, the end-of-bit identifier is 1, and the preset filler is 0. The first target data consists of input data (with a length less than 2^64 bits), an internal padding key (256 bits), a 1 (end-of-bit identifier), a plurality of 0s (preset fillers), and 64 bits of first length information.

[0115] Furthermore, step S5044 fills the data to an integer multiple of 512 bits by filling multiple zeros between the bit tail identifier and the first length information to obtain the first target data.

[0116] In an exemplary embodiment, a microprocessor can perform the data padding processing in steps S5042 to S5044 on input data of any length to obtain multiple fixed-length operators, and then send the multiple operators to the SHA-2 calculation unit in sequence for iterative calculation, thereby solving the problem in the related art that the SHA-2 calculation unit can only process fixed-length data.

[0117] In an exemplary embodiment, step S406 may include the following steps:

[0118] Step S5062, splitting the first target data into multiple operators;

[0119] Step S5064, sending the first operator in the first target data and the preset initial hash constant to the SHA-2 calculation unit, and receiving a calculation result obtained by the SHA-2 calculation unit performing SHA-2 calculation on the first operator in the first target data, wherein the calculation result is the second preset length;

[0120] Step S5066, using the calculation result of the previous round of SHA-2 calculation as the hash constant of the new round of SHA-2 calculation, and sending the next operator in the first target data and the hash constant to the SHA-2 calculation unit for a new round of SHA-2 calculation, until the last operator in the first target data is sent to the SHA-2 calculation unit, and receiving the encryption result obtained by the SHA-2 calculation unit performing SHA-2 calculation on the last operator in the first target data.

[0121] In an exemplary embodiment, when the input data length (ie, the first preset length) of the SHA-2 calculation unit is 512 bits, the microprocessor may send a 512-bit operator to the SHA-256 calculation unit for calculation each time.

[0122] In an exemplary embodiment, in the SHA-256 calculation unit, the preset initial hash constants are eight 32-bit constants, including: 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19.

[0123] Furthermore, the 256-bit result of the previous round of SHA-256 calculation can be divided into eight 32-bit data and used as the hash constant of the new round of SHA-256 calculation, so as to realize the iterative processing of multiple operators. N operators need to perform N rounds of SHA-256 calculation.

[0124] In an exemplary embodiment, performing data padding on the second spliced ​​data in step S508 to obtain second target data including multiple operators may include the following steps:

[0125] Step S5082, converting the total length of the second spliced ​​data into second length information of a third preset length;

[0126] Step S5084: Add a tail identifier, multiple preset fillers, and the second length information in sequence after the second spliced ​​data to fill in data, so as to obtain the second target data, wherein the length of the second target data is an integer multiple of the first preset length.

[0127] In an exemplary embodiment, step S510 may include the following steps:

[0128] Step S5102, splitting the second target data into multiple operators;

[0129] Step S5104, sending the first operator in the second target data and the preset initial hash constant to the SHA-2 calculation unit, and receiving the calculation result obtained by the SHA-2 calculation unit performing SHA-2 calculation on the first operator in the third target data, wherein the calculation result is the second preset length;

[0130] Step S5106, using the calculation result of the previous round of SHA-2 calculation as the hash constant of the new round of SHA-2 calculation, and sending the next operator in the second target data and the hash constant to the SHA-2 calculation unit for a new round of SHA-2 calculation, until the last operator in the second target data is sent to the SHA-2 calculation unit, and receiving the output data obtained by the SHA-2 calculation unit performing SHA-2 calculation on the last operator in the second target data.

[0131] In this embodiment, the specific implementations of step S504 and step S508 are substantially the same, and the specific implementations of step S506 and step S510 are substantially the same.

[0132] In the embodiment of the present application, by interacting with the SHA-2 computing unit through the microprocessor, the reusability of the SHA-2 computing unit can be improved. Only one SHA-2 computing unit needs to be set up to implement the data encryption processing flow of the entire HMAC-SHA2 algorithm, which not only ensures the hardware implementation of the HMAC-SHA2 algorithm, but also reduces resource consumption.

[0133] Figure 6 2 is a flow chart of a data encryption processing method based on SHA-256 according to an embodiment of the present application. Figure 6 As shown, the embodiment of the present application can convert an input message of any limited length (less than 2^64 bits) into a message digest with a length of 256 bits.

[0134] In this embodiment, the input message needs to be padded with data first, and the data is padded to a length that is an integer multiple of 512 bits.

[0135] Specifically, a 1 can be added to the end of the input message, and the last 64 bits of the data block are the total length of the original data. Multiple 0s are used to fill the space between the added 1 and the 64-bit total length, and the data block is filled to an integer multiple of 512 bits. Alternatively, a 1 can be added to the end of the input message, and then several 0s can be added until the message length is the value of 448, which is the remainder of the message divided by 512, and then a 64-bit total length of the original data is added to the end, so as to fill the data block to an integer multiple of 512 bits.

[0136] In this embodiment, the padded data block needs to be split into n operators, each of which is 512 bits. However, the present application is not limited thereto, and the length of the operator can be adjusted according to the requirements of the input data length in the algorithm hardware implementation.

[0137] In this embodiment, it is necessary to perform SHA-256 calculation on each group of 512-bit data (operator) in sequence.

[0138] Specifically, when performing SHA-256 calculation on the first operator M1, the first operator M1 and H0 (hash constant) need to be input into the SHA-256 calculation unit to obtain the calculation result H1. When performing SHA-256 calculation on the second operator M2, the second operator M2 and the previous round of calculation result H1 need to be input into the SHA-256 calculation unit to obtain the calculation result H2. The calculation is iterated multiple times until the last operator Mn and the previous round of calculation result Hn-1 are input into the SHA-256 calculation unit to obtain the final result Hn.

[0139] In this embodiment, the above data filling process and the data interaction with the SHA-256 calculation unit are all implemented by a microprocessor. The SHA-256 calculation of data of any length can be implemented through the embodiment of the present application, but the present application is not limited to the SHA-256 algorithm, and can also be applied to algorithms such as SHA-224, SHA-384, and SHA-512.

[0140] According to another aspect of an embodiment of the present application, a data encryption processing device is also provided.

[0141] Figure 7 is a structural block diagram of a data encryption processing device according to an embodiment of the present application (I), such as Figure 7 As shown, the device comprises:

[0142] The microprocessor 72 and n encryption computing units 74. n is a positive integer.

[0143] In an exemplary embodiment, the microprocessor 72 is used to obtain the data to be processed and the key, and generate the first target data according to the data to be processed and the key, wherein the first target data is composed of m operators, each operator corresponds to data of a first preset length, and m is an integer greater than 1; the first operator of the m operators is sent to the target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the first first result, wherein the target encryption calculation unit is any one of the n encryption calculation units; for each operator from the 2nd to the mth operators of the m operators, the i-th operator and the i-1th first result are sent to the target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the i-th first result, wherein i=2,...,m, and the i-1th first result is the calculation result of the target encryption calculation unit calculating the i-1th operator;

[0144] In an exemplary embodiment, the encryption calculation unit 74 is used to receive each of the 1st to mth operators and the 1st to m-1th first results sent by the microprocessor, perform encryption calculation on each operator respectively, and send the calculation results to the microprocessor.

[0145] In an exemplary embodiment, the encryption calculation unit is a hardware structure with a fixed input data length, such as a SHA-2 calculation unit.

[0146] Furthermore, the SHA-2 algorithm is divided into four algorithms, SHA-224, SHA-256, SHA-384, and SHA-512, according to the length of the different output message digests. The second preset length is the length of the message digest output by the SHA-2 calculation unit. Taking the SHA-256 calculation unit as an example, the length of the output data is 256 bits, that is, the second preset length is 256 bits.

[0147] In an exemplary embodiment, the microprocessor 72 is further used to process the initial key into an intermediate key of the second preset length; perform an XOR operation on the intermediate key and a preset internal filling sequence to obtain the internal filling key; perform an XOR operation on the intermediate key and a preset external filling sequence to obtain the external filling key, wherein the internal filling sequence and the external filling sequence are of the second preset length.

[0148] In an exemplary embodiment, the inner pad sequence (ipad for short) is a fixed-length byte sequence, which is filled with 0x36 (hexadecimal), that is, 0x36 is repeated multiple times to a second preset length. The outer pad sequence (opad for short) is similar to the inner pad sequence, which is filled with 0x5C (hexadecimal), that is, 0x5C is repeated multiple times to a second preset length.

[0149] In an exemplary embodiment, the microprocessor 72 is also used to fill the initial key to the second preset length with multiple preset fillers to obtain the intermediate key when the length of the initial key is less than the second preset length; send the initial key to the encryption calculation unit for calculation when the length of the initial key is greater than the second preset length, and receive the intermediate key obtained by the encryption calculation unit through encryption calculation of the initial key; when the length of the initial key is equal to the second preset length, directly use the initial key as the intermediate key.

[0150] Furthermore, the preset filler may be 0, and the initial key having a length less than the second preset length is filled to the second preset length by adding 0 after the initial key.

[0151] In an exemplary embodiment, the microprocessor 72 is also used to convert the total length of the first spliced ​​data into first length information of a third preset length; and to add a bit tail identifier, multiple preset fillers and the first length information in sequence after the first spliced ​​data to fill the data to obtain the first target data, wherein the length of the first target data is an integer multiple of the first preset length.

[0152] In an exemplary embodiment, the microprocessor 72 is also used to split the first target data into multiple operators; send the first operator in the first target data and a preset initial hash constant to the encryption calculation unit, and receive the calculation result obtained by the encryption calculation unit for the first operator in the first target data, wherein the calculation result is the second preset length; use the calculation result of the previous round of encryption calculation as the hash constant for a new round of encryption calculation, and send the next operator in the first target data and the hash constant to the encryption calculation unit for a new round of encryption calculation, until the last operator in the first target data is sent to the encryption calculation unit, and receive the encryption result obtained by the encryption calculation unit for the last operator in the first target data.

[0153] In an exemplary embodiment, the microprocessor 72 is also used to convert the total length of the second spliced ​​data into second length information of a third preset length; and to add a bit tail identifier, multiple preset fillers and the second length information in sequence after the second spliced ​​data to fill the data, so as to obtain the second target data, wherein the length of the second target data is an integer multiple of the first preset length.

[0154] In an exemplary embodiment, the microprocessor 72 is also used to split the second target data into multiple operators; send the first operator in the second target data and a preset initial hash constant to the encryption calculation unit, and receive the calculation result obtained by the encryption calculation unit for the first operator in the third target data, wherein the calculation result is the second preset length; use the calculation result of the previous round of encryption calculation as the hash constant for a new round of encryption calculation, and send the next operator in the second target data and the hash constant to the encryption calculation unit for a new round of encryption calculation, until the last operator in the second target data is sent to the encryption calculation unit, and receive the output data obtained by the encryption calculation unit for the last operator in the second target data.

[0155] In the embodiment of the present application, the reusability of the encryption computing unit can be improved by interacting with the microprocessor. Taking the HMAC-SHA2 algorithm as an example, only one SHA-2 computing unit needs to be set up to implement the data encryption processing flow of the entire HMAC-SHA2 algorithm, which not only ensures the hardware implementation of the HMAC-SHA2 algorithm, but also reduces resource consumption.

[0156] Figure 8 is a structural block diagram of a data encryption processing device according to an embodiment of the present application (II), such as Figure 8 As shown, the device comprises:

[0157] The microprocessor 72, n encryption computing units 74 and a scheduling module 86. n is a positive integer.

[0158] The scheduling module 86 is located between the microprocessor 72 and the n encryption computing units 74 .

[0159] In an exemplary embodiment, the scheduling module is used to schedule multiple encryption computing units for parallel processing when the microprocessor simultaneously obtains multiple data to be processed, wherein each data to be processed corresponds to an encryption computing unit.

[0160] Furthermore, if the microprocessor needs to perform HMAC-SHA2 calculations on multiple messages at the same time and has requirements for the calculation rate, the calculation rate can be improved by cascading multiple SHA-2 calculation units and using the scheduling module to schedule multiple SHA-2 calculation units for parallel processing. Each SHA-2 calculation unit can only perform encryption calculations on one message at a time, and multiple operators split from the same message perform iterative calculations in the same SHA-2 calculation unit.

[0161] Fig. 9 is a structural block diagram of a microprocessor for data encryption processing according to an embodiment of the present application, such as Fig. 9 As shown, the microprocessor may include:

[0162] Instruction unit 92 , calculation unit 94 and data storage unit 96 .

[0163] In an exemplary embodiment, the instruction unit 92 is used to send control instructions to the computing unit 94 and the data storage unit 96, such as storage instructions, computing instructions, etc. The instruction unit 92 can complete the splitting of the microprocessor processing steps in any of the above embodiments, and control the computing unit 94 and the data storage unit 96 in the form of instructions to jointly complete the data encryption processing flow.

[0164] In an exemplary embodiment, the calculation unit 94 is used to generate the first target data according to the data to be processed and the key under the control of the calculation instruction.

[0165] In an exemplary embodiment, the calculation unit 94 is also used to complete the calculation work required in the microprocessor under the control of the instruction unit 92, such as key processing, data filling, and operator splitting.

[0166] In an exemplary embodiment, the data storage unit 96 is used to read and write the data to be processed, the key, the first target data and the calculation results returned by the target encryption calculation unit under the control of the read and write instructions, wherein the calculation results include the 1st to mth first results.

[0167] In an exemplary embodiment, the data storage unit 96 is also used to store data involved in calculation or generated by calculation in the data encryption process. The data storage unit 96 can be divided into three parts: key, response and message.

[0168] Furthermore, the key is used to store the initial key, the internal filling key, the external filling key and the intermediate key; the return result is used to store the calculation result returned by the encryption calculation unit after performing encryption calculation on each operator, such as H1 to Hn; the message is used to store input data, first spliced ​​data, second spliced ​​data and multiple operators.

[0169] In an exemplary embodiment, taking the SHA-256 algorithm as an example, the input data message is temporarily stored in the microprocessor, and the key key can be stored in the microprocessor in the form of direct input or instruction issuance. The microprocessor determines whether to perform SHA-256 calculation based on the length of the key. If not, the key is padded to 256 bits to generate a new key; if yes, the key is sent to the interactive SHA-256 calculation unit, and when the calculation result is obtained, the original key is replaced with the new key.

[0170] In an exemplary embodiment, the microprocessor performs XOR operation on the new key with 256'h3636...36 and 256'h5C5C...5C in the form of instructions to obtain the internal padding key ipadkey and the external padding key opadkey, and temporarily stores the calculation results in the microprocessor.

[0171] In an exemplary embodiment, the microprocessor concatenates message and ipadkey, stores them again, and performs SHA-256 data padding on the concatenated data, that is, adding a 1 at the end of the data bit, the last 64 bits of the data block are the total length of the original data, and then padding with 0 between the added 1 and the 64-bit total length, padding the data until the length of the data is an integer multiple of 512 bits. At this time, every 512 bits is called an operator and is stored in the microprocessor.

[0172] In an exemplary embodiment, the microprocessor first sends the first operator to the SHA-256 calculation unit for calculation in order. H0 corresponding to the first calculation is the initial hash constant, and the calculated H1 is returned to the microprocessor as the return result (response, abbreviated as rsp) for storage. During the second calculation, the microprocessor sends the return result rsp of the previous round as the hash initial value of this round and the second operator to SHA-256 for calculation, returns the calculation result, and continues to store it in the microprocessor. During the third calculation, the microprocessor sends the return result rsp of the previous round as the hash initial value and the third operator to the SHA-256 calculation unit for calculation, and iterates to complete the SHA-256 calculation of the original input data message and ipadkey, and stores the calculation result as a new message.

[0173] In an exemplary embodiment, the microprocessor also needs to concatenate the new message with the opadkey, and perform the above-mentioned SHA-256 iterative calculation process again to obtain the final output data (result) and output it.

[0174] In an exemplary embodiment, when multiple messages need to be processed, the microprocessor needs to allocate corresponding spaces to the multiple messages, and associate and identify each data and space through the thread number in the microprocessor. When processing data of multiple threads, each thread can issue a SHA-2 calculation request. At this time, the scheduling module sends these calculation requests and thread numbers to the corresponding SHA-2 calculation unit. When returning the calculation result (rsp), the thread numbers that were previously sent to the calculation unit are returned at the same time, and the thread number returned is identified by the scheduling module again, and stored in the rsp space corresponding to the thread number.

[0175] Through the embodiment of the present application, the HMAC-SHA2 algorithm calculation of multiple groups of data can be performed simultaneously, which improves the calculation speed. The present application can also select the number of cascaded SHA-2 calculation units according to specific calculation requirements, which has strong reconfigurability.

[0176] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program executes the steps of any of the above method embodiments when executed by a processor.

[0177] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0178] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0179] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0180] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0181] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0182] The above is only an exemplary embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data encryption processing method, It is characterized in that Applied to a microprocessor, the microprocessor is connected to n encryption computing units, where n is a positive integer, the method comprises: Get the data and key to be processed; Generate first target data according to the data to be processed and the key, wherein the first target data is composed of m operators, each operator corresponds to data of a first preset length, and m is an integer greater than 1; Sending the first operator of the m operators to a target encryption calculation unit for calculation, and saving the calculation result returned by the target encryption calculation unit as the first first result, wherein the target encryption calculation unit is any one of the n encryption calculation units; For each of the 2nd to mth operators among the m operators, the i-th operator and the i-1th first result are sent to the target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the i-th first result, where i=2,...,m, and the i-1th first result is the calculation result of the target encryption calculation unit calculating the i-1th operator.

2. The method according to claim 1, It is characterized in that The data to be processed is input data to be encrypted, and the key is a first key, which is an internal padding key of a second preset length generated according to an input initial key.

3. The method according to claim 1, It is characterized in that The data to be processed is an encryption result calculated using a secure hash algorithm on the input data to be encrypted and a first key, and the key is a second key, wherein the first key and the second key are respectively an internal padding key and an external padding key of a second preset length generated based on the input initial key.

4. The method according to claim 2, It is characterized in that The method further comprises: Generate second target data according to the mth first result and the second key, wherein the second target data is composed of l operators, each operator corresponds to data of a first preset length, and l is an integer greater than 1; Sending the first operator of the l operators to the target encryption calculation unit for calculation, and saving the calculation result returned by the target encryption calculation unit as the first second result; For each operator from the 2nd to the lth operators among the l operators, the jth operator and the j-1th second result are sent to the target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the jth second result, where j=2,...,l, and the j-1th second result is the calculation result of the target encryption calculation unit calculating the j-1th operator.

5. The method according to claim 1, It is characterized in that Generating first target data according to the data to be processed and the key includes: Splicing the data to be processed and the key to obtain first spliced ​​data; Data padding is performed on the first spliced ​​data to obtain the first target data.

6. The method according to claim 2, It is characterized in that The method further comprises: When the length of the initial key is greater than the second preset length, the initial key is sent to one of the n encryption calculation units for calculation to obtain an intermediate key of the second preset length; An XOR operation is performed on the intermediate key and a preset internal filling sequence to obtain the first key.

7. The method according to claim 3, It is characterized in that The method further comprises: When the length of the initial key is greater than the second preset length, the initial key is sent to one of the n encryption calculation units for calculation to obtain an intermediate key of the second preset length; Performing an XOR operation on the intermediate key and a preset internal padding sequence to obtain the first key; An XOR operation is performed on the intermediate key and a preset external padding sequence to obtain the second key.

8. The method according to claim 1, It is characterized in that The method further comprises: The encryption calculation unit is a secure hash algorithm SHA-2 calculation unit; When the SHA-2 calculation unit calculates the first operator among the m operators, a preset initial hash constant is used as an initial hash value of the secure hash algorithm; When the SHA-2 calculation unit calculates the i-th operator among the m operators, the i-1-th first result is used as an initial hash value of the secure hash algorithm.

9. The method according to claim 5, It is characterized in that Filling the first spliced ​​data with data to obtain the first target data includes: Converting the total length of the first spliced ​​data into first length information of a third preset length; A bit tail identifier, a plurality of preset fillers and the first length information are sequentially added after the first spliced ​​data for data filling to obtain the first target data, wherein the length of the first target data is m times the first preset length.

10. A data encryption processing device, It is characterized in that The device comprises: A microprocessor and n encryption computing units, wherein n is a positive integer; The microprocessor is used to obtain the data to be processed and the key, and generate the first target data according to the data to be processed and the key, wherein the first target data is composed of m operators, each operator corresponds to data of a first preset length, and m is an integer greater than 1; the first operator of the m operators is sent to a target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the first first result, wherein the target encryption calculation unit is any one of the n encryption calculation units; for each operator from the second to the mth operators of the m operators, the i-th operator and the i-1th first result are sent to the target encryption calculation unit for calculation, and the calculation result returned by the target encryption calculation unit is saved as the i-th first result, wherein i=2,...,m, and the i-1th first result is the calculation result of the target encryption calculation unit calculating the i-1th operator; The encryption calculation unit is used to receive each operator from the 1st to the mth operators and the 1st to the m-1th first results sent by the microprocessor, perform encryption calculation on each operator respectively, and send the calculation result to the microprocessor.

11. The device according to claim 10, It is characterized in that The device also includes: The scheduling module is used to schedule multiple encryption calculation units for parallel processing when the microprocessor simultaneously obtains multiple data to be processed, wherein each data to be processed corresponds to an encryption calculation unit.

12. The device according to claim 10, It is characterized in that The microprocessor comprises: An instruction unit, used to issue control instructions to the computing unit and the data storage unit, wherein the control instructions include computing instructions and read-write instructions; a computing unit, configured to generate the first target data according to the data to be processed and the key under the control of the computing instruction; A data storage unit is used to read and write the data to be processed, the key, the first target data and the calculation results returned by the target encryption calculation unit under the control of the read and write instructions, wherein the calculation results include the 1st to mth first results.

13. A computer-readable storage medium, It is characterized in that The storage medium stores a computer program, wherein the computer program executes the method described in any one of claims 1 to 9 when executed by a processor.

14. An electronic device comprising a memory and a processor, It is characterized in that A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Cache management method and device, control program and controller

    CN115756296A

  • Data encryption method and data encryption device

    CN115795515A

  • Encryption method and apparatus, terminal device, and storage medium

    WO2019237550A1