Data processing method and device, equipment and medium
By splitting parallel hashing and multiple hashing of the data to be processed, the speed and security problems of the SM3 algorithm in large-scale data processing are solved, achieving more efficient data processing and stronger security.
Patent Information
- Application Number
- CN202410726587.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-06
AI Technical Summary
The existing SM3 algorithm has limited speed when processing large-scale data, and there is a risk of hash collision, resulting in poor data security.
By splitting the data to be processed to form N groups of data, the first hash processing is performed in parallel, and then the temporary hash data is processed to generate the target hash data, and preset calculation rules such as summation or XOR are used to reduce the hash. Collision risk, and enhanced data irreversibility through multiple hashing processes.
It improves the data processing speed, reduces the risk of hash collision, and enhances the uniqueness and irreversibility of data, thus improving data security.
Smart Images

Figure CN118690384A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device, equipment and medium. Background Art
[0002] In the field of data security, HASH algorithms are widely used in data encryption, data integrity verification, and data indexing in data storage devices, such as solid-state drives. The performance of the HASH algorithm directly affects the processing speed and data security of the entire solid-state drive system. Among them, the SM3 (senior middle 3) algorithm is a commonly used HASH value calculation algorithm.
[0003] At present, in order to improve the HASH processing performance of the SM3 algorithm, some solutions have been proposed. For example, by optimizing the algorithm to achieve parallel computing of the SM3 algorithm, multi-threading is used for computing to increase the processing speed. In addition, there are some solutions that use distributed computing to decompose computing tasks onto multiple processors for parallel computing to further improve computing performance.
[0004] However, the multi-threaded processing in the SM3 algorithm hardware module in the existing solution only processes the parts of the input data with similar calculation steps in parallel, and processes the other parts in serial, so the speed improvement is limited and cannot meet the efficient processing requirements of large-scale data; in addition, for input data with longer data lengths, the processing time is longer; in addition, the hash data obtained after different data are processed by the HASH algorithm may collide, that is, different data have the same hash data, and the data obtained by a single HASH algorithm can be easily restored to the data before processing, resulting in poor security.
[0005] In summary, how to improve the data processing speed and data security of solid-state drives is an issue that needs to be urgently addressed. Summary of the invention
[0006] In view of this, the object of the present invention is to provide a data processing method, device, equipment and medium, which can adapt to input data of different lengths and improve the speed of data processing and data security. The specific scheme is as follows:
[0007] In a first aspect, the present application discloses a data processing method, comprising:
[0008] Get the data to be processed;
[0009] Splitting the data to be processed into N groups of split data, where N is an integer not less than 2;
[0010] Performing a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data;
[0011] The N groups of first temporary hash data are processed to obtain target hash data.
[0012] Optionally, splitting the data to be processed to obtain N groups of split data includes:
[0013] Determine a first ratio of the data length of the data to be processed to the target length, and round up the first ratio to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is an integer not less than 1;
[0014] The data to be processed is split into N groups of split data, where N is the first number.
[0015] Optionally, among the N groups of split data, there is at most one group of data whose data length is not an integer multiple of the target length.
[0016] Optionally, the processing the N groups of first temporary hash data to obtain target hash data includes:
[0017] The N groups of first temporary hash data are processed based on a preset calculation rule to obtain second temporary hash data, and the target hash data is obtained according to the second temporary hash data; wherein the preset calculation rule is sum or XOR.
[0018] Optionally, the data processing method further includes:
[0019] After obtaining the second temporary hash data, a second hash process is performed on the second temporary hash data to obtain third temporary hash data, and the target hash data is obtained according to the third temporary hash data.
[0020] Optionally, the SM3 algorithm adopted by the second hash processing is different from the SM3 algorithm adopted by the first hash processing.
[0021] In a second aspect, the present application discloses a data processing device, comprising:
[0022] An acquisition module is used to acquire data to be processed;
[0023] A splitting module, used for splitting the data to be processed to obtain N groups of split data, where N is an integer not less than 2;
[0024] A first processing module, configured to perform a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data;
[0025] The second processing module is used to process the N groups of first temporary hash data to obtain target hash data.
[0026] Optionally, the data processing device, wherein:
[0027] The splitting module is specifically used to determine a first ratio of the data length of the data to be processed to the target length, and round up the first ratio to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is an integer not less than 1; the data to be processed is split to obtain the N groups of split data; and N is the first quantity.
[0028] In a third aspect, the present application discloses an electronic device, comprising:
[0029] Memory, used to store computer programs;
[0030] The processor is used to execute the computer program to implement the data processing method disclosed above.
[0031] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed data processing method is implemented.
[0032] It can be seen that the present application obtains the data to be processed; splits the data to be processed to obtain N groups of split data, wherein N is an integer not less than 2; performs a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; and processes the N groups of first temporary hash data to obtain the target hash data. It can be seen that the present application splits the input data to be processed, and then performs hash processes on the N groups of split data in parallel to obtain N groups of first temporary hash data. Compared with directly performing hash processing on the data to be processed, multiple data groups can be processed in parallel at the same time to adapt to input data of different lengths, and the time spent is reduced, which effectively improves the processing speed; the method of the present application of further processing the obtained N groups of first temporary hash data to obtain the target hash data can reduce the risk of hash collision and improve the uniqueness of the hash result compared with direct hash processing, and because the level of steps increases, the difficulty of inferring the data to be processed from the target hash data increases, and the irreversibility of the target hash data is improved, so the data security is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0034] Figure 1 A flow chart of a data processing method disclosed in this application;
[0035] Figure 2 A flow chart of a specific data processing method disclosed in this application;
[0036] Figure 3 A flow chart of a specific data processing method disclosed in this application;
[0037] Figure 4 A flow chart of a specific data processing method disclosed in this application;
[0038] Figure 5 A schematic diagram of the structure of a data processing device disclosed in this application;
[0039] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The multi-threaded processing in the SM3 algorithm hardware module in the existing solution only processes the parts of the input data with similar calculation steps in parallel, and the speed of improvement is limited, which cannot meet the efficient processing requirements of large-scale data. Moreover, the improper splitting of input data during parallel processing will increase the hardware overhead of the SM3 algorithm hardware module; in addition, the processing time is long for input data with a large amount of data; in addition, the single HASH algorithm is easy to be restored to the data to be processed and there is a risk of hash collision, and the security is poor.
[0042] To this end, an embodiment of the present application proposes a data processing solution that can improve the speed of data processing and data security.
[0043] The present application discloses a data processing method. Figure 1 As shown, the method includes:
[0044] Step S11: Obtain data to be processed.
[0045] In this embodiment, the data to be processed is data in the computer field, especially data in the fields of data security, cryptography, cloud computing and blockchain.
[0046] Step S12: Split the data to be processed into N groups of split data, where N is an integer not less than 2.
[0047] It should be pointed out that the larger the value of N, the shorter the time required for subsequent parallel hash calculations, but the more SM3 algorithm hardware modules will need to participate in the hash calculations, which will lead to an increase in the hardware area required for subsequent application systems to integrate the algorithm IP (Internet Protocol). Therefore, based on the subsequent application system's requirements for algorithm processing performance and the hardware area required for the integrated algorithm IP core, the choice of the number of split groups N can be optimized to achieve a balance between improving the algorithm processing speed and the subsequent hardware area.
[0048] Step S13: performing a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0049] In this embodiment, after the data to be processed is split, hash processing is performed in parallel on N groups of split data to obtain N groups of first temporary hash data. Compared with directly hashing the data to be processed, there is no need to wait for all the data to be given before calculation. Multiple data groups can be processed in parallel at the same time, which can adapt to input data of different lengths, reduce time and effectively improve processing speed.
[0050] Step S14: Process the N groups of first temporary hash data to obtain target hash data.
[0051] In this embodiment, the data to be processed is split to obtain N groups of split data, where N is an integer not less than 2; the N groups of split data are subjected to a first hash process in parallel to obtain the N groups of first temporary hash data; the N groups of first temporary hash data are processed to obtain target hash data. It can be seen that the present application performs a hash process in parallel on the N groups of split data to obtain N groups of first temporary hash data. Compared with directly performing a hash process on the data to be processed, multiple data groups can be processed in parallel at the same time to adapt to input data of different lengths, and the time spent is reduced, which effectively improves the processing speed. When the amount of data to be processed is large, the splitting method of the present application can take into account the subsequent hardware area overhead while improving the processing speed of the SM3 algorithm, and effectively reduce the hardware area of the algorithm IP core subsequently integrated in the application system. The method of the present application for processing the obtained N groups of first temporary hash data to obtain the target hash data can reduce the risk of hash collision and improve the uniqueness of the hash result compared with direct hash processing. Moreover, due to the increase in the level of steps, the difficulty of inferring the data to be processed from the target hash data increases, and the irreversibility of the target hash data is improved, so the data security is improved.
[0052] The embodiment of the present application discloses a specific data processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Figure 2 As shown, specifically including:
[0053] Step S21: Obtain data to be processed.
[0054] For a more specific processing procedure of step S21, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0055] Step S22: Determine a first ratio of the data length of the data to be processed to the target length, and round up the first ratio to obtain a first number; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is an integer not less than 1.
[0056] Step S23: Split the data to be processed to obtain the N groups of split data; N is the first number; among the N groups of split data, at most one group of data has a data length that is not an integer multiple of the target length; N is an integer not less than 2.
[0057] In this embodiment, the data to be processed is split to obtain N groups of split data, including: determining a first ratio of the data length of the data to be processed to the target length, and rounding up the first ratio to obtain a first number; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is a value not less than 1; the data to be processed is split to obtain the N groups of split data; N is the first number. It should be noted that N is not less than 2 and not greater than the first number when the target length is the smallest; wherein rounding up can be understood as when the first ratio is an integer, the first number is equal to the first ratio; when the first ratio is a decimal and the decimal part is not 0, the first number is an integer obtained by adding 1 to the integer part of the first ratio.
[0058] It should be pointed out that the first step of the hash operation of the SM3 algorithm is padding, which requires the data length to be padded to a multiple of 512 bits, where 512 bits is the minimum target length that needs to be padded when performing a hash operation.
[0059] It should be noted that M is an integer not less than 1, which specifies the minimum value of M, and N is an integer not less than 2, which specifies the maximum value of M. Specifically: when the data length of the data to be processed is 5.2 times 512 bits, the target length is M times 512 bits, M is an integer not less than 1, and the above provision states that N is an integer not less than 2, the first ratio P is a value in 1 (M is 5.2) < P ≤ 5.2 (M is 1), and the value range obtained by rounding up the value is 2 ≤ K ≤ 6, that is, N belongs to 2 ≤ K ≤ 6. It should be noted that if M is greater than 5.2, the value of 1 in 1 < P ≤ 5.2 is not 1 but less than 1, which will cause the value of 2 in the range of 2 ≤ K ≤ 6 where N is located to be not 2 but less than 2, which does not meet the requirements. Therefore, M is an integer not less than 1, which specifies the minimum value of M, and the value of M is not greater than the first ratio when the target length is 512 bits. The feature that N is an integer not less than 2 also specifies the maximum value of M.
[0060] It should be pointed out that the data length of the data to be processed is 5.2 times 512 bits, the target length is M times 512 bits, M is a value not less than 1, and N is not greater than the first number when the target length is the minimum. Therefore, N is not greater than 6. Specifically, when the target length is the minimum target length of 512 bits, the data length of the data to be processed is 5.2 times the minimum target length, the first ratio is 5.2 times, and the first number is the first ratio rounded up, that is, 6; therefore, N is an integer not less than 2 and not greater than 6.
[0061] It should be pointed out that in the specific data splitting process, the choice of target length during splitting can be optimized based on the subsequent application system's requirements for algorithm processing performance and the hardware area required for the integrated algorithm IP core, thereby optimizing the choice of the number of splitting groups N, while taking into account the subsequent hardware area on the basis of improving the algorithm processing speed.
[0062] In this embodiment, there is at most one group of data in the N groups of split data whose data length is not an integer multiple of the target length. It should be pointed out that when the SM3 algorithm is used for hash processing, only data whose data length is an integer multiple of the target length can be processed. If the input split data is not an integer multiple of the target length, the data needs to be padded to obtain an integer multiple of the target length, which will waste space and further waste time, which is not conducive to improving the processing speed. Therefore, it is necessary to split the split data into integer multiples of the target length as much as possible.
[0063] Step S24: performing a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0064] Through the above steps, the data to be processed is split to obtain N groups of split data. On this basis, the first hash processing is performed on the N groups of split data in parallel to improve the hash processing speed.
[0065] Step S25: Process the N groups of first temporary hash data to obtain target hash data.
[0066] In a specific embodiment, when the size of the data to be processed is moderate and the application system needs to greatly improve the processing speed, the data to be processed can be split into N groups, where N is the ratio of the data length of the data to be processed to the minimum target length, rounded up to obtain a first number, and at most one group of data in the N groups has a data length that is not an integer multiple of the target length, and the data length of each group is up to 512 bits. At this time, the time required for the first hash processing is a time period (the time for hash processing 512-bit data is set to a time period to facilitate the representation of the hash processing time), and the required SM3 algorithm hardware modules are N. Through the N SM3 algorithm hardware modules, the first hash processing is performed on the N groups of split data in parallel using the SM3 algorithm to obtain the N first temporary hash data.
[0067] For example, the data length of the data to be processed is 6.2 times 512bit. In order to greatly improve the processing speed, the target length is 1 times the minimum target length at this time, and the first ratio is calculated to be 6.2, which is rounded up to 7. Therefore, the first number is 7, and the data to be processed is split into 7 groups of data. Since the first step of the hash operation of the SM3 algorithm is padding, the data length needs to be padded to a multiple of 512bi. Therefore, when there are more data whose data length is not an integer multiple of 512bit in the N groups of split data, the data that needs to be padded will become more, which will cause a waste of space, further cause a waste of time, and is not conducive to improving the processing speed. Therefore, in the data splitting process, there is at most one group of data whose data length is not an integer multiple of the target length. Therefore, the number of split groups N=7, including: 6 groups of data with a length of 1 times 512bit, and 1 group of data with a length of 0.2 times 512bit. The parallel hashing of these 7 groups of split data takes 1 time period and requires 7 SM3 hardware modules. Directly performing hash processing on the data to be processed requires 7 time periods, while the above splitting only requires 1 time period, which can greatly improve the processing speed.
[0068] In another specific embodiment, when the amount of data to be processed is large and it is necessary to consider the hardware area overhead while improving the processing speed of the SM3 algorithm, when splitting the data to be processed into N groups, the selection of N needs to comprehensively consider the hash processing time and the number of SM3 hardware modules required, so as to effectively improve the algorithm processing speed while ensuring that the subsequent SM3 algorithm hardware module overhead is reasonable. Therefore, in the specific splitting process, it is necessary to optimize the selection of the number of split groups N to ensure that when the data to be processed is hashed in parallel, the sum of the time period and the number of SM3 hardware modules is optimal.
[0069] For example, if the data length of the data to be processed is 100.2 times of 512 bits, in order to take into account the hardware area overhead when improving the processing speed of the SM3 algorithm, you can choose to split the data to be processed into 9 groups of 10 times of 512 bits and 1 group of 10.2 times of 512 bits. After these 10 groups of split data are processed in parallel by hashing, it takes 11 time periods and requires 10 SM3 hardware modules. The sum of the time periods and the number of SM3 hardware modules is the smallest among many splitting schemes.
[0070] It should be pointed out that, according to the above examples, the more groups are split, the more conducive it is to improve the processing speed; when the amount of data to be processed is large and it is necessary to take into account the subsequent hardware area overhead while improving the processing speed of the SM3 algorithm, the selection of the number of split groups N needs to comprehensively consider the hash processing time and the number of SM3 hardware modules required, so that the sum of the time period spent on hash processing and the number of SM3 hardware modules required is the smallest among many splitting schemes. In addition, no matter how many groups of split data are divided into, the closer the data lengths of these groups of split data are, the less time it takes, and the faster the processing speed. Therefore, it can be considered to set the data lengths of multiple groups of split data to be as close as possible in order to improve the processing speed.
[0071] In this embodiment, there is at most one group of data in the N groups of split data whose data length is not an integer multiple of the target length. It should be pointed out that, since the above content proposes that the first step of the hash operation of the SM3 algorithm is padding, the data length needs to be padded to a multiple of 512 bits. Therefore, when there are more data whose data length is not an integer multiple of the target length in the N groups of split data, more data will need to be padded, which will cause a waste of space and further a waste of time, which is not conducive to improving the processing speed. Therefore, it is necessary to exclude this division method, so it is set that there is at most one group of data in the data splitting process whose data length is not an integer multiple of the target length.
[0072] It can be seen that the present application obtains data to be processed; determines a first ratio of the data length of the data to be processed to a target length, and rounds up the first ratio to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is a value not less than 1; splits the data to be processed to obtain the N groups of split data; N is the first quantity; among the N groups of split data, at most one group of data has a data length that is not an integer multiple of the target length; performs a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; and processes the N groups of first temporary hash data to obtain the target hash data. It can be seen that, among the N groups of split data in the present application, at most there is one group of data whose data length is not an integer multiple of the target length, so most of the split data do not need to be filled when performing hash calculations, reducing space waste and further improving the processing speed; the N groups of split data are hashed in parallel to obtain N groups of first temporary hash data. Compared with directly performing hash processing on the data to be processed, multiple data groups can be processed in parallel at the same time to adapt to input data of different lengths, and the time spent is reduced, which effectively improves the processing speed; and when the amount of data to be processed is large, the splitting method of the present application can take into account the subsequent hardware area overhead while improving the processing speed of the SM3 algorithm, The method can effectively reduce the hardware area of the algorithm IP core subsequently integrated in the application system; the method of further processing the obtained N groups of first temporary hash data to obtain target hash data can reduce the risk of hash collision and improve the uniqueness of the hash result compared with direct hash processing, and because the step level increases, the difficulty of inferring the data to be processed from the target hash data increases, and the irreversibility of the target hash data is improved, so the data security is improved; among the N groups of split data described in the present application, at most one group of data has a data length that is not an integer multiple of the target length, so most of the split data does not need to be filled when performing hash calculation, which reduces space waste and can improve processing speed.
[0073] The embodiment of the present application discloses a specific data processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Figure 3 As shown, specifically including:
[0074] Step S31: Obtain data to be processed.
[0075] For a more specific processing procedure of step S31, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0076] Step S32: Split the data to be processed into N groups of split data, where N is an integer not less than 2.
[0077] For a more specific processing procedure of step S32, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0078] Step S33: performing a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0079] It should be pointed out that no matter how long the data is, 256-bit data will be obtained by hashing it, so the N groups of first temporary hash data are N groups of 256-bit data.
[0080] Step S34: Process the N groups of first temporary hash data based on a preset calculation rule to obtain second temporary hash data, and obtain the target hash data according to the second temporary hash data; wherein the preset calculation rule is sum or XOR.
[0081] In this embodiment, the time required for summation or XOR processing is short and can be ignored. Therefore, on the basis that the above-mentioned splitting and parallel processing of data can achieve the effect of improving the processing speed, the N groups of first temporary hash data are processed to obtain the second temporary hash data and then summed or XORed to obtain the target hash data, which can also achieve the effect of improving the processing speed.
[0082] In addition, if it is necessary to consider the time required for summation or XOR processing, considering that the time is short, it will not exceed the time period required for hash processing, and the maximum time period required for the above-mentioned splitting and parallel processing of data is less than the number of time periods required for processing before splitting, so the time required for parallel processing plus summation or XOR processing will not exceed the number of time periods required for processing before splitting, thereby achieving the effect of improving processing speed.
[0083] It can be seen that the present application obtains data to be processed; splits the data to be processed to obtain N groups of split data, wherein N is an integer not less than 2; performs a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; processes the N groups of first temporary hash data based on a preset calculation rule to obtain second temporary hash data, and obtains the target hash data according to the second temporary hash data; wherein the preset calculation rule is summing or XOR. It can be seen that the present application processes the N groups of first temporary hash data to obtain second temporary hash data and obtains the target hash data by summing or XORing them, which can reduce the risk of hash collision and improve the uniqueness of the hash result compared with direct hash processing; the time required for summing or XOR processing in the present application is relatively short, and has little effect on the overall processing speed. Regardless of whether the time is considered or ignored, the present application can achieve the effect of improving the processing speed.
[0084] The embodiment of the present application discloses a specific data processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Figure 4 As shown, specifically including:
[0085] Step S41: Obtain data to be processed.
[0086] For a more specific processing procedure of step S41, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0087] Step S42: Split the data to be processed into N groups of split data, where N is an integer not less than 2.
[0088] Among them, for a more specific processing process of step S42, reference may be made to the corresponding content disclosed in the aforementioned embodiment, which will not be repeated here.
[0089] Step S43: performing a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0090] For a more specific processing procedure of step S43, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0091] Step S44: Processing the N groups of first temporary hash data based on a preset calculation rule to obtain second temporary hash data; wherein the preset calculation rule is sum or XOR.
[0092] Step S45: after obtaining the second temporary hash data, performing a second hash process on the second temporary hash data to obtain third temporary hash data, and obtaining the target hash data according to the third temporary hash data.
[0093] In this embodiment, a second hash process is performed on the second temporary hash data to obtain third temporary hash data, and the target hash data is obtained based on the third temporary hash data, which can further reduce the risk of hash collision. The SM3 algorithm used in the second hash process is different from the SM3 algorithm used in the first hash process. Therefore, the difficulty of inferring the data to be processed from the target hash data is increased, the irreversibility of the target hash data is improved, and the security of the data is further improved.
[0094] In this embodiment, hash processing includes three steps. The first is parallel hashing after splitting to improve the processing speed. The second is summing or XORing to reduce the risk of hash collision and improve data security. The third is hashing again to further improve data security. Compared with direct hash processing, the risk of hash collision can be reduced and the uniqueness of the hash result can be improved. In addition, due to the increase in the number of step levels, the difficulty of inferring the data to be processed from the target hash data increases, and the irreversibility of the target hash data is improved, so data security is improved.
[0095] In this embodiment, in order to reduce the processing time of the second hash processing, before performing the second hash processing, the N groups of first temporary hash data are processed based on preset calculation rules; it should be noted that the present application can control the data length of the second temporary hash data within a range not greater than the minimum data length of 512 bits, because the data length after summation or XOR processing is 256 bits, and the input data is padded with 512 bits when performing the second hash processing. At this time, the time required for the second hash processing is only one time period. If the second hash processing is directly performed on the N groups of first temporary hash data, N time periods are required. Therefore, the present application can effectively reduce the hash processing time and improve the processing speed.
[0096] In this embodiment, the time required for summation or XOR processing is short and can be ignored, and the maximum time required for the above-mentioned splitting and parallel processing of data is also shorter than the time required for direct hashing. The second hashing only takes one time period, that is, the present application will achieve the effect of increasing the speed under any circumstances, and when the amount of data to be processed is large, the subsequent hardware area overhead can be taken into account, thereby reducing the hardware area of the algorithm IP core subsequently integrated in the application system.
[0097] It can be seen that the present application obtains data to be processed; splits the data to be processed to obtain N groups of split data, wherein N is an integer not less than 2; performs a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; processes the N groups of first temporary hash data based on a preset calculation rule to obtain second temporary hash data; wherein the preset calculation rule is summing or XOR; after obtaining the second temporary hash data, performs a second hash process on the second temporary hash data to obtain third temporary hash data, and obtains the target hash data according to the third temporary hash data. It can be seen that the present application performs hash process on the basis of performing hash process on the N groups of split data in parallel, processes the N groups of first temporary hash data to obtain second temporary hash data, sums or XORs them, and performs a second hash process to obtain the target hash data. Compared with direct hash processing, it can reduce the risk of hash collision, improve the uniqueness of the hash result, increase the difficulty of inferring the data to be processed from the target hash data, and improve data security while taking into account the improvement of processing speed.
[0098] Accordingly, the present application also discloses a data processing device, see Figure 5 As shown, the device comprises:
[0099] An acquisition module 11 is used to acquire data to be processed;
[0100] A splitting module 12 is used to split the data to be processed to obtain N groups of split data, where N is an integer not less than 2;
[0101] A first processing module 13 is used to perform a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data;
[0102] The second processing module 14 is used to process the N groups of first temporary hash data to obtain target hash data.
[0103] It can be seen that the present application obtains the data to be processed; splits the data to be processed to obtain N groups of split data, wherein N is an integer not less than 2; performs a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; processes the N groups of first temporary hash data to obtain the target hash data. It can be seen that the present application performs a hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data. Compared with directly performing a hash process on the data to be processed, multiple data groups can be processed in parallel at the same time to adapt to input data of different lengths, and the time spent is reduced, which effectively improves the processing speed; the present application processes the obtained N groups of first temporary hash data to obtain the target hash data. Compared with directly performing a hash process, the method can reduce the risk of hash collision, improve the uniqueness and irreversibility of the hash result, increase the difficulty of inferring the data to be processed from the target hash data, and improve the data security while taking into account the improvement of the processing speed; the data length of at most one group of data in the N groups of split data described in the present application is not an integer multiple of the target length, so most of the split data do not need to be filled when performing hash calculations, which reduces space waste and improves the processing speed.
[0104] In one embodiment, the splitting module 12 is specifically used to determine a first ratio of the data length of the data to be processed to the target length, and round up the first ratio to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is an integer not less than 1; the data to be processed is split to obtain the N groups of split data; and N is the first quantity.
[0105] In one embodiment, among the N groups of split data, at most one group of data has a data length that is not an integer multiple of the target length.
[0106] In one embodiment, the second processing module is specifically used to process the N groups of first temporary hash data based on a preset calculation rule to obtain second temporary hash data, and obtain the target hash data according to the second temporary hash data; wherein the preset calculation rule is sum or XOR.
[0107] In one embodiment, the second processing module is further used to, after obtaining the second temporary hash data, perform a second hash process on the second temporary hash data to obtain third temporary hash data, and obtain the target hash data according to the third temporary hash data.
[0108] In one embodiment, the SM3 algorithm used in the second hash process is different from the SM3 algorithm used in the first hash process.
[0109] Furthermore, an embodiment of the present application also provides an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0110] Figure 6 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the data processing method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0111] In this embodiment, the power supply 26 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 24 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0112] In addition, the memory 22, as a carrier for storing resources, may be a read-only memory, a random access memory, a disk or an optical disk, etc., and the resources stored thereon may include a computer program 221, and the storage method may be temporary storage or permanent storage. In addition to including a computer program that can be used to complete the data processing method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 221 may further include a computer program that can be used to complete other specific tasks.
[0113] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed data processing method is implemented.
[0114] The various embodiments in this application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0115] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0116] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0117] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0118] The above is a detailed introduction to a data processing method, device, equipment, and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for a person skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data processing method, characterized in that: include: Get the data to be processed; Splitting the data to be processed into N groups of split data, where N is an integer not less than 2; Performing a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; The N groups of first temporary hash data are processed to obtain target hash data.
2. The data processing method according to claim 1, characterized in that: The step of splitting the data to be processed to obtain N groups of split data includes: Determine a first ratio of the data length of the data to be processed to the target length, and round up the first ratio to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is an integer not less than 1; The data to be processed is split into N groups of split data, where N is the first number.
3. The data processing method according to claim 2, characterized in that: Among the N groups of split data, at most one group of data has a data length that is not an integer multiple of the target length.
4. The data processing method according to claim 3, characterized in that: The processing of the N groups of first temporary hash data to obtain target hash data includes: The N groups of first temporary hash data are processed based on a preset calculation rule to obtain second temporary hash data, and the target hash data is obtained according to the second temporary hash data; wherein the preset calculation rule is sum or XOR.
5. The data processing method according to claim 4, characterized in that: Also includes: After obtaining the second temporary hash data, a second hash process is performed on the second temporary hash data to obtain third temporary hash data, and the target hash data is obtained according to the third temporary hash data.
6. The data processing method according to claim 5, characterized in that: The SM3 algorithm used in the second hash processing is different from the SM3 algorithm used in the first hash processing.
7. A data processing device, characterized in that: include: An acquisition module is used to acquire data to be processed; A splitting module, used for splitting the data to be processed to obtain N groups of split data, where N is an integer not less than 2; A first processing module, configured to perform a first hash process on the N groups of split data in parallel to obtain the N groups of first temporary hash data; The second processing module is used to process the N groups of first temporary hash data to obtain target hash data.
8. The data processing device according to claim 7, characterized in that: in: The splitting module is specifically used to determine a first ratio of the data length of the data to be processed to the target length, and round up the first ratio to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when the SM3 algorithm performs hash calculation, and M is an integer not less than 1; the data to be processed is split to obtain the N groups of split data; and N is the first quantity.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the data processing method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Implementation method and device of hash algorithm
CN112084534A
Data processing method and device, electronic equipment and storage medium
CN114077490A
Data encryption device
CN116318629A
Method for executing hash chain traversal for efficient authentication
KR1020100070879A
Parallel processing of hash functions
US20170102946A1
Cited By
Folding hash processing circuit applied to post quantum cryptography algorithm
CN119696764A
