Data encryption processing method and apparatus

By splitting data of any length into fixed-length operators and using hardware encryption calculation units for iterative calculations, the problem that the hardware implementation of the fixed input data length of the encryption algorithm in the prior art is solved, and the arbitrary length is realized Efficient encryption and resource conservation of data.

WO2024244496A1PCT designated stage expired Publication Date: 2024-12-05SANECHIPS TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/073120
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-29
Filing Date
2024-01-18
Publication Date
2024-12-05

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 usage, increased cost and power consumption when processing long data, and it is difficult to adapt to the computing needs of different data lengths.

Method used

The input data of any length is split into multiple operators of fixed length through a microprocessor, and iteratively calculates using the hardware encryption calculation unit to realize the encryption processing of data of any length, and improve the reusability and efficiency of the encryption calculation unit. .

Benefits of technology

It realizes efficient encryption processing of data of any length, saves hardware resources, improves the reusability and operation speed of the encryption computing unit, and adapts to the computing needs of different data lengths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024073120_05122024_PF_FP_ABST
    Figure CN2024073120_05122024_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present disclosure are a data encryption processing method and apparatus. The method is applied to a microprocessor, which is connected to n encryption calculation units, n being a positive integer. The method comprises: acquiring data to be processed and a key; according to the data to be processed and the key, generating first target data consisting of m operators; sending a first operator among the m operators to a target encryption calculation unit for calculation, and storing as a first first result a calculation result returned by the target encryption calculation unit; and sending an ith operator and an (i-1)th first result to the target encryption calculation unit for calculation, and storing as an ith first result a calculation result returned by the target encryption calculation unit, wherein i=2, ..., m.
Need to check novelty before this filing date? Find Prior Art

Description

Data encryption processing method and device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This disclosure is based on Chinese patent application CN202310619704.6, filed on May 29, 2023, entitled “A Data Encryption Processing Method and Device,” and claims the priority of the patent application. All of the disclosed contents are incorporated into this disclosure by reference. Technical Field

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

[0004] SHA-2 (Secure Hash Algorithm 2) is a one-way hash algorithm published in 2002 by the National Institute of Standards and Technology (NIST) and the National Security Agency (NSA). It can convert messages of arbitrary length into fixed-length digests. SHA-224, SHA-256, SHA-384, and SHA-512 are categorized by the length of the output message digest. SHA-256 is used in digital signatures, HMAC (Hash-based Message Authentication Code) authentication, password protection, data integrity verification, and network security protocols. SHA-256 can convert any finite-length input message (less than 2^64 bits) into a 256-bit message digest. The processing steps are divided into three parts: data preprocessing, data expansion, and data compression. HMAC, an algorithm based on SHA and a secret key, 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 separately according to the key and message. HMAC-SHA-256 is based on the algorithm calculation of SHA-256 in the SHA algorithm.

[0005] SHA-2 can be implemented using software on general-purpose devices or hardware on specialized equipment. Software implementations offer advantages such as low resource consumption, ease of use, and portability. However, with the advancement of communications technology, the amount of data that encryption algorithms must process has exploded. In many applications, simple SHA-2 software implementations are no longer able to meet the speed requirements of the system. To improve system efficiency, many systems are beginning to utilize dedicated SHA-2 hardware.

[0006] Currently, the hardware implementation of the SHA algorithm mainly uses a pipeline structure and is designed for 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. Related technologies perform specific optimizations on the hardware implementation method based on each type of input data, but the optimization scheme will introduce a complex control unit and may be incompatible with other optimization schemes or have high process requirements. More importantly, these schemes can only perform algorithmic calculations on fixed-length input data and are not reusable. Moreover, as the data length increases, the difficulty of optimization increases.

[0007] 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.

[0008] Summary of the Invention

[0009] The embodiments of the present disclosure provide a data encryption processing method and apparatus to at least solve the problem in the related art that hardware implementations of encryption algorithms with fixed input data lengths cannot be reused and reconstructed.

[0010] According to one embodiment of the present disclosure, a data encryption processing method is provided, which is applied to a microprocessor, and the microprocessor is connected to n encryption calculation units, where n is a positive integer. The method includes: obtaining data to be processed and a key; generating first target data based on 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 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 calculation unit for calculation, and saving the calculation result returned by the target encryption calculation 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 calculation unit calculating the i-1th operator.

[0011] According to another embodiment of the present disclosure, a data encryption processing device is provided, which includes: a microprocessor and n encryption calculation units, where 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 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 the first operator of the n encryption calculation units. any one of; for each operator from the 2nd to the 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; an 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.

[0012] According to another embodiment of the present disclosure, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are executed.

[0013] According to another embodiment of the present disclosure, 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] FIG1 is a block diagram of the hardware structure of the data encryption processing method according to an embodiment of the present disclosure;

[0015] FIG2 is a hardware structure block diagram of a SHA-2 calculation unit according to an embodiment of the present disclosure;

[0016] FIG3 is a schematic diagram of a processing flow of a SHA-256 calculation unit according to an embodiment of the present disclosure;

[0017] FIG4 is a flow chart of a data encryption processing method according to an embodiment of the present disclosure;

[0018] 5 is a flow chart of data encryption processing according to the HMAC-SHA-2 algorithm according to an embodiment of the present disclosure;

[0019] FIG6 is a flow chart of a data encryption processing method based on SHA-256 according to an embodiment of the present disclosure;

[0020] FIG7 is a structural block diagram (I) of a data encryption processing device according to an embodiment of the present disclosure;

[0021] FIG8 is a structural block diagram (II) of a data encryption processing device according to an embodiment of the present disclosure;

[0022] FIG9 is a structural block diagram of a microprocessor for data encryption processing according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.

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

[0025] The method embodiments provided in the embodiments of the present disclosure can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, FIG1 is a hardware structure block diagram of the data encryption processing method of the embodiment of the present disclosure. As shown in FIG1 , the hardware board may include one or more (only one is shown in FIG1 ) processors 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 above-mentioned mobile terminal may also include a transmission device 16 and an input and output device 18 for communication functions. It can be understood by those skilled in the art that the structure shown in FIG1 is only for illustration and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may also include more or fewer components than those shown in FIG1 , or have a configuration different from that shown in FIG1 .

[0026] 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 disclosure. The processor 12 executes various functional applications and data encryption processing methods by running the computer programs stored in the memory 14, that is, implements the above-mentioned 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 located 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.

[0027] The transmission device 16 is used to receive or send data via a network. Specific examples of the aforementioned network may include a wireless network provided by a communications provider. In one embodiment, the transmission device 16 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 16 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0028] According to an embodiment of the present disclosure, 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 units are implemented through a hardware structure.

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

[0030] FIG2 is a block diagram of the hardware structure of a SHA-2 calculation unit according to an embodiment of the present disclosure. As shown in FIG2 , taking the SHA-256 calculation unit as an example, the SHA-256 calculation unit may include the following structures:

[0031] Counting unit 21 , data expansion unit 22 , data compression unit 23 , constant selection unit 24 , data pre-processing unit 25 , and data output unit 26 .

[0032] In this embodiment, the counting unit 21 is used to count the current number of calculation rounds so that other units can select calculation data based on the current number of calculation rounds. Furthermore, 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.

[0033] 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.

[0034] 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.

[0035] 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.

[0036] In one embodiment of the present disclosure, the data preprocessing unit 25 is configured to select a hash value for the iterative calculation. For the initial iterative calculation, a hash constant is selected; otherwise, the result of the previous round of calculation is selected as the hash value. Furthermore, the present embodiment uses the hash constant only when calculating the first operator; the result of the previous SHA-256 operator is used for calculations of subsequent operators.

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

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

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

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

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

[0042] ch=(e_reg&f_reg)^(^e_reg&f_reg)

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

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

[0045] t2=sum0+maj

[0046] a_reg=t1+t2

[0047] b_reg=a_reg

[0048] c_reg=b_reg

[0049] d_reg=c_reg

[0050] e_reg=d_reg+t1

[0051] f_reg=e_reg

[0052] g_reg=f_reg

[0053] h_reg=g_reg

[0054] 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.

[0055] In this embodiment, the data output unit 26 is only valid after the data compression unit 23 calculates 64 rounds. It is used to perform the final calculation on the calculation results 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.

[0056] The SHA-2 calculation unit in the disclosed embodiment is implemented in hardware and can only process fixed-length input data. However, the disclosed embodiment can use a microprocessor to split input data of any finite length (less than 2^64 bits) into multiple operators of fixed lengths, and then use the SHA-2 calculation unit to iteratively calculate the multiple operators, thereby completing the SHA-2 calculation of input data of any length in hardware.

[0057] The embodiments of the present disclosure do not limit the hardware structure of the SHA-2 calculation unit, and the SHA-2 calculation unit may also adopt other hardware implementation methods.

[0058] Figure 3 is a schematic diagram of the processing flow of a SHA-256 calculation unit according to an embodiment of the present disclosure. As shown in Figure 3, taking the SHA-256 calculation unit as an example, the process includes: expanding the input data (data_in) into w0 to w63; selecting one 32-bit data from w0 to w63 and one constant from k0 to k63 in turn according to the calculation round, and performing 64 rounds of iterative calculation 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.

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

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

[0061] FIG4 is a flow chart of a data encryption processing method according to an embodiment of the present disclosure. As shown in FIG4 , the flow includes the following steps:

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

[0063] 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;

[0064] Step S406: Send the first operator of the m operators to a target encryption calculation unit for calculation, and save 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;

[0065] Step S408: 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.

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

[0067] In the embodiment of the present disclosure, 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 performing data interaction between the microprocessor and the encryption calculation unit, the reusability of the encryption calculation unit is improved, hardware resources are saved, and the hardware algorithm calculation has the advantage of faster running speed.

[0068] 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 the input initial key.

[0069] In another exemplary embodiment, the data to be processed can be the encryption result calculated using a secure hash algorithm on the input data to be encrypted and the first key, the key is the second key, and 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.

[0070] 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.

[0071] The data encryption processing method adopted in the embodiments of the present disclosure 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 requires first performing a SHA-2 calculation on the input data and an internal padding key, and then performing a SHA-2 calculation on the calculation result and an external padding key. This corresponds to the method in the above-mentioned embodiment of first performing an encryption operation on the first key and the data to be encrypted (the first target data), and then performing an encryption operation on the encryption result and the external padding key (the second target data).

[0072] 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. This eliminates the need for additional design of the SHA-2 calculation unit, thereby improving the reusability of the SHA-2 calculation unit. The disclosed embodiment also overcomes the shortcoming of the SHA-2 calculation unit, which can only perform algorithm calculations on input data of a fixed length. Even when processing very long input data, it can save a lot of hardware resources.

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

[0074] Step S4042: concatenate the data to be processed and the key to obtain first concatenated data;

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

[0076] In an exemplary embodiment, the first key may be obtained by:

[0077] 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;

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

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

[0080] If 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;

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

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

[0083] In one exemplary embodiment, the inner pad sequence (ipad) is a fixed-length byte sequence and is padded using 0x36 (hexadecimal), i.e., 0x36 is repeated multiple times to a first predetermined length. The outer pad sequence (opad) is similar to the inner pad sequence and is padded using 0x5C (hexadecimal), i.e., 0x5C is repeated multiple times to a first predetermined length.

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

[0085] 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.

[0086] 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.

[0087] 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 (with a length 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.

[0088] In an exemplary embodiment, the specific steps of generating the second target data based on 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.

[0089] FIG5 is a flow chart of data encryption processing according to the HMAC-SHA-2 algorithm according to an embodiment of the present disclosure, which is applied to a microprocessor. As shown in FIG5 , the process may specifically include the following steps:

[0090] Step S502: Obtain input data and an initial key, and process the initial key into an inner padding key and an outer padding key of a second preset length;

[0091] Step S504: concatenate the input data and the internal padding key to obtain first concatenated data, and perform 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;

[0092] Step S506: Send the first target data to a secure hash algorithm SHA-2 calculation unit, and receive an encryption result obtained by the SHA-2 calculation unit by iteratively performing SHA-2 calculation on the first target data;

[0093] Step S508: concatenate the encryption result and the external padding key to obtain second concatenated data, and perform data padding on the second concatenated data to obtain second target data containing multiple operators;

[0094] 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.

[0095] In the embodiment of the present disclosure, 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 art cannot be reused and reconstructed can be solved. By performing data interaction between the microprocessor and the SHA-2 calculation unit, 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.

[0096] In this embodiment, the encryption result in step S506 is equivalent to the mth first result in the above embodiment, processed through 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, processed through l iterations. m and l are the number of fixed-length operators.

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

[0098] 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 disclosure can make up for the disadvantage 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.

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

[0100] 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.

[0101] In another exemplary embodiment, in a hardware implementation of a SHA-256 calculation unit, the first preset length is 512 bits, meaning the microprocessor can only perform encryption operations on input data of 512 bits in length at a time. By preprocessing the input data, the microprocessor can further split data of any length into fixed-length operators before feeding the operators into the SHA-256 calculation unit.

[0102] 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:

[0103] Step S5022: Process the initial key into an intermediate key of the second preset length;

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

[0105] Step S5026: Perform an XOR operation on the intermediate key and a preset external padding sequence to obtain the external padding key.

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

[0107] In one exemplary embodiment, the inner pad sequence (ipad) is a fixed-length byte sequence and is padded using 0x36 (hexadecimal), i.e., 0x36 is repeated multiple times to a second predetermined length. The outer pad sequence (opad) is similar to the inner pad sequence and is padded using 0x5C (hexadecimal), i.e., 0x5C is repeated multiple times to a second predetermined length.

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

[0109] 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;

[0110] If 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;

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

[0112] 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.

[0113] 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:

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

[0115] 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.

[0116] 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), multiple 0s (preset fillers), and 64 bits of first length information.

[0117] 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.

[0118] 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 in sequence to the SHA-2 calculation unit for iterative calculation, thereby solving the problem in the related art that the SHA-2 calculation unit can only process fixed-length data.

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

[0120] Step S5062: split the first target data into multiple operators;

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

[0122] Step S5066: Use the calculation result of the previous round of SHA-2 calculation as the hash constant for the new round of SHA-2 calculation, and send 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 receive the encryption result obtained by the SHA-2 calculation unit performing SHA-2 calculation on the last operator in the first target data.

[0123] 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.

[0124] 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, and 0x5be0cd19.

[0125] Furthermore, the 256-bit result from the previous SHA-256 calculation can be split into eight 32-bit data and used as the hash constant for the next SHA-256 calculation, thus enabling iterative processing of multiple operators. N operators require N rounds of SHA-256 calculations.

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

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

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

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

[0130] Step S5102: split the second target data into multiple operators;

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

[0132] Step S5106: Use the calculation result of the previous round of SHA-2 calculation as the hash constant of the new round of SHA-2 calculation, and send 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 receive the output data obtained by the SHA-2 calculation unit performing SHA-2 calculation on the last operator in the second target data.

[0133] 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.

[0134] In the disclosed embodiment, the microprocessor interacts with the SHA-2 calculation unit to improve the reusability of the SHA-2 calculation unit. Only one SHA-2 calculation unit is required to implement the entire HMAC-SHA2 algorithm data encryption processing flow, thereby ensuring the hardware implementation of the HMAC-SHA2 algorithm and reducing resource consumption.

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

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

[0137] Specifically, you can add a 1 to the end of the input message. The last 64 bits of the data block are the total length of the original data (length). Multiple 0s are used to pad the space between the added 1 and the 64-bit total length, until the data block length is an integer multiple of 512 bits. Alternatively, you can first add a 1 to the end of the input message, followed by several 0s, until the message length reaches the remainder 448 when divided by 512. Then, you can add the 64-bit total length of the original data (length) to the end, thus padding the data block to an integer multiple of 512 bits.

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

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

[0140] Specifically, when performing a 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 a SHA-256 calculation on the second operator M2, the second operator M2 and the previous 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 calculation result Hn-1 are input into the SHA-256 calculation unit to obtain the final result Hn.

[0141] In this embodiment, the data padding process and data interaction with the SHA-256 calculation unit are both implemented by a microprocessor. The disclosed embodiments can implement SHA-256 calculations on data of any length, but the disclosure is not limited to the SHA-256 algorithm and can also be applied to algorithms such as SHA-224, SHA-384, and SHA-512.

[0142] According to another aspect of the embodiments of the present disclosure, a data encryption processing device is also provided.

[0143] FIG7 is a structural block diagram (I) of a data encryption processing device according to an embodiment of the present disclosure. As shown in FIG7 , the device includes:

[0144] A microprocessor 72 and n encryption calculation units 74. n is a positive integer.

[0145] In an exemplary embodiment, the microprocessor 72 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 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;

[0146] 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.

[0147] 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.

[0148] Furthermore, the SHA-2 algorithm is further divided into four algorithms, SHA-224, SHA-256, SHA-384, and SHA-512, based on the length of the output message digest. 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 output data length is 256 bits, that is, the second preset length is 256 bits.

[0149] 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; and 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.

[0150] In one exemplary embodiment, the inner pad sequence (ipad) is a fixed-length byte sequence and is padded using 0x36 (hexadecimal), i.e., 0x36 is repeated multiple times to a second predetermined length. The outer pad sequence (opad) is similar to the inner pad sequence and is padded using 0x5C (hexadecimal), i.e., 0x5C is repeated multiple times to a second predetermined length.

[0151] In an exemplary embodiment, the microprocessor 72 is further 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 the encryption calculation of the initial key; and directly use the initial key as the intermediate key when the length of the initial key is equal to the second preset length.

[0152] 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.

[0153] In an exemplary embodiment, the microprocessor 72 is further used to convert the total length of the first spliced ​​data into first length information of a third preset length; and to 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 first preset length.

[0154] In an exemplary embodiment, the microprocessor 72 is further 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 encryption calculation of 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 encryption calculation of the last operator in the first target data.

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

[0156] In an exemplary embodiment, the microprocessor 72 is further 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 by performing encryption calculation on 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 by performing encryption calculation on the last operator in the second target data.

[0157] In the embodiments of the present disclosure, the reusability of the encryption calculation unit can be improved by interacting with the microprocessor. Taking the HMAC-SHA2 algorithm as an example, only one SHA-2 calculation 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.

[0158] FIG8 is a structural block diagram (II) of a data encryption processing device according to an embodiment of the present disclosure. As shown in FIG8 , the device includes:

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

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

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

[0162] Furthermore, if the microprocessor needs to perform HMAC-SHA2 calculations on multiple messages simultaneously and has a high calculation speed requirement, the calculation speed can be increased 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 are iteratively calculated in the same SHA-2 calculation unit.

[0163] FIG9 is a block diagram of a microprocessor for data encryption processing according to an embodiment of the present disclosure. As shown in FIG9 , the microprocessor may include:

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

[0165] In an exemplary embodiment, the instruction unit 92 is used to issue control instructions, such as storage instructions and calculation instructions, to the computing unit 94 and the data storage unit 96. The instruction unit 92 can complete the separation 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 process.

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

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

[0168] 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.

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

[0170] Furthermore, the key is used to store the initial key, internal filling key, external filling key and 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.

[0171] In one exemplary embodiment, using the SHA-256 algorithm as an example, the input message is temporarily stored in the microprocessor, while the key can be directly input or sent as a command. The microprocessor determines whether to perform a SHA-256 calculation based on the length of the key. If not, the key is padded with zeros to 256 bits to generate a new key. If so, the key is sent to the interactive SHA-256 calculation unit. Upon receiving the calculation result, the original key is replaced with the new key.

[0172] In an exemplary embodiment, the microprocessor performs XOR 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.

[0173] In an exemplary embodiment, the microprocessor concatenates the message and iPadKey, stores them again, and performs SHA-256 padding on the concatenated data. This involves adding a 1 to the end of the data, with the last 64 bits of the data block being the total length of the original data. The data is then padded with 0s between the added 1 and the total length of 64 bits, until the data length is an integer multiple of 512 bits. Each 512 bits is called an operator and is stored in the microprocessor.

[0174] In an exemplary embodiment, the microprocessor first sends the first operator to the SHA-256 calculation unit for calculation in sequence. The 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, thereby iterating to complete the SHA-256 calculation of the original input data message and ipadkey, and stores the calculation result as a new message.

[0175] 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.

[0176] In an exemplary embodiment, when multiple messages need to be processed, the microprocessor needs to allocate corresponding space for the multiple messages and associate and identify each data and space using the thread number in the microprocessor. When processing data from 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 previously sent to the calculation unit are also returned. The returned thread number is identified by the scheduling module again and stored in the rsp space corresponding to the thread number.

[0177] Through the embodiments of the present disclosure, HMAC-SHA2 algorithm calculations can be performed simultaneously on multiple sets of data, improving the calculation speed. The present disclosure can also select the number of cascaded SHA-2 calculation units according to specific calculation requirements, which has strong reconfigurability.

[0178] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above method embodiments are executed.

[0179] 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.

[0180] An embodiment of the present disclosure further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0181] 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.

[0182] 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 here.

[0183] Obviously, those skilled in the art should understand that the modules or steps of the present disclosure described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and thus, 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 performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present disclosure is not limited to any particular combination of hardware and software.

[0184] The foregoing is merely an exemplary embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that the present disclosure is susceptible to various modifications and variations. Any modifications, equivalent substitutions, improvements, and the like made within the principles of the present disclosure shall be included within the scope of protection of the present disclosure.

Claims

1. A data encryption processing method, applied to a microprocessor, wherein the microprocessor is connected to n encryption calculation units, where n is a positive integer, and the method include: 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 operator from the 2nd to the 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, in, 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, in, 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, in, 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, in, 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, in, 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, in, 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, in, 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, in, 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, the device include: 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, in, 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, in, 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, wherein a computer program is stored in the storage medium. in, When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is executed.

14. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, 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

  • Data transmission method, device and equipment and readable storage medium

    CN110061996A

  • Data encryption method and device, computer equipment and storage medium

    CN115001663A

  • Private data calculation method and device based on homomorphic encryption

    CN115580393A

  • Internet of vehicles information encryption method and device, computer equipment and storage medium

    CN115766244A

  • Data encryption method and device, electronic equipment and storage medium

    CN116132159A