A data processing method, apparatus, device, and medium
By splitting the data to be processed into parallel hash processing and performing multiple hash processing, the problem of insufficient processing speed and security of the SM3 algorithm in solid-state drives is solved, achieving faster data processing and higher security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2026-04-07
AI Technical Summary
The existing SM3 algorithm has limited processing speed in solid-state drives, which cannot meet the needs of efficient processing of large-scale data, and it also has problems such as hash collision risk and poor data security.
The data to be processed is split into N groups, and the first hash processing is performed in parallel. Then, the target hash data is obtained through the preset calculation rules and the second hash processing. The number of split groups is optimized to reduce hardware overhead and hash collision risk.
It improves data processing speed, reduces the risk of hash collisions, enhances the uniqueness and irreversibility of data, and improves data security.
Smart Images

Figure CN118690384B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a data processing method, device, equipment and medium. BACKGROUND
[0002] In the field of data security, HASH algorithm is widely used in data encryption, data integrity verification and data indexing of data storage devices, such as solid state disk. The performance of HASH algorithm directly affects the processing speed and data security of the entire solid state disk system. Among them, SM3 algorithm is a commonly used HASH value calculation algorithm.
[0003] At present, in order to improve the HASH processing performance of SM3 algorithm, some solutions have been proposed. For example, by optimizing the algorithm to realize the parallel calculation of SM3 algorithm, using multi-threading for calculation to improve the processing speed. In addition, some solutions use distributed computing to divide the calculation task into multiple processors for parallel calculation, further improving the calculation performance.
[0004] However, in the existing scheme, the multi-thread processing in the SM3 algorithm hardware module only parallel processes the part of the input data with similar calculation steps, and serial processes the other part, which has limited speed improvement and cannot meet the efficient processing needs of large-scale data. In addition, for input data with long data length, the processing time is longer. In addition, the hash data obtained by processing different data through HASH algorithm may collide, that is, different data have the same hash data, and the data obtained by single HASH algorithm processing is easy to be 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 disk is a problem to be solved at present. SUMMARY
[0006] Therefore, the purpose of the present application is to provide a data processing method, device, equipment and medium, which can adapt to input data of different lengths and improve the speed and security of data processing. The specific scheme is as follows:
[0007] In a first aspect, the present application discloses a data processing method, comprising:
[0008] obtaining to-be-processed data;
[0009] splitting the to-be-processed data to obtain N groups of split data, N being an integer not less than 2;
[0010] parallel processing the N groups of split data to obtain N groups of first temporary hash data;
[0011] processing the N groups of first temporary hash data to obtain target hash data.
[0012] Optionally, the splitting the to-be-processed data to obtain N groups of split data comprises:
[0013] determining a first ratio of a data length of the to-be-processed data to a target length, and taking an integer greater than or equal to the first ratio to obtain a first quantity; wherein the target length is M times of a minimum data length that can be filled to obtain hash calculation by an SM3 algorithm, and M is an integer greater than or equal to 1;
[0014] splitting the to-be-processed data to obtain the N groups of split data; and N is the first quantity.
[0015] Optionally, in the N groups of split data, a data length of at most one group of data 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 comprises:
[0017] processing the N groups of first temporary hash data based on a pre-designed calculation rule to obtain second temporary hash data, and obtaining the target hash data according to the second temporary hash data; wherein the pre-designed calculation rule is summation or exclusive OR.
[0018] Optionally, the data processing method further comprises:
[0019] after obtaining the second temporary hash data, performing second hash processing 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.
[0020] Optionally, the SM3 algorithm used in the second hash processing is different from the SM3 algorithm used in the first hash processing.
[0021] In a second aspect, the present application discloses a data processing apparatus, comprising:
[0022] an acquisition module configured to acquire to-be-processed data;
[0023] a splitting module configured to split the to-be-processed data to obtain N groups of split data, wherein N is an integer greater than or equal to 2;
[0024] a first processing module configured to perform first hash processing on the N groups of split data in parallel to obtain N groups of first temporary hash data;
[0025] The second processing module is used to process the N sets of first temporary hash data to obtain the target hash data.
[0026] Optionally, in the data processing apparatus:
[0027] The splitting module is specifically used to determine a first ratio between the data length of the data to be processed and the target length, and to 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 performing hash calculation using the SM3 algorithm, and M is an integer not less than 1; the data to be processed is split to obtain the N sets of split data; and N is the first quantity.
[0028] Thirdly, this application discloses an electronic device, comprising:
[0029] Memory, used to store computer programs;
[0030] A processor is used to execute the computer program to implement the aforementioned disclosed data processing method.
[0031] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed data processing method.
[0032] As can be seen, this application obtains the data to be processed; splits the data to be processed into N sets of split data, where N is an integer not less than 2; performs a first hash process on the N sets of split data in parallel to obtain the N sets of first temporary hash data; and processes the N sets of first temporary hash data to obtain the target hash data. Therefore, this application splits the input data to be processed and then performs hash processing on the N sets of split data in parallel to obtain N sets of first temporary hash data. Compared with directly hashing the data to be processed, this allows for the simultaneous parallel processing of multiple data sets, adapting to input data of different lengths, and reducing processing time, effectively improving processing speed. Furthermore, the method of processing the obtained N sets of first temporary hash data to obtain the target hash data, compared with direct hash processing, reduces the risk of hash collisions, improves the uniqueness of the hash result, and, due to the increased number of steps, increases the difficulty of deducing the data to be processed from the target hash data, improving the irreversibility of the target hash data, thus enhancing data security. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0034] Figure 1 This is a flowchart of a data processing method disclosed in this application;
[0035] Figure 2 This is a flowchart of a specific data processing method disclosed in this application;
[0036] Figure 3 This is a flowchart of a specific data processing method disclosed in this application;
[0037] Figure 4 This is a flowchart of a specific data processing method disclosed in this application;
[0038] Figure 5 This is 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 Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] The multi-threaded processing in the existing SM3 algorithm hardware module only processes the parts of the input data with similar computational steps in parallel, which has limited speed improvement and cannot meet the needs of efficient processing of large-scale data. Moreover, 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. Furthermore, the single HASH algorithm is easily restored to the data to be processed and has the risk of hash collision, resulting in poor security.
[0042] Therefore, this application proposes a data processing scheme that can improve data processing speed and data security.
[0043] This application discloses a data processing method, see [link to relevant documentation] Figure 1 As shown, the method includes:
[0044] Step S11: Obtain the 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 sets of split data, where N is an integer not less than 2.
[0047] It should be noted that the larger the value of N, the shorter the time required for subsequent parallel hash calculations. However, the more SM3 algorithm hardware modules need to participate in the hash calculation, the larger the hardware area required for subsequent application systems to integrate the algorithm IP (Internet Protocol). Therefore, the choice of the number of split groups N can be optimized based on the requirements of subsequent application systems for algorithm processing performance and the hardware area required to integrate the algorithm IP core, so as to improve the algorithm processing speed while taking into account the subsequent hardware area.
[0048] Step S13: Perform the first hash processing on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0049] In this embodiment, the data to be processed is split into N groups, and then the split data is hashed in parallel to obtain N groups of first temporary hash data. Compared with directly hashing the data to be processed, it is not necessary to wait for all the data to be given before calculation. At the same time, multiple data groups are processed in parallel, which can adapt to input data of different lengths and reduce the time spent, effectively improving the processing speed.
[0050] Step S14: Process the N sets of first temporary hash data to obtain the target hash data.
[0051] In this embodiment, the data to be processed is split into N sets of split data, where N is an integer not less than 2; the N sets of split data are subjected to a first hash process in parallel to obtain N sets of first temporary hash data; and the N sets of first temporary hash data are processed to obtain the target hash data. Therefore, compared with directly hashing the data to be processed, the parallel hash processing of the split data into N sets of first temporary hash data allows for the simultaneous processing of multiple data sets, adapting to input data of different lengths, and reducing processing time, effectively improving processing speed. Furthermore, when the amount of data to be processed is large, the splitting method of this application can improve the processing speed of the SM3 algorithm while considering subsequent hardware area overhead, effectively reducing the hardware area of the algorithm IP core integrated into the application system. The method of further processing the obtained N sets of first temporary hash data to obtain the target hash data, compared with direct hash processing, can reduce the risk of hash collisions, improve the uniqueness of the hash result, and, due to the increased number of steps, increase the difficulty of deducing the data to be processed from the target hash data, improving the irreversibility of the target hash data, thus improving data security.
[0052] This application discloses a specific data processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. See also... Figure 2 As shown, it specifically includes:
[0053] Step S21: Obtain the data to be processed.
[0054] For a more detailed description of the process of step S21, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0055] Step S22: Determine a first ratio between the data length of the data to be processed and the target length, and round the first ratio up to obtain a first quantity; wherein, the target length is M times the minimum data length that can be filled when performing hash calculation using the SM3 algorithm, and M is an integer not less than 1.
[0056] Step S23: Split the data to be processed to obtain the N sets of split data; N is the first quantity; at most one set of data in the N sets of split 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, splitting the data to be processed into N sets of split data includes: determining a first ratio between the data length of the data to be processed and a target length; rounding the first ratio up to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled by hash calculation using the SM3 algorithm, and M is a value not less than 1; splitting the data to be processed into the N sets of split data; and N is the first quantity. It should be noted that N is not less than 2 and not greater than the first quantity when the target length is minimized; wherein, rounding up can be understood as the first quantity being equal to the first ratio when the first ratio is an integer; and the first quantity being an integer obtained by adding 1 to the integer part of the first ratio when the first ratio is a decimal.
[0058] It should be noted that the first step in the hash operation of the SM3 algorithm is padding, which requires padding the data length to a multiple of 512 bits, where 512 bits is the minimum target length that the data needs to be padded when performing the hash operation.
[0059] It should be noted that M being an integer not less than 1 defines the minimum value of M, and N being an integer not less than 2 defines the maximum value of M. Specifically: when the length of the data to be processed is 5.2 times 512 bits, and the target length is M times 512 bits, and M is an integer not less than 1 and N is defined as an integer not less than 2, the first ratio P is a value in the range 1 (M is 5.2) < P ≤ 5.2 (M is 1). The range of this value, rounded up, is 2 ≤ K ≤ 6, meaning N belongs to 2 ≤ K ≤ 6. It should be noted that if M is greater than 5.2, then the value of 1 in 1 < P ≤ 5.2 is not 1 but less than 1. This would cause the value of 2 in the range 2 ≤ K ≤ 6 where N is located to be less than 2, which does not meet the requirements. Therefore, M being an integer not less than 1 defines the minimum value of M, and M's value is not greater than the first ratio when the target length is 512 bits. The characteristic that N is an integer not less than 2 also defines the maximum value of M.
[0060] It should be noted that the data length of the data to be processed is 5.2 times 512 bits, the target length is M times 512 bits, where M is a value not less than 1, and N is not greater than the first quantity when the target length is at its 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 quantity is the first ratio rounded up, which is 6; therefore, N is an integer not less than 2 and not greater than 6.
[0061] It should be noted that in the specific data splitting process, the selection of the target length during splitting can be optimized based on the requirements of the subsequent application system for algorithm processing performance and the hardware area required for integrating the algorithm IP core. This will optimize the selection of the number of splitting groups N, thereby improving the algorithm processing speed while taking into account the subsequent hardware area.
[0062] In this embodiment, at most one group of the N split data sets will have a data length that is not an integer multiple of the target length. It should be noted that when using the SM3 algorithm for hashing, only data whose 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, resulting in wasted space and further wasted time, which is detrimental to improving processing speed. Therefore, it is necessary to split the data into integer multiples of the target length as much as possible.
[0063] Step S24: Perform the first hash processing on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0064] After splitting the data to be processed into N sets of split data by the above steps, the first hash processing is performed on the N sets of split data in parallel to improve the hash processing speed.
[0065] Step S25: Process the N sets of first temporary hash data to obtain the target hash data.
[0066] In one specific embodiment, when the size of the data to be processed is moderate and the application system needs to greatly improve processing speed, the data to be processed can be split into N groups, where N is the first number obtained by rounding up the ratio of the data length of the data to be processed to the minimum target length, and at most one group in the N groups has a data length that is not an integer multiple of the target length. The maximum data length of each group is 512 bits. The time required for the first hash processing is a time interval (the time for hashing 512 bits of data is set as a time interval for easy representation of the hash processing time), and N SM3 algorithm hardware modules are required. Through the N SM3 algorithm hardware modules, the first hash processing of the N groups of split data is performed in parallel using the SM3 algorithm to obtain the N first temporary hash data.
[0067] For example, if the length of the data to be processed is 6.2 times the 512-bit length, to maximize processing speed, the target length is set to 1 times the minimum target length. The first ratio is calculated as 6.2, rounded up to 7. Therefore, the first quantity is 7, dividing the data to be processed into 7 groups. Since the first step of the SM3 algorithm's hash operation is padding, which requires padding the data length to a multiple of 512 bits, the more data groups after N splits where the data length is not an integer multiple of 512 bits, the more padding is needed, resulting in wasted space and time, hindering processing speed. Therefore, during data splitting, at most one group of data will have a length not an integer multiple of the target length. Thus, the number of split groups N = 7, including: 6 groups of 512-bit data with a length of 1 time and 1 group of 512-bit data with a length of 0.2 times the target length. These 7 groups of split data are hashed in parallel, taking one time interval and requiring 7 SM3 hardware modules. Directly hashing the data to be processed would take seven time periods, while the above splitting only takes one 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 balance improving the processing speed of the SM3 algorithm with reducing hardware area overhead, splitting the data to be processed into N groups requires careful consideration of both hash processing time and the number of SM3 hardware modules needed. This ensures that the hardware overhead of the subsequent SM3 algorithm is reasonable while effectively improving the algorithm's processing speed. Therefore, in the specific splitting process, the selection of the number of groups N needs to be optimized to ensure that the sum of the time required for parallel hash processing of the data to be processed and the number of SM3 hardware modules is optimal.
[0069] For example, if the length of the data to be processed is 100.2 times that of 512 bits, in order to improve the processing speed of the SM3 algorithm while taking into account the hardware area overhead, the data to be processed can be split into 9 groups of 10 times the length of 512 bits and 1 group of 10.2 times the length of 512 bits. After these 10 splits, the data is hashed in parallel, which takes 11 time periods and requires 10 SM3 hardware modules. Moreover, the sum of the time periods and the number of SM3 hardware modules is the smallest among many splitting schemes.
[0070] It should be noted that, as illustrated in the examples above, a higher number of split groups generally leads to faster processing. When the amount of data to be processed is large and the hardware footprint needs to be considered while improving the SM3 algorithm's processing speed, the choice of the number of split groups N must take into account both hash processing time and the required number of SM3 hardware modules, minimizing the sum of the hash processing time and the number of required SM3 hardware modules among various splitting schemes. Furthermore, regardless of the number of split groups, the closer the data lengths of these groups, the shorter the processing time and the faster the processing speed. Therefore, it is advisable to set the data lengths of multiple split groups to be as close as possible to improve processing speed.
[0071] In this embodiment, for the case where at most one set of data in the N groups of split data has a data length that is not an integer multiple of the target length, it should be noted that, as mentioned above, the first step of the hash operation of the SM3 algorithm is padding, which requires padding the data length to a multiple of 512 bits. Therefore, when there are more data sets in the N groups of split data whose length is not an integer multiple of the target length, the amount of data that needs to be padded will increase, resulting in wasted space and further wasted time, which is not conducive to improving processing speed. Therefore, this partitioning method needs to be excluded. Thus, it is set that at most one set of data in the data splitting process has a data length that is not an integer multiple of the target length.
[0072] As can be seen, this application obtains data to be processed; determines a first ratio between the data length of the data to be processed and the target length, and rounds the first ratio up to obtain a first quantity; wherein, the target length is M times the minimum data length that can be filled when performing hash calculation using the SM3 algorithm, and M is a value not less than 1; splits the data to be processed to obtain N groups of split data; N is the first quantity; at most one group of data in the N groups of split 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. Therefore, it can be seen that in the N groups of split data obtained in this application, at most one group of data has a length that is not an integer multiple of the target length. Thus, most of the split data does not need padding during hash calculation, reducing space waste and further improving processing speed. The parallel hashing of the N groups of split data to obtain N groups of first temporary hash data, compared to directly hashing the data to be processed, allows for the simultaneous parallel processing of multiple data groups, adapting to input data of different lengths, and reducing processing time, effectively improving processing speed. Furthermore, when the amount of data to be processed is large, the splitting method of this application can improve the processing speed of the SM3 algorithm while considering subsequent hardware area overhead. This method effectively reduces the hardware area of the algorithm IP cores subsequently integrated into the application system. Compared with direct hash processing, the method of processing the obtained N groups of first temporary hash data to obtain the target hash data can reduce the risk of hash collisions, improve the uniqueness of hash results, and increase the difficulty of deducing the data to be processed from the target hash data due to the increased number of steps, thereby improving the irreversibility of the target hash data and thus improving data security. In the N groups of split data described in this application, at most one group of data has a data length that is not an integer multiple of the target length. Therefore, most of the split data does not need to be padded during hash calculation, reducing space waste and improving processing speed.
[0073] This application discloses a specific data processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. See also... Figure 3 As shown, it specifically includes:
[0074] Step S31: Obtain the data to be processed.
[0075] For a more detailed description of the process of step S31, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0076] Step S32: Split the data to be processed into N sets of split data, where N is an integer not less than 2.
[0077] For a more detailed description of the process of step S32, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0078] Step S33: Perform the first hash processing on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0079] It should be noted that no matter how long the data is, the hashing process will result in 256 bits of data. Therefore, the N sets of first temporary hash data are N sets of 256 bits of data.
[0080] Step S34: Process the N sets of first temporary hash data according to the 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 summation or XOR.
[0081] In this embodiment, the time required for summation or XOR processing is short and negligible. Therefore, based on the above-mentioned splitting and parallel processing of data to improve processing speed, the addition of processing the N groups of first temporary hash data to obtain the second temporary hash data and then summing or XORing them to obtain the target hash data can also improve processing speed.
[0082] In addition, if we need to consider the time required for summation or XOR processing, considering that the time is relatively short and will not exceed the time period required for hash processing, and that 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, the time required for parallel processing plus summation or XOR processing will not exceed the number of time periods required for processing before splitting, thus achieving the effect of improving processing speed.
[0083] As can be seen, this application obtains data to be processed; splits the data to be processed into N sets of split data, where N is an integer not less than 2; performs a first hash process on the N sets of split data in parallel to obtain the N sets of first temporary hash data; processes the N sets of first temporary hash data based on a preset calculation rule to obtain second temporary hash data, and obtains the target hash data based on the second temporary hash data; wherein, the preset calculation rule is summation or XOR. Therefore, this application, by performing parallel hash processing on the N sets of split data, and then summing or XORing the N sets of first temporary hash data to obtain the second temporary hash data to obtain the target hash data, can reduce the risk of hash collisions and improve the uniqueness of the hash result compared to direct hash processing. The summation or XOR processing required by this application is relatively short, and has little impact on the overall processing speed. Whether this time is considered or ignored, this application can still achieve the effect of improving processing speed.
[0084] This application discloses a specific data processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. See also... Figure 4 As shown, it specifically includes:
[0085] Step S41: Obtain the data to be processed.
[0086] For a more detailed description of the process of step S41, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0087] Step S42: Split the data to be processed into N sets of split data, where N is an integer not less than 2.
[0088] For a more detailed description of the process of step S42, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0089] Step S43: Perform the first hash processing on the N groups of split data in parallel to obtain the N groups of first temporary hash data.
[0090] For a more detailed description of the process of step S43, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0091] Step S44: Process the N sets of first temporary hash data according to the preset calculation rules to obtain second temporary hash data; wherein, the preset calculation rules are summation or XOR.
[0092] Step S45: After obtaining the second temporary hash data, perform a second hashing process on the second temporary hash data to obtain a third temporary hash data, and obtain the target hash data based on the third temporary hash data.
[0093] In this embodiment, the second temporary hash data is subjected to a second hash process to obtain a third temporary hash data, and the target hash data is obtained based on the third temporary hash data. This can further reduce the risk of hash collisions. Furthermore, 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 deducing the data to be processed from the target hash data is increased, which improves the irreversibility of the target hash data and further enhances the security of the data.
[0094] In this embodiment, the hashing process includes three steps: first, splitting and parallel hashing to improve processing speed; second, summing or XORing to reduce the risk of hash collisions and improve data security; and third, hashing again to further improve data security. Compared with direct hashing, it can reduce the risk of hash collisions, improve the uniqueness of hash results, and increase the difficulty of deriving the data to be processed from the target hash data due to the increased number of steps, thereby improving the irreversibility of the target hash data and thus improving data security.
[0095] In this embodiment, to reduce the processing time of the second hash processing, the N sets of first temporary hash data are processed based on preset calculation rules before performing the second hash processing. It should be noted that this application can control the data length of the second temporary hash data to no more than the minimum data length of 512 bits. Because the data length after summation or XOR processing is 256 bits, it is padded to 512 bits of input data during the second hash processing. Therefore, the time required for the second hash processing is only one time period. If the second hash processing is performed directly on the N sets of first temporary hash data, N time periods are required. Therefore, this application can effectively reduce hash processing time and improve processing speed.
[0096] In this embodiment, the time required for summation or XOR processing is short and negligible. Furthermore, 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 hash only requires one time period. In other words, this application will achieve the effect of improving speed under any circumstances. Moreover, when the amount of data to be processed is large, it can take into account the subsequent hardware area overhead and reduce the hardware area of the algorithm IP core integrated into the application system.
[0097] As can be seen, this application obtains data to be processed; splits the data to be processed into N sets of split data, where N is an integer not less than 2; performs a first hash process on the N sets of split data in parallel to obtain the N sets of first temporary hash data; processes the N sets of first temporary hash data based on a preset calculation rule to obtain second temporary hash data; wherein, the preset calculation rule is summation 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 based on the third temporary hash data. Therefore, this application, based on the parallel hash processing of the split data into N sets, processes the N sets of first temporary hash data to obtain the second temporary hash data, performs summation or XOR, and then performs a second hash process to obtain the target hash data. Compared with direct hash processing, this can reduce the risk of hash collisions, improve the uniqueness of the hash result, increase the difficulty of deducing the data to be processed from the target hash data, and improve data security while also increasing processing speed.
[0098] Accordingly, this application also discloses a data processing apparatus, see [link to relevant documentation]. Figure 5 As shown, the device includes:
[0099] Module 11 is used to acquire data to be processed;
[0100] The splitting module 12 is used to split the data to be processed into N sets of split data, where N is an integer not less than 2;
[0101] The 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] As can be seen, this application obtains the data to be processed; splits the data to be processed into N sets of split data, where N is an integer not less than 2; performs a first hash process on the N sets of split data in parallel to obtain the N sets of first temporary hash data; and processes the N sets of first temporary hash data to obtain the target hash data. Therefore, compared with directly hashing the data to be processed, this application's method of performing hash processing on the N sets of split data in parallel to obtain N sets of first temporary hash data allows for the simultaneous parallel processing of multiple data sets, adapting to input data of different lengths, and reducing processing time, effectively improving processing speed. The method of further processing the obtained N sets of first temporary hash data to obtain the target hash data, compared with direct hash processing, reduces the risk of hash collisions, improves the uniqueness and irreversibility of hash results, increases the difficulty of deducing the data to be processed from the target hash data, and improves data security while also increasing processing speed. In this application, at most one set of data in the N sets of split data has a length that is not an integer multiple of the target length, thus most of the split data does not need to be padded during hash calculation, reducing space waste and improving processing speed.
[0104] In one embodiment, the splitting module 12 is specifically used to determine a first ratio between the data length of the data to be processed and the target length, and to 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 performing hash calculation using the SM3 algorithm, and M is an integer not less than 1; the data to be processed is split to obtain the N sets of split data; and N is the first quantity.
[0105] In one embodiment, at most one set of data in the N sets of split data has a 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 sets of first temporary hash data based on a preset calculation rule to obtain second temporary hash data, and to obtain the target hash data based on the second temporary hash data; wherein, the preset calculation rule is summation or XOR.
[0107] In one embodiment, the second processing module is further configured to, after obtaining the second temporary hash data, perform a second hash processing on the second temporary hash data to obtain a third temporary hash data, and obtain the target hash data based on the third temporary hash data.
[0108] In one embodiment, the SM3 algorithm used in the second hash processing is different from the SM3 algorithm used in the first hash processing.
[0109] Furthermore, embodiments of this application also provide an electronic device. Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0110] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may 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 stores 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 foregoing embodiments. Furthermore, 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 operating 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 external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 24 is used to acquire 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] Furthermore, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored thereon may include computer programs 221, and the storage method may be temporary storage or permanent storage. The computer programs 221 may include, in addition to computer programs capable of performing the data processing methods executed by the electronic device 20 as disclosed in any of the foregoing embodiments, computer programs capable of performing other specific tasks.
[0113] Furthermore, embodiments of this application also disclose a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed data processing method.
[0114] The various embodiments in this application are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. For the same or similar parts between the various embodiments, refer to each other. As for the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and relevant parts can be referred to in the method section.
[0115] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0116] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0117] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0118] The above provides a detailed description of a data processing method, apparatus, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data processing method, characterized in that, include: Obtain the data to be processed; The data to be processed is split into N sets of split data, where N is an integer not less than 2; The N groups of split data are processed in parallel to obtain the N groups of first temporary hash data; The target hash data is obtained by processing the N sets of first temporary hash data; The step of splitting the data to be processed into N sets of split data includes: A first ratio is determined between the data length of the data to be processed and the target length, and the first ratio is rounded up to obtain a first quantity; wherein, the target length is M times the minimum data length that can be filled when performing hash calculation using the SM3 algorithm, and M is an integer not less than 1; The data to be processed is split into N sets of split data, where N is the first quantity; Among the N groups of split data, at most one group of data has a length that is not an integer multiple of the target length.
2. The data processing method according to claim 1, characterized in that, The process of processing the N groups of first temporary hash data to obtain the target hash data includes: The N sets of first temporary hash data are processed according to 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 summation or XOR.
3. The data processing method according to claim 2, characterized in that, Also includes: After obtaining the second temporary hash data, perform a second hashing process on the second temporary hash data to obtain a third temporary hash data, and obtain the target hash data based on the third temporary hash data.
4. The data processing method according to claim 3, characterized in that, The second hash process uses a different SM3 algorithm than the first hash process.
5. A data processing apparatus, characterized in that, include: The acquisition module is used to acquire data to be processed. The splitting module is used to split the data to be processed into N sets of split data, where N is an integer not less than 2; The first processing module 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. The second processing module is used to process the N groups of first temporary hash data to obtain target hash data; Specifically, the splitting module is used to determine a first ratio between the data length of the data to be processed and the target length, and round the first ratio up to obtain a first quantity; wherein the target length is M times the minimum data length that can be filled when performing hash calculation using the SM3 algorithm, and M is an integer not less than 1; the data to be processed is split to obtain the N sets of split data; and N is the first quantity; Among the N groups of split data, at most one group of data has a length that is not an integer multiple of the target length.
6. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the data processing method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, Used to store a computer program; wherein, when the computer program is executed by a processor, it implements the data processing method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Implementation method and device of hash algorithm
CN112084534A
Data processing method and device, electronic equipment and storage medium
CN114077490A