Digital signature calculation method, device, electronic device and storage medium
By adopting the method of continuously receiving data streams on network communication devices and calculating digital signatures based on the current unsigned data and digital signature intermediate values, the problem of cache space occupation when signing big data files is solved, and efficient resource utilization and performance improvement are achieved .
Patent Information
- Application Number
- CN202110322251.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-25
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2041-03-25
AI Technical Summary
When processing big data files, existing digital signature calculation methods need to occupy a large amount of cache space, resulting in waste of resources and difficulty in improving performance.
The method of continuously receiving data streams is adopted to calculate the digital signature based on the current unsigned data and the intermediate value of the digital signature, and transmit it in real time after the data signature is completed, avoiding the entire object to be signed in the cache.
It reduces the use of cache space, improves the overall performance of electronic devices, and is suitable for network communication devices with limited resources.
Smart Images

Figure CN115134085B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular to a digital signature calculation method, device, electronic device and storage medium. Background Art
[0002] In order to ensure the security of data, the data sender generally calculates the digital signature of the data file before transmitting the data file to the data receiver, and then transmits the digital signature and the data file to the data receiver. If the data file is tampered with by a third party during the transmission process or an error occurs due to network transmission, the digital signature can detect the problem in time. Common digital signature algorithms include SHA1 algorithm, MD5 algorithm, etc.
[0003] In the prior art, when calculating the digital signature of a data file, it is necessary to first cache the entire data file to be processed, and then calculate the digital signature of the entire data file. The computing resources and storage resources of some electronic devices with network communication functions (such as data collectors) are relatively limited. If the data file to be processed has a large amount of data, the existing digital signature calculation method will occupy a large amount of cache space, resulting in a waste of cache space and is not conducive to improving the overall performance of the electronic device. Summary of the invention
[0004] In view of the problems existing in the prior art, the present invention provides a digital signature calculation method, device, electronic device and storage medium.
[0005] The present invention provides a digital signature calculation method, comprising:
[0006] Continuously receiving a data stream, wherein the data stream includes data of an object to be signed;
[0007] Calculate the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value;
[0008] Among them, the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed.
[0009] According to a digital signature calculation method provided by the present invention, after calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes:
[0010] Determine whether the digital signature calculation has been completed for all data of the object to be signed. If not, when the initiation conditions for the next digital signature calculation are met, re-execute the step of calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value; if yes, end the process.
[0011] According to a digital signature calculation method provided by the present invention, before calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes:
[0012] Determine whether the current unsigned data of the object to be signed is continuous data;
[0013] If there is non-continuous first data, the first data is stored until the second data is received, and the current unsigned data of the object to be signed is obtained according to the first data and the second data;
[0014] The second data is data that makes the first data become continuous data.
[0015] According to a digital signature calculation method provided by the present invention, after calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes:
[0016] The data of the object to be signed that has been digitally signed is transmitted in real time.
[0017] According to a digital signature calculation method provided by the present invention, the digital signature is calculated based on the current unsigned data of the object to be signed and the current digital signature intermediate value, including:
[0018] According to the current unsigned data of the object to be signed, obtaining the value of each bit in the current unsigned data and the length of the current unsigned data;
[0019] The digital signature is calculated based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value and based on a preset digital signature algorithm.
[0020] According to a digital signature calculation method provided by the present invention, after calculating the digital signature based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value and based on a preset digital signature algorithm, the method further includes:
[0021] The calculated digital signature is used to update the current digital signature intermediate value.
[0022] According to a digital signature calculation method provided by the present invention, the initiation condition of the next digital signature calculation includes:
[0023] a time interval of a predetermined length; or,
[0024] The amount of the current unsigned data of a preset size; or,
[0025] A combination of a time interval of a preset length and a data amount of the current unsigned data of a preset size.
[0026] The present invention also provides a digital signature calculation device, comprising:
[0027] A data stream receiving module, used to continuously receive a data stream, wherein the data stream includes data of an object to be signed;
[0028] A digital signature calculation module, used to calculate a digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value;
[0029] Among them, the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed.
[0030] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned digital signature calculation methods are implemented.
[0031] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the digital signature calculation methods described above are implemented.
[0032] The digital signature calculation method, device, electronic device and storage medium provided by the present invention divide the data of the signature object into multiple times for digital signature calculation, and there is no need to store the entire signature object in the cache, which helps to reduce the occupancy of the cache space. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1It is a flow chart of the digital signature calculation method provided by the present invention;
[0035] Figure 2 It is a structural schematic diagram of the digital signature calculation device provided by the present invention;
[0036] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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.
[0038] Combine the following Figure 1-Figure 3 The digital signature calculation method, device, electronic device and storage medium of the present invention are described.
[0039] Figure 1 is a flow chart of the digital signature calculation method of the present invention, such as Figure 1 As shown, the digital signature calculation method of the present invention is applied to an electronic device with a network communication function, comprising:
[0040] Step 101: Continuously receive a data stream, wherein the data stream contains data of an object to be signed.
[0041] Electronic devices with network communication functions applicable to the present invention include data collectors, file identifiers, firewalls, security devices, etc.
[0042] The method of the present invention is applied to the field of network communication. Electronic devices with network communication functions will continuously receive data streams during operation. These data streams may be from other components inside the electronic device, such as environmental data collected in real time by sensors in the electronic device, processing results of pre-stored data files by processors in the electronic device, etc., or may be data from outside the electronic device, such as data streams received by the electronic device through the network.
[0043] The object to be signed refers to the object whose digital signature needs to be calculated, such as a data file whose digital signature needs to be calculated.
[0044] Step 102: Calculate a digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value.
[0045] In this embodiment, when the overall data volume of the object to be signed is large, the object to be signed may be divided into multiple times for digital signature calculation.
[0046] In this embodiment, the current unsigned data of the object to be signed refers to the data of the object to be signed that has been received at the current moment and has not been digitally signed. For example, the object to be signed is a file D of 10 megabytes in size. At the current moment (assuming it is time t1), a data block D1 of 1 megabyte in size of the file has been received, and the data block D1 has not been digitally signed, then the data block D1 is the current unsigned data of the object to be signed.
[0047] It is easy for a person skilled in the art to understand that when the object to be signed needs to be digitally signed for multiple times, and it is the first time to perform digital signature calculation, the current unsigned data of the object to be signed is all the data of the object to be signed that has been received. When the object to be signed needs to be digitally signed for multiple times, and it is the second time or later to perform digital signature calculation, the current unsigned data of the object to be signed is the data of the object to be signed that is newly received after the previous digital signature calculation is completed.
[0048] In this embodiment, the initiation condition for a digital signature calculation may be a time interval of a preset length. For example, it is set that every 2 seconds, a digital signature calculation is performed on the data of the object to be signed that is newly received within the last 2 seconds. In other embodiments, the initiation condition for a digital signature calculation may also be a preset size of data volume. For example, it is set that a digital signature calculation is performed every time new data of the object to be signed of a size of 1 megabyte is received. In other embodiments, the initiation condition for a digital signature calculation may also be other contents, such as a combination of a time interval of a preset length and a data volume of a preset size. The present invention does not make specific limitations on the initiation conditions for digital signature calculation.
[0049] In the present invention, the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed, that is, the current digital signature intermediate value is the digital signature corresponding to the moment before a new digital signature calculation is performed.
[0050] When the object to be signed needs to be digitally signed for multiple times, and it is the first time to calculate the digital signature, the current digital signature intermediate value is 0. When the object to be signed needs to be digitally signed for multiple times, and it is the second time or later to calculate the digital signature, the current digital signature intermediate value is the result of the previous digital signature calculation.
[0051] For example, the object to be signed is a file D of size 10 megabytes. Initially, the digital signature intermediate value is set to 0. At time t1, a data block D1 of size 1 megabyte of the file has been received. The digital signature calculation is performed on the data block D1 to obtain the digital signature S1, and the current digital signature intermediate value changes from 0 to S1.
[0052] In this embodiment, a special parameter may be set to record the digital signature intermediate value. For example, when the digital signature algorithm adopts the SHA1 algorithm, a variable named sha1_ctx may be used to record the digital signature intermediate value. After a digital signature calculation, the digital signature previously recorded by sha1_ctx may be replaced by the latest calculated digital signature, thereby obtaining the updated current digital signature intermediate value.
[0053] When performing digital signature calculation, the data based on it include: the current unsigned data of the object to be signed and the current digital signature intermediate value. Specifically, the value of each bit of the current unsigned data and the length of the current unsigned data can be obtained according to the current unsigned data of the object to be signed; then, based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value, the corresponding digital signature is calculated based on the existing digital signature algorithm.
[0054] For example, the object to be signed is a file D of 10 megabytes in size. Initially, the digital signature intermediate value is set to 0. At time t1, a data block D1 of 1 megabyte in size has been received. When the digital signature is calculated for the first time, the value of each byte in the data block D1, such as the binary value of each bit, can be obtained based on the data block D1, and the data volume value L1 of the data block D1 can also be obtained. Since the current digital signature intermediate value is 0, when the digital signature is calculated for the first time, the digital signature calculation is performed on the value of each bit in the data block D1 and the data volume value L1 of the data block D1 to obtain the digital signature S1. The digital signature S1 is used to update the parameters used to represent the digital signature intermediate value, that is, the current digital signature intermediate value changes from 0 to S1.
[0055] Obviously, at time t1, only part of the data in file D has been digitally signed. Therefore, the digital signature calculation continues. At time t2, a new data block D2 of 1 megabyte in size is received from file D. When the digital signature calculation is performed for the second time, the value of each bit in data block D2 can be obtained based on data block D2, and the data volume value L2 of data block D2 can also be obtained. At this time, the current digital signature intermediate value is S1 (non-zero), so when the digital signature is calculated for the second time, the digital signature calculation is performed on the value of each bit in data block D2, the data volume value L2 of data block D2, and the digital signature intermediate value S1 to obtain the digital signature S2. The digital signature S2 is used to update the parameters used to represent the digital signature intermediate value, that is, the current digital signature intermediate value changes from S1 to S2.
[0056] By analogy, the digital signature calculation can be continued for file D until the digital signature calculation has been completed for all the data of file D. The final current digital signature intermediate value is also the digital signature of file D.
[0057] In this embodiment, the digital signature algorithm may be a SHA1 algorithm, an MD5 algorithm, etc. Taking the SHA1 algorithm as an example, in a digital signature calculation process, assuming that the current unsigned data of the object to be signed includes {a, b, c, d}, and the current digital signature intermediate value is S1, when performing digital signature calculation, logical operations such as "shift", "and", "or", and "not" are performed according to the bit to obtain a digital signature S2.
[0058] For example:
[0059] R0{a,b,c,d,S1,0}; R0{S1,a,b,c,d,1};
[0060] R0{d, S1, a, b, c, 2}; R0{c, d, S1, a, b, 3};
[0061] R0{b,c,d,S1,a,4}; R0{a,b,c,d,S1,5};
[0062] R0{S1, a, b, c, d, 6}; R0 {d, S1, a, b, c, 7};
[0063] R0{c,d,S1,a,b,8}; R0{b,c,d,S1,a,9};
[0064] R0{a, b, c, d, S1, 10}; R0{S1, a, b, c, d, 11};
[0065] R0{d, S1, a, b, c, 12}; R0{c, d, S1, a, b, 13};
[0066] R0{b,c,d,S1,a,14}; R0{a,b,c,d,S1,15};
[0067] R1{S1, a, b, c, d, 16}; R1 {d, S1, a, b, c, 17};
[0068] R1{c,d,S1,a,b,18}; R1{b,c,d,S1,a,19};
[0069] R2{a, b, c, d, S1, 20}; R2{S1, a, b, c, d, 21};
[0070] R2{d, S1, a, b, c, 22}; R2{c, d, S1, a, b, 23};
[0071] R2{b,c,d,S1,a,24}; R2{a,b,c,d,S1,25};
[0072] R2{S1,a,b,c,d,26};R2{d,S1,a,b,c,27};
[0073] R2{c,d,S1,a,b,28};R2{b,c,d,S1,a,29};
[0074] R2{a,b,c,d,S1,30};R2{S1,a,b,c,d,31};
[0075] R2{d,S1,a,b,c,32};R2{c,d,S1,a,b,33};
[0076] R2{b,c,d,S1,a,34};R2{a,b,c,d,S1,35};
[0077] R2{S1,a,b,c,d,36};R2{d,S1,a,b,c,37};
[0078] R2{c,d,S1,a,b,38};R2{b,c,d,S1,a,39};
[0079] R3{a,b,c,d,S1,40};R3{S1,a,b,c,d,41};
[0080] R3{d,S1,a,b,c,42};R3{c,d,S1,a,b,43};
[0081] R3{b,c,d,S1,a,44};R3{a,b,c,d,S1,45};
[0082] R3{S1,a,b,c,d,46};R3{d,S1,a,b,c,47};
[0083] R3{c,d,S1,a,b,48};R3{b,c,d,S1,a,49};
[0084] R3{a,b,c,d,S1,50};R3{S1,a,b,c,d,51};
[0085] R3{d,S1,a,b,c,52};R3{c,d,S1,a,b,53};
[0086] R3{b,c,d,S1,a,54};R3{a,b,c,d,S1,55};
[0087] R3{S1,a,b,c,d,56};R3{d,S1,a,b,c,57};
[0088] R3{c,d,S1,a,b,58}; R3{b,c,d,S1,a,59};
[0089] R4{a, b, c, d, S1, 60}; R4 {S1, a, b, c, d, 61};
[0090] R4{d, S1, a, b, c, 62}; R4 {c, d, S1, a, b, 63};
[0091] R4{b,c,d,S1,a,64}; R4{a,b,c,d,S1,65};
[0092] R4{S1, a, b, c, d, 66}; R4 {d, S1, a, b, c, 67};
[0093] R4{c,d,S1,a,b,68}; R4{b,c,d,S1,a,69};
[0094] R4{a, b, c, d, S1, 74}; R4 {S1, a, b, c, d, 71};
[0095] R4{d, S1, a, b, c, 72}; R4 {c, d, S1, a, b, 73};
[0096] R4{b,c,d,S1,a,74}; R4{a,b,c,d,S1,75};
[0097] R4{S1, a, b, c, d, 76}; R4 {d, S1, a, b, c, 77};
[0098] R4{c,d,S1,a,b,78}; R4{b,c,d,S1,a,79}.
[0099] In the above example, R0-R4 is the wheel formula of displacement calculation; the number in each unit, such as 0, 1, 2, ..., 79, represents the number of times involved in the calculation; the above content is the result of the digital signature calculation.
[0100] The digital signature calculation method provided by the present invention performs digital signature calculations on the data of the object to be signed in multiple times, without storing the entire object to be signed in the cache, which helps to reduce the occupation of the cache space.
[0101] Based on any of the above embodiments, in this embodiment, after step 102, the method further includes:
[0102] Determine whether the digital signature calculation has been completed for all data of the object to be signed. If not, when the initiation conditions for the next digital signature calculation are met, re-execute the step of calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value; if yes, end the process.
[0103] Depending on the amount of data in the object to be signed, the number of times the digital signature is calculated for the object to be signed may vary. In this embodiment, it is determined whether all the data in the object to be signed have completed the digital signature calculation. If there is data in the object to be signed that has not yet completed the digital signature, the next digital signature calculation needs to be performed on the object to be signed.
[0104] In this embodiment, the initiation condition for a digital signature calculation may be a time interval of a preset length. For example, it is set that every 2 seconds, a digital signature calculation is performed on the data of the object to be signed that is newly received within the last 2 seconds. In other embodiments, the initiation condition for a digital signature calculation may also be a preset size of data volume. For example, it is set that a digital signature calculation is performed every time new data of the object to be signed of a size of 1 megabyte is received. In other embodiments, the initiation condition for a digital signature calculation may also be other contents, such as a combination of a time interval of a preset length and a data volume of a preset size. The present invention does not make specific limitations on the initiation conditions for digital signature calculation.
[0105] The specific implementation process of digital signature calculation is not essentially different from the previous embodiment, so it will not be repeated in this embodiment.
[0106] The digital signature calculation method provided by the present invention performs digital signature calculations on the data of the object to be signed in multiple times, without storing the entire object to be signed in the cache, which helps to reduce the occupation of the cache space.
[0107] Based on any of the above embodiments, in this embodiment, before calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes:
[0108] Determine whether the current unsigned data of the object to be signed is continuous data;
[0109] If there is non-continuous first data, the first data is stored until the second data is received, and the current unsigned data of the object to be signed is obtained based on the first data and the second data; wherein the second data is the data that makes the first data continuous data.
[0110] In the previous embodiments, there is a default premise that the data of the object to be signed is received in sequence. According to the description of the process of digital signature calculation in the previous embodiment, it can be known that the result obtained by the previous digital signature calculation (the current digital signature intermediate value) will be used in the next digital signature calculation process. Therefore, only when the data of the object to be signed is received in sequence, the final result obtained by multiple digital signature calculations will be the same as the result of a single digital signature calculation for the entire object to be signed. Otherwise, the final result obtained by multiple digital signature calculations is very likely to be incorrect.
[0111] For example, the object D to be signed has data block D1, data block D2 and data block D3 in sequence. According to the correct order, first calculate the digital signature S1 of data block D1, then calculate the digital signature S2 based on data block D2 and digital signature S1, and then calculate the digital signature S3 based on data block D3 and digital signature S2.
[0112] However, if during the data transmission process, the order of receiving the data blocks in the object to be signed D is data block D1, data block D3 and data block D2. According to the description of the previous embodiment, the digital signature S1 of the data block D1 is first calculated, and then the digital signature S2' is calculated based on the data block D3 and the digital signature S1, and then the digital signature S3' is calculated based on the data block D2 and the digital signature S2'.
[0113] Digital signature S3 is obtained based on data block D3 and digital signature S2, while digital signature S3' is obtained based on data block D2 and digital signature S2'. Under the premise that data block D2 is different from data block D3, and digital signature S2 is different from digital signature S2', digital signature S3 and digital signature S3' are very likely to be different.
[0114] Therefore, in this embodiment, it is necessary to determine whether the current unsigned data of the object to be signed is continuous data. How to determine whether the current unsigned data is continuous data is common knowledge for those skilled in the art, such as based on the identification information of the data block, so it is not further described in this embodiment.
[0115] If the current unsigned data of the object to be signed is not continuous data, the non-continuous first data will be temporarily stored. After the continuous second data is received, the first data and the second data will be spliced in sequence to form the current unsigned data of the object to be signed, and then the data signature calculation operation will be performed.
[0116] For example, the object D to be signed has data block D1, data block D2 and data block D3 in sequence. During the data transmission process, the order of receiving the data blocks in the object D to be signed is data block D1, data block D3 and data block D2. During the first digital signature calculation, it is known that data block D1 is the first data block in the object D to be signed, so the digital signature calculation can be performed normally. Next, data block D3 is processed. Since data block D3 and the previously processed data block D1 are not continuous data, data block D3 is temporarily stored and no digital signature calculation is performed. After receiving data block D2, it is determined whether data block D2 is continuous with data block D3, and whether data block D2 is continuous with the previously processed data block D1. Since they are continuous data, data block D2 and data block D3 together form the current unsigned data of the object D to be signed. The digital signature calculation is performed on these two data blocks and the digital signature S1 obtained based on data block D1.
[0117] The digital signature calculation method provided by the present invention avoids the influence of disorder caused by data transmission on data signature calculation by judging whether the current unsigned data of the signature object is continuous data, and reduces the cache space occupied while also ensuring the accuracy of digital signature calculation.
[0118] Based on any of the above embodiments, in this embodiment, after calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes:
[0119] The data of the object to be signed that has been digitally signed is transmitted in real time.
[0120] In this embodiment, when the overall data volume of the object to be signed is large, the object to be signed can be divided into multiple digital signature calculations. After each digital signature calculation, the part of the object to be signed that has been digitally signed can be sent out instantly through the network without being stored in the local cache of the electronic device. This further reduces the demand for cache space.
[0121] The digital signature calculation method provided by the present invention divides the data of the signature object into multiple digital signature calculations, and after each digital signature calculation, the part that has been digitally calculated is instantly sent out through the network. There is no need to store the entire object to be signed in the cache, which helps to reduce the occupancy of the cache space.
[0122] The digital signature calculation device provided by the present invention is described below. The digital signature calculation device described below and the digital signature calculation method described above can be referenced to each other.
[0123] Figure 2 A schematic diagram of the structure of the digital signature calculation device provided by the present invention, such as Figure 2 As shown, the digital signature calculation device provided by the present invention includes:
[0124] A data stream receiving module 201, configured to continuously receive a data stream, wherein the data stream includes data of an object to be signed;
[0125] A digital signature calculation module 202, used to calculate a digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value;
[0126] Among them, the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed.
[0127] The digital signature calculation device provided by the present invention performs digital signature calculations on the data of the object to be signed in multiple times, and does not need to store the entire object to be signed in the cache, which helps to reduce the occupation of the cache space.
[0128] Based on any of the above embodiments, in this embodiment, the device further includes:
[0129] The judgment module is used to judge whether all the data of the object to be signed have completed the digital signature calculation. If not, when the initiation conditions of the next digital signature calculation are met, the step of calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value is re-executed; if yes, the process ends.
[0130] The digital signature calculation device provided by the present invention performs digital signature calculations on the data of the object to be signed in multiple times, and does not need to store the entire object to be signed in the cache, which helps to reduce the occupation of the cache space.
[0131] Based on any of the above embodiments, in this embodiment, the device further includes:
[0132] A continuous data judgment module is used to judge whether the current unsigned data of the object to be signed is continuous data;
[0133] The current unsigned data generation module is used to store discontinuous first data if the first data exists, until the second data is received, and obtain the current unsigned data of the object to be signed based on the first data and the second data; wherein the second data is the data that makes the first data continuous data.
[0134] The digital signature calculation device provided by the present invention avoids the influence of disorder caused by data transmission on data signature calculation by judging whether the current unsigned data of the signature object is continuous data, and reduces the cache space occupied while also ensuring the accuracy of digital signature calculation.
[0135] Based on any of the above embodiments, in this embodiment, the device further includes:
[0136] The real-time transmission module is used to transmit in real time the data of the object to be signed that has been digitally signed.
[0137] The digital signature calculation device provided by the present invention divides the data of the signature object into multiple digital signature calculations, and after each digital signature calculation, the part that has been digitally signed is instantly sent out through the network. There is no need to store the entire object to be signed in the cache, which helps to reduce the occupancy of the cache space.
[0138] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the digital signature calculation method, which includes:
[0139] Continuously receiving a data stream, wherein the data stream includes data of an object to be signed;
[0140] Calculate the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value;
[0141] Among them, the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed.
[0142] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0143] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer can execute the digital signature calculation method provided by the above methods, the method comprising:
[0144] Continuously receiving a data stream, wherein the data stream includes data of an object to be signed;
[0145] Calculate the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value;
[0146] Among them, the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed.
[0147] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the digital signature calculation method provided above, the method comprising:
[0148] Continuously receiving a data stream, wherein the data stream includes data of an object to be signed;
[0149] Calculate the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value;
[0150] Among them, the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed.
[0151] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0152] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A digital signature calculation method, characterized in that: include: Continuously receiving a data stream, wherein the data stream includes data of an object to be signed; Calculate the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value; The method of calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value includes: obtaining the value of each bit in the current unsigned data and the length of the current unsigned data according to the current unsigned data of the object to be signed; calculating the digital signature based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value based on a preset digital signature algorithm; wherein the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; when the object to be signed needs to perform digital signature calculations in batches, and it is the first time to perform digital signature calculations, the current unsigned data of the object to be signed is calculated based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value. The name data is all the data of the object to be signed that has been received so far; when the object to be signed needs to perform digital signature calculations in batches, and the digital signature calculation is performed for the second time or later, the current unsigned data of the object to be signed is the data of the object to be signed newly received after the previous digital signature calculation is completed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed; when the object to be signed needs to perform digital signature calculations in batches, and the digital signature calculation is performed for the first time, the current digital signature intermediate value is 0; when the object to be signed needs to perform digital signature calculations in batches, and the digital signature calculation is performed for the second time or later, the current digital signature intermediate value is the result of the previous digital signature calculation.
2. The digital signature calculation method according to claim 1, characterized in that: After calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes: Determine whether the digital signature calculation has been completed for all data of the object to be signed. If not, when the initiation conditions for the next digital signature calculation are met, re-execute the step of calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value; if yes, end the process.
3. The digital signature calculation method according to claim 1 or 2, characterized in that: Before calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes: Determine whether the current unsigned data of the object to be signed is continuous data; If there is non-continuous first data, the first data is stored until the second data is received, and the current unsigned data of the object to be signed is obtained according to the first data and the second data; The second data is data that makes the first data become continuous data.
4. The digital signature calculation method according to any one of claims 1 to 3, characterized in that: After calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value, the method further includes: The data of the object to be signed that has been digitally signed is transmitted in real time.
5. The digital signature calculation method according to claim 1, characterized in that: After calculating the digital signature based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value and based on a preset digital signature algorithm, the method further includes: The calculated digital signature is used to update the current digital signature intermediate value.
6. The digital signature calculation method according to claim 2, characterized in that: The initiation conditions for the next digital signature calculation include: a time interval of a predetermined length; or, The amount of the current unsigned data of a preset size; or, A combination of a time interval of a preset length and a data amount of the current unsigned data of a preset size.
7. A digital signature calculation device, characterized in that: include: A data stream receiving module, used to continuously receive a data stream, wherein the data stream includes data of an object to be signed; A digital signature calculation module, used to calculate a digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value; The method of calculating the digital signature based on the current unsigned data of the object to be signed and the current digital signature intermediate value includes: obtaining the value of each bit in the current unsigned data and the length of the current unsigned data according to the current unsigned data of the object to be signed; calculating the digital signature based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value based on a preset digital signature algorithm; wherein the current unsigned data of the object to be signed is the data of the object to be signed that has been received at the current moment, and the data has not been digitally signed; when the object to be signed needs to perform digital signature calculations in batches, and it is the first time to perform digital signature calculations, the current unsigned data of the object to be signed is calculated based on the value of each bit of the current unsigned data, the length of the current unsigned data and the current digital signature intermediate value. The name data is all the data of the object to be signed that has been received so far; when the object to be signed needs to perform digital signature calculations in batches, and the digital signature calculation is performed for the second time or later, the current unsigned data of the object to be signed is the data of the object to be signed newly received after the previous digital signature calculation is completed; the current digital signature intermediate value is a digital signature obtained based on the signed data of the object to be signed; when the object to be signed needs to perform digital signature calculations in batches, and the digital signature calculation is performed for the first time, the current digital signature intermediate value is 0; when the object to be signed needs to perform digital signature calculations in batches, and the digital signature calculation is performed for the second time or later, the current digital signature intermediate value is the result of the previous digital signature calculation.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the digital signature calculation method according to any one of claims 1 to 6 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the digital signature calculation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising computer executable instructions, characterized in that: When executed, the instructions are used to implement the steps of the digital signature calculation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Digital signature method for mass data
CN101883118A
Quantum digital signature method for untrusted center
CN106452791A
Signature verification method and device based on content center network, and medium
CN108833108A
Signature verification method, system, device and equipment in block chain type account book
CN110163006A
Digital signature generation method, device and equipment and storage medium
CN111614469A
