An encryption method and system based on digest function
Through the encryption method based on digest function, the plaintext data is expanded and grouped, and combined with key derivation and exclusive OR operation, the problem of slow encryption speed in power grid equipment is solved, and data transmission efficiency and computing performance are improved.
Patent Information
- Application Number
- CN202410993691.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-07-24
AI Technical Summary
When existing power grid terminal devices interact with data, the SM4 packet encryption algorithm causes the ciphertext calculation speed to be slow, affecting the information interaction rate, and unable to adapt to the technical trend of long messages and strong interactions.
The encryption method based on digest function is adopted to generate ciphertext data by expanding plaintext data, packet processing, key derivation and exclusive OR operations, thereby improving encryption efficiency.
On the basis of ensuring security, the interaction rate of data transmission is significantly improved, adapting to the needs of a large number of data fast interaction scenarios, and improving resource utilization and computing performance.
Smart Images

Figure CN118551401B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and more specifically, to an encryption method and system based on a digest function. Background Art
[0002] With the rapid development of new power system construction, more and more load control equipment is installed and deployed at the end of the power grid, assuming functions such as data collection and user load control. As the degree of automation at the end of the power grid increases, the frequency of data interaction between the end-of-grid equipment and user equipment is getting higher and higher, and the length of the transmitted data is getting longer and longer. This requires that when the two parties communicate, they need to pay attention to security while ensuring transmission efficiency.
[0003] In order to ensure the security of the power grid terminal equipment, the embedded cryptographic algorithm module is now mostly used to achieve identity authentication and data encryption protection. The SM4 block encryption method is used to generate ciphertext in encryption. The speed of calculating the ciphertext is relatively slow. It is urgent to design an algorithm process that can improve the interaction rate while ensuring that the security is basically not reduced.
[0004] At present, IoT meters add security chips in different modules to achieve identity authentication and interactive data encryption for the connection between metering modules, management modules and external devices. The SM4 block encryption method is used to generate ciphertext. The metering process is relatively complicated and the ciphertext calculation speed is relatively slow, which affects the information interaction rate and cannot adapt to the technical trend of long messages and strong interactions.
[0005] In the context of new power system construction, electric energy meters not only carry the basic mission of electric energy metering, but also serve as a key perception hub on the customer side, and undertake the mission of power consumption situation perception monitoring, load control and equipment interconnection, and information interaction. Faced with diverse application scenarios and constantly updated perception and interaction needs, the frequency of data interaction between meters and related equipment is getting higher and higher, and the length of transmitted data is getting longer and longer. When the two parties communicate, it is necessary to pay attention to security while ensuring transmission efficiency. It is urgent to design an algorithm process that can improve the interaction rate without reducing security. Summary of the invention
[0006] The technical solution of the present invention provides an encryption method and system based on a digest function to solve the problem of how to quickly encrypt data based on a digest function.
[0007] In order to solve the above problem, the present invention provides an encryption method based on a digest function, the method comprising:
[0008] The original plaintext data to be encrypted is expanded, and the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data;
[0009] Using the integer multiple as the grouping number, grouping the expanded plaintext data to obtain the grouped plaintext data;
[0010] Based on the true random number R and the pre-buried key, the key is obtained through the digest function operation, and the key stream including the integer multiple array key is generated by performing a derivation operation on the obtained key;
[0011] Perform XOR calculations on the keys in the key stream and the corresponding grouped plaintext data to obtain integer multiple arrays of ciphertext data;
[0012] Generate an integer multiple plus a group of ciphertext data based on all ciphertext data in the integer multiple array, the true random number R, and the pre-embedded key;
[0013] All ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group are sent to the receiver as a whole encrypted data.
[0014] Preferably, the method of obtaining a key through a digest function operation based on a true random number R and a pre-buried key, and generating a key stream including an integer multiple array key by performing a derivation operation on the obtained key, includes:
[0015] A true random number R is generated by a random number generator as the initial value of the counter, the true random number R is concatenated with the pre-embedded key and used as the input value of the digest function, and the first key is obtained after the digest function is operated; after obtaining the first key, a key derivation operation is performed:
[0016] Increasing the value of the counter by one, and concatenating the value with the pre-buried key as the input value of the digest function, and obtaining the second key after the digest function is operated;
[0017] The key derivation operation is performed in this way until the key of the integer multiple array is obtained;
[0018] Based on the first key to the integer multiple array key, a key stream including all integer multiple array keys is generated.
[0019] Preferably, the step of generating the integer multiple plus one group of ciphertext data based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key comprises:
[0020] All ciphertext data in the integer multiple array are used as input values for hash calculation to obtain a fixed-length information summary value str;
[0021] After the information digest value str is concatenated with the pre-buried key, the key of the integer multiple plus one group is derived as the input value of the digest function;
[0022] The integer multiple plus a group of key and the true random number R are XORed to generate the integer multiple plus a group of ciphertext data.
[0023] Preferably, the method further comprises decrypting the encrypted data by the receiving party, wherein the true random number R is obtained as follows:
[0024] Calculate the information digest value str2 of the ciphertext data of the first to the first integer multiple arrays based on the digest function, and after splicing the information digest value str2 with the pre-embedded key, derive the first integer multiple plus a group of keys as the input value of the digest function;
[0025] The true random number R is obtained by performing an XOR calculation based on the key of the integer multiple plus a group and the ciphertext data of the integer multiple plus a group.
[0026] Preferably, the method further comprises decrypting the encrypted data by the receiving party, wherein all the ciphertext data in the integer multiple array are decrypted as follows:
[0027] The true random number R is concatenated with the pre-embedded key as the input value of the digest function, a key stream is obtained after the digest function is operated, and all the plaintext data in the integer multiple array are obtained by performing XOR operations on the keys in the key stream and the corresponding pairs of all the ciphertext data in the integer multiple array.
[0028] Preferably, the method further comprises decrypting the encrypted data by the receiving party, comprising:
[0029] Concatenate all the plaintext data in the integer multiple array to obtain the original plaintext data.
[0030] According to another aspect of the present invention, the present invention provides an encryption system based on a digest function, the system comprising:
[0031] The initial unit is used to expand the original plaintext data to be encrypted, and the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data;
[0032] A grouping unit, used to group the expanded plaintext data using an integer multiple as a grouping number, and obtain the grouped plaintext data;
[0033] A first generating unit is used to obtain a key after performing a digest function operation based on a true random number R and a pre-buried key, and to generate a key stream including an integer multiple array key by performing a derivation operation on the obtained key;
[0034] An acquisition unit, used to perform XOR calculation on the key in the key stream and the corresponding grouped plaintext data respectively, to obtain the ciphertext data of the integer multiple array;
[0035] A second generating unit is used to generate the integer multiple plus one group of ciphertext data based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key;
[0036] The sending unit is used to send all the ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group as a whole encrypted data to the receiving party.
[0037] Preferably, the first generating unit is used to obtain a key after performing a digest function operation based on the true random number R and the pre-embedded key, and to generate a key stream including an integer multiple array key by performing a derivation operation on the obtained key, and is also used to:
[0038] A true random number R is generated by a random number generator as the initial value of the counter, the true random number R is concatenated with the pre-embedded key and used as the input value of the digest function, and the first key is obtained after the digest function is operated; after obtaining the first key, a key derivation operation is performed:
[0039] Increasing the value of the counter by one, and concatenating the value with the pre-buried key as the input value of the digest function, and obtaining the second key after the digest function is operated;
[0040] The key derivation operation is performed in this way until the key of the integer multiple array is obtained;
[0041] Based on the first key to the integer multiple array key, a key stream including all integer multiple array keys is generated.
[0042] Preferably, the second generating unit is used to generate the integer multiple plus one group of ciphertext data based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key, and is also used to:
[0043] All ciphertext data in the integer multiple array are used as input values for hash calculation to obtain a fixed-length information summary value str;
[0044] After the information digest value str is concatenated with the pre-buried key, the key of the integer multiple plus one group is derived as the input value of the digest function;
[0045] The integer multiple plus a group of key and the true random number R are XORed to generate the integer multiple plus a group of ciphertext data.
[0046] Preferably, it also includes a decryption unit, which is used to decrypt the encrypted data through the receiving party, wherein the true random number R is obtained as follows:
[0047] Calculate the information digest value str2 of the ciphertext data of the first to the first integer multiple arrays based on the digest function, and after splicing the information digest value str2 with the pre-embedded key, derive the first integer multiple plus a group of keys as the input value of the digest function;
[0048] The true random number R is obtained by performing an XOR calculation based on the key of the integer multiple plus a group and the ciphertext data of the integer multiple plus a group.
[0049] Preferably, it also includes a decryption unit, which is used to decrypt the encrypted data through the receiving party, wherein all the ciphertext data in the integer multiple array are decrypted as follows:
[0050] The true random number R is concatenated with the pre-embedded key as the input value of the digest function, a key stream is obtained after the digest function is operated, and all the plaintext data in the integer multiple array are obtained by performing XOR operations on the keys in the key stream and the corresponding pairs of all the ciphertext data in the integer multiple array.
[0051] Preferably, it also includes a decryption unit, which is used to decrypt the encrypted data through the receiving party, including:
[0052] Concatenate all the plaintext data in the integer multiple array to obtain the original plaintext data.
[0053] According to another aspect of the present invention, the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and the computer program is used to execute an encryption method based on a digest function.
[0054] Based on another aspect of the present invention, the present invention provides an electronic device, characterized in that the electronic device comprises: a processor and a memory; wherein,
[0055] The memory is a memory for storing instructions executable by the processor;
[0056] The processor is used to read the executable instructions from the memory and execute the instructions to implement an encryption method based on a digest function.
[0057] The technical solution of the present invention provides an encryption method and system based on a digest function, wherein the method comprises: expanding the original plaintext data to be encrypted, wherein the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data; using the integer multiple as the grouping number, grouping the expanded plaintext data, and obtaining the grouped plaintext data; based on a true random number R and a pre-embedded key, obtaining the key after a digest function operation, and generating a key stream including an integer multiple array key by performing a derivation operation on the obtained key; performing an XOR operation on the key in the key stream and the corresponding grouped plaintext data, respectively, to obtain the ciphertext data of the integer multiple array; generating the ciphertext data of the integer multiple plus one group based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key; and sending all the ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group as the whole encrypted data to the receiver. The technical solution of the present invention aims at the problem of low interaction efficiency existing in the operation process of encryption algorithm in application scenarios with rapid interaction of large amounts of data. A fast encryption method based on a digest function is proposed. The encryption and decryption key stream is derived through the fast calculation and fixed output length characteristics of the digest function. A simple XOR operation is used in the operation to improve resource utilization and achieve higher performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] A more complete understanding of exemplary embodiments of the present invention may be obtained by referring to the following drawings:
[0059] Figure 1 A flowchart of an encryption method based on a digest function according to a preferred embodiment of the present invention;
[0060] Figure 2 It is a flowchart of the encryption process operation according to a preferred embodiment of the present invention;
[0061] Figure 3 A flowchart of a decryption process according to a preferred embodiment of the present invention; and
[0062] Figure 4 The figure is a structural diagram of an encryption system based on a digest function according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0063] Now, exemplary embodiments of the present invention are described with reference to the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to disclose the present invention in detail and completely and to fully convey the scope of the present invention to those skilled in the art. The terms used in the exemplary embodiments shown in the accompanying drawings are not intended to limit the present invention. In the accompanying drawings, the same units / elements are marked with the same reference numerals.
[0064] Unless otherwise specified, the terms (including technical terms) used herein have the commonly understood meanings to those skilled in the art. In addition, it is understood that the terms defined in commonly used dictionaries should be understood to have the same meanings as those in the context of the relevant fields, and should not be understood as idealized or overly formal meanings.
[0065] Figure 1 The figure is a flow chart of an encryption method based on a digest function according to a preferred embodiment of the present invention.
[0066] The present invention aims to solve the problem of low interaction efficiency in the operation of encryption algorithms in application scenarios where a large amount of data is rapidly interacted. A fast encryption method based on a digest function is provided. The encryption and decryption key streams are derived through the fast calculation and fixed output length characteristics of the digest function. A simple XOR operation is used in the operation to improve resource utilization and achieve higher performance.
[0067] Aiming at the problem of low interaction efficiency in the operation of encryption algorithms in application scenarios where a large amount of data is rapidly interacted, this invention proposes a fast encryption method based on a digest function, which proposes a more efficient method and application for existing encryption and decryption algorithms. Its implementation process includes two parts: packet encryption and packet decryption:
[0068] The data encryption process is to fill the data first. The encryption algorithm uses the KDF key stream encryption algorithm based on the digest function. The key is derived through the digest function to obtain several key streams, which are then XORed with the grouped plaintext to obtain the ciphertext group. Among them, the essence of the digest function is to operate on data of any length to obtain a hash value of fixed length, use the pre-buried key plus the counter to derive the key stream, and then XOR it with the grouped plaintext to obtain the grouped ciphertext. The encryption process is as follows:
[0069] like Figure 1 As shown, the present invention provides an encryption method based on a digest function, the method comprising:
[0070] Step 101: Expand the original plaintext data to be encrypted, and the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data;
[0071] The present invention first fills the original data. Since the derived key stream is a data string of fixed length, it needs to be expanded to an integer multiple of the corresponding key length before plaintext grouping.
[0072] Step 102: using the integer multiple as the grouping number, grouping the expanded plaintext data to obtain the grouped plaintext data;
[0073] The present invention fills the data to an integer multiple (N times) of the key length and obtains N groups of plaintexts (plaintext 1, plaintext 2 . . . plaintext N) after grouping, and then derives the key stream of the pre-buried key.
[0074] Step 103: Based on the true random number R and the pre-buried key, a key is obtained through a digest function operation, and a key stream including an integer multiple array key is generated by performing a derivation operation on the obtained key;
[0075] The present invention is based on a true random number R and a pre-buried key, obtains a key through a digest function operation, and generates a key stream including an integer multiple array key by performing a derivative operation on the obtained key, including:
[0076] A true random number R is generated by a random number generator as the initial value of the counter, and the true random number R is concatenated with the pre-embedded key as the input value of the digest function. The first key is obtained after the digest function operation; after obtaining the first key, the key derivation operation is performed:
[0077] The counter value is incremented by one, and the resultant is concatenated with the pre-buried key as the input value of the digest function, and the second key is obtained after the digest function operation;
[0078] The key derivation operation is performed in this way until the key of the integer multiple array is obtained;
[0079] Based on the first key to the integer multiple array keys, a key stream including all integer multiple array keys is generated.
[0080] The derivation process of the key stream in the present invention is:
[0081] ① First, use the random number generator to generate a true random number R as the initial value of the counter, and then concatenate the random number with the pre-buried key to form the input value of the digest function. After the digest function operation, the key 1 is obtained, such as Figure 1 ;
[0082] ② After obtaining key 1, add one to the counter, and then concatenate it with the pre-buried key to form the input value of the second digest function. After the digest function operation, key 2 is obtained, and so on to obtain key 1, key 2...key N. Figure 2 shown.
[0083] Step 104: performing XOR calculations on the keys in the key stream and the corresponding grouped plaintext data respectively to obtain ciphertext data of an integer multiple array;
[0084] The present invention performs XOR calculation on the key stream and the corresponding plaintext group, key 1 corresponds to plaintext 1, key 2 corresponds to plaintext 2, and so on to obtain N groups of ciphertext (ciphertext 1, ciphertext 2...ciphertext N).
[0085] Step 105: Generate the integer multiple plus one group of ciphertext data based on all ciphertext data in the integer multiple array, the true random number R and the pre-embedded key;
[0086] Preferably, based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key, generating the ciphertext data of the integer multiple plus one group includes:
[0087] All ciphertext data in the integer multiple array are used as input values for hash calculation to obtain a fixed-length information summary value str;
[0088] After the information digest value str is concatenated with the pre-buried key, the key of the integer multiple plus one group is derived as the input value of the digest function;
[0089] The integer multiple plus a group of key is XORed with the true random number R to generate the integer multiple plus a group of ciphertext data.
[0090] In order to ensure that the decryption party can correctly decrypt the ciphertext, the present invention must correctly and securely transmit the counter R value, and to ensure the integrity of the information during transmission, the operation steps are as follows:
[0091] ① Ciphertext 1, ciphertext 2, ... ciphertext N are used as input values for hash calculation to obtain a fixed-length information summary value str;
[0092] ② Concatenate the obtained summary value str with the pre-buried key and use it as the input value of the summary function to derive the key N+1;
[0093] ③ Perform XOR calculation on the key N+1 and the counter R value to obtain the ciphertext N+1.
[0094] Step 106: Send all the ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group as the whole encrypted data to the receiver.
[0095] The present invention transmits ciphertext 1, ciphertext 2, ... ciphertext N+1 to the receiving party. The encryption process ends.
[0096] Preferably, the method further includes decrypting the encrypted data by the receiver, wherein the true random number R is obtained as:
[0097] Calculate the information digest value str2 of the ciphertext data of the first to the integer multiple arrays based on the digest function, concatenate the information digest value str2 with the embedded key, and use the result as the input value of the digest function to derive the integer multiple plus one group of keys;
[0098] A true random number R is obtained by performing an XOR calculation based on the key of the integer multiple plus a group and the ciphertext data of the integer multiple plus a group.
[0099] Preferably, the method further includes decrypting the encrypted data by the receiver, wherein all the ciphertext data in the integer multiple array are decrypted as follows:
[0100] The true random number R is concatenated with the embedded key as the input value of the digest function, and the key stream is obtained after the digest function operation. The key in the key stream and the corresponding all ciphertext data in the integer multiple array are XORed in turn to obtain all the plaintext data in the integer multiple array.
[0101] Preferably, the method further includes decrypting the encrypted data by the receiving party, including:
[0102] Concatenate all the plaintext data in the integer multiple array to obtain the original plaintext data.
[0103] The present invention proposes a fast encryption method based on a digest function, which utilizes the digest function in combination with a counter and the keys of the interacting parties (sender and receiver) to derive a key stream, and implements fast encryption of plaintext through XOR logic calculation.
[0104] The fast encryption method proposed by the present invention includes two parts: group encryption and group decryption.
[0105] The block encryption process proposed by the present invention is to group the plaintext, generate a block key based on a pre-embedded key and a random number, and then obtain the block ciphertext through an XOR operation.
[0106] The block encryption algorithm of the present invention adopts a KDF key stream encryption algorithm based on a digest function, and a key is derived through a digest function to obtain a plurality of key streams.
[0107] The key stream derived in the present invention is a data string of fixed length.
[0108] The packet decryption process proposed by the present invention is that after the receiver decrypts the counter, a key stream is derived at the receiving end, and the ciphertext and the key stream are XOR-transformed to obtain the original plaintext data.
[0109] The plaintext grouping method of the present invention is to first fill the original plaintext data, and then group them according to the length of the summary generated by the summary function.
[0110] The present invention fills the original data with an integer multiple (N times) of the key length, and obtains N groups of plaintexts (plaintext 1, plaintext 2 . . . plaintext N) after grouping.
[0111] The key 1 generation process of the present invention is to first use a random number generator to generate a true random number R as the initial value of the counter, then concatenate the random number with the pre-embedded key to form the input value of the digest function, and obtain the key 1 after the digest function operation.
[0112] The generation process of key 2 to key N of the present invention is to add one to the counter, and then splice it with the pre-embedded key to form the input value of the second summary function. After the summary function operation, key 2 is obtained, and so on to obtain key 1, key 2...key N.
[0113] The present invention performs XOR calculation on the key stream and the corresponding plaintext group, key 1 corresponds to plaintext 1, key 2 corresponds to plaintext 2, and so on to obtain N groups of ciphertext (ciphertext 1, ciphertext 2, ..., ciphertext N).
[0114] The present invention encrypts a counter R value based on a digest function and an XOR operation, thereby achieving correct and secure transmission of the counter value to a receiver.
[0115] The process of encrypting the counter R of the present invention is to perform hash calculation on ciphertext 1, ciphertext 2, ..., ciphertext N as a whole as input values to obtain a fixed-length information summary value str, and concatenate the obtained summary value str with the embedded key to derive the key N+1 as the input value of the summary function, and obtain the ciphertext N+1 by performing XOR calculation on the key N+1 and the random number R.
[0116] In the present invention, the information transmitted from the sender to the receiver includes ciphertext 1, ciphertext 2, ..., ciphertext N+1.
[0117] In the present invention, after receiving all ciphertexts, the receiver first processes the ciphertexts to obtain the counter R value.
[0118] In the present invention, the process of the receiver obtaining the counter R value is that the receiver uses a digest function to calculate the overall digest value str2 of the first N groups of lengths of the received ciphertext, then concatenates the pre-embedded key, and derives the key N+1 as the input value of the digest function, which is XOR-calculated with the N+1th group of received ciphertext to obtain the counter R value.
[0119] In the present invention, after the receiver obtains the value of the calculator R, the decryption process is specifically the inverse process of the encryption process.
[0120] In the present invention, the receiver decrypts ciphertext 1 by concatenating the counter R value with the pre-buried key to form the input value of the digest function, obtains key 1 after the digest function operation, and then performs XOR operation on key 1 and ciphertext 1 to obtain plaintext 1.
[0121] In the present invention, the receiver decrypts ciphertext 2 to ciphertext N by performing XOR calculation on the key stream and the corresponding plaintext group, key 2 corresponds to ciphertext 2, and so on to obtain N groups of plaintext (plaintext 1, plaintext 2, ..., ciphertext N).
[0122] In the present invention, after the receiver has decrypted all ciphertext groups, the N groups of plaintext are concatenated to obtain the complete original plaintext data.
[0123] The decryption process in the present invention is specifically the reverse process of the encryption process. The receiver uses the digest function to calculate the overall digest value str2 of the first N groups of received ciphertext, and then pre-embeds the key for splicing, and derives the key N+1 as the input value of the digest function, and performs XOR calculation with the N+1th group of received ciphertext to obtain the counter R value.
[0124] After the counter R value is obtained, the decryption process of the present invention is specifically the reverse process of the encryption process, such as Figure 3 .
[0125] The fast encryption method based on summary function proposed in the present invention is based on pre-embedded keys and counters, generates a characteristic derived key stream of fixed summary values through a summary function, and adopts a simple XOR method in operation to reduce encryption complexity, improve resource utilization, and achieve higher performance.
[0126] The grouping encryption and decryption method proposed in the present invention transmits data in groups, thereby improving data transmission efficiency while ensuring that security is not substantially reduced.
[0127] The counter R value secure transmission method proposed in the present invention generates an encrypted counter R value key based on a ciphertext summary value and a pre-embedded key, without the need to transmit other information additionally, thereby ensuring the integrity and security of information transmission.
[0128] Figure 4 The structure diagram of an encryption system based on a digest function according to a preferred embodiment of the present invention.
[0129] like Figure 4 As shown, the present invention provides an encryption system based on a digest function, the system comprising:
[0130] The initialization unit 401 is used to expand the original plaintext data to be encrypted, and the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data;
[0131] A grouping unit 402, configured to group the expanded plaintext data using an integer multiple as a grouping number, and obtain the grouped plaintext data;
[0132] The first generating unit 403 is used to obtain a key through a digest function operation based on the true random number R and the pre-embedded key, and generate a key stream including an integer multiple array key by performing a derivation operation on the obtained key;
[0133] Preferably, the first generating unit 403 is used to obtain a key after performing a digest function operation based on the true random number R and the pre-embedded key, and to generate a key stream including an integer multiple array key by performing a derivation operation on the obtained key, and is also used to:
[0134] A true random number R is generated by a random number generator as the initial value of the counter, and the true random number R is concatenated with the pre-embedded key as the input value of the digest function. The first key is obtained after the digest function operation; after obtaining the first key, the key derivation operation is performed:
[0135] The counter value is incremented by one, and the resultant is concatenated with the pre-buried key as the input value of the digest function, and the second key is obtained after the digest function operation;
[0136] The key derivation operation is performed in this way until the key of the integer multiple array is obtained;
[0137] Based on the first key to the integer multiple array keys, a key stream including all integer multiple array keys is generated.
[0138] The acquisition unit 404 is used to perform XOR calculation on the key in the key stream and the corresponding grouped plaintext data to obtain the ciphertext data of the integer multiple array;
[0139] The second generating unit 405 is used to generate the integer multiple plus one group of ciphertext data based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key;
[0140] Preferably, the second generating unit 405 is used to generate the integer multiple plus one group of ciphertext data based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key, and is also used to:
[0141] All ciphertext data in the integer multiple array are used as input values for hash calculation to obtain a fixed-length information summary value str;
[0142] After the information digest value str is concatenated with the pre-buried key, the key of the integer multiple plus one group is derived as the input value of the digest function;
[0143] The integer multiple plus a group of key is XORed with the true random number R to generate the integer multiple plus a group of ciphertext data.
[0144] The sending unit 406 is used to send all the ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group as a whole encrypted data to the receiving party.
[0145] Preferably, it also includes a decryption unit for decrypting the encrypted data through the receiving party, wherein the true random number R is obtained as:
[0146] Calculate the information digest value str2 of the ciphertext data of the first to the integer multiple arrays based on the digest function, concatenate the information digest value str2 with the embedded key, and use the result as the input value of the digest function to derive the integer multiple plus one group of keys;
[0147] A true random number R is obtained by performing an XOR calculation based on the key of the integer multiple plus a group and the ciphertext data of the integer multiple plus a group.
[0148] Preferably, it also includes a decryption unit for decrypting the encrypted data through the receiving party, wherein all the ciphertext data in the integer multiple array are decrypted as follows:
[0149] The true random number R is concatenated with the embedded key as the input value of the digest function, and the key stream is obtained after the digest function operation. The key in the key stream and the corresponding all ciphertext data in the integer multiple array are XORed in turn to obtain all the plaintext data in the integer multiple array.
[0150] Preferably, it also includes a decryption unit, which is used to decrypt the encrypted data through the receiving party, including:
[0151] Concatenate all the plaintext data in the integer multiple array to obtain the original plaintext data.
[0152] The present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, and the computer program is used to execute an encryption method based on a digest function.
[0153] The present invention provides an electronic device, characterized in that the electronic device comprises: a processor and a memory; wherein:
[0154] Memory, a memory for storing processor executable instructions;
[0155] The processor is used for reading executable instructions from the memory and executing the instructions to implement an encryption method based on a digest function.
[0156] The present invention proposes a fast encryption method based on summary functions, which can be used to transform the results in the market of IoT table and rail table encryption chips. The market is stable, the cooperation is smooth, and the prospect of transformation of results is broad.
[0157] The present invention proposes a fast encryption method based on a digest function, which quickly derives a key stream based on the digest function and combines it with XOR logic calculation to effectively improve the encryption speed during algorithm operation, improve the utilization rate of computing resources, and achieve higher performance.
[0158] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The solutions in the embodiments of the present invention may be implemented in various computer languages, for example, object-oriented programming language Java and interpreted scripting language JavaScript, etc.
[0159] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0160] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0161] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0162] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0163] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
[0164] The invention has been described above with reference to a few embodiments. However, it is readily apparent to a person skilled in the art that other embodiments than the ones disclosed above are equally within the scope of the invention, as defined by the appended patent claims.
[0165] Generally, all terms used in the claims are to be interpreted according to their ordinary meaning in the technical field, unless explicitly defined otherwise herein. All references to "a / said / the [means, components, etc.]" are to be openly interpreted as at least one instance of the means, components, etc., unless explicitly stated otherwise. The steps of any method disclosed herein do not necessarily have to be performed in the exact order disclosed, unless explicitly stated otherwise.
Claims
1. An encryption method based on a digest function, the method comprising: The original plaintext data to be encrypted is expanded, and the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data; Using the integer multiple as the grouping number, grouping the expanded plaintext data to obtain the grouped plaintext data; Based on the true random number R and the pre-buried key, the key is obtained through the digest function operation, and the key stream including the integer multiple array key is generated by performing a derivative operation on the obtained key, including: A true random number R is generated by a random number generator as the initial value of the counter, the true random number R is concatenated with the pre-embedded key and used as the input value of the digest function, and the first key is obtained after the digest function is operated; after obtaining the first key, a key derivation operation is performed: Increasing the value of the counter by one, and concatenating the value with the pre-buried key as an input value of the digest function, and obtaining the second key after the digest function is operated; The key derivation operation is performed in this way until the key of the integer multiple array is obtained; Based on the first key to the integer multiple array key, generate a key stream including all integer multiple array keys; Perform XOR calculations on the keys in the key stream and the corresponding grouped plaintext data to obtain the ciphertext data of the integer multiple array; Based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key, generating the integer multiple plus one group of ciphertext data, including: All ciphertext data in the integer multiple array are used as input values for hash calculation to obtain a fixed-length information summary value str; After the information digest value str is concatenated with the pre-buried key, the key of the integer multiple plus one group is derived as the input value of the digest function; Performing an XOR calculation on the key of the integer multiple plus a group and the true random number R to generate the ciphertext data of the integer multiple plus a group; All ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group are sent to the receiver as a whole encrypted data.
2. The method according to claim 1 further comprises decrypting the encrypted data by the receiving party, wherein: The true random number R is obtained as: Calculate the information digest value str2 of the ciphertext data of the first to the first integer multiple arrays based on the digest function, and after splicing the information digest value str2 with the pre-embedded key, derive the first integer multiple plus a group of keys as the input value of the digest function; The true random number R is obtained by performing an XOR calculation based on the key of the integer multiple plus a group and the ciphertext data of the integer multiple plus a group.
3. The method according to claim 2, further comprising decrypting the encrypted data by the receiving party, wherein: Decrypt all ciphertext data in the integer multiple array as follows: The true random number R is concatenated with the embedded key as the input value of the digest function, and the key stream is obtained after the digest function is operated. The key in the key stream and the corresponding all ciphertext data in the integer multiple array are XORed in turn to obtain all the plaintext data in the integer multiple array.
4. The method according to claim 2, further comprising decrypting the encrypted data by the receiving party, comprising: Concatenate all the plaintext data in the integer multiple array to obtain the original plaintext data.
5. An encryption system based on a digest function, the system comprising: The initial unit is used to expand the original plaintext data to be encrypted, and the length of the expanded plaintext data is an integer multiple of the key length of the digest function corresponding to the original plaintext data; A grouping unit, used to group the expanded plaintext data using an integer multiple as a grouping number, and obtain the grouped plaintext data; The first generating unit is used to obtain a key after performing a digest function operation based on a true random number R and a pre-buried key, and to generate a key stream including an integer multiple array key by performing a derivation operation on the obtained key, and is also used to: A true random number R is generated by a random number generator as the initial value of the counter, the true random number R is concatenated with the pre-embedded key and used as the input value of the digest function, and the first key is obtained after the digest function is operated; after obtaining the first key, a key derivation operation is performed: Increasing the value of the counter by one, and concatenating the value with the pre-buried key as an input value of the digest function, and obtaining the second key after the digest function is operated; The key derivation operation is performed in this way until the key of the integer multiple array is obtained; Based on the first key to the integer multiple array key, generate a key stream including all integer multiple array keys; An acquisition unit, used to perform XOR calculation on the key in the key stream and the corresponding grouped plaintext data respectively, to obtain the ciphertext data of the integer multiple array; The second generating unit is used to generate the ciphertext data of the integer multiple plus one group based on all the ciphertext data in the integer multiple array, the true random number R and the pre-embedded key, and is also used to: All ciphertext data in the integer multiple array are used as input values for hash calculation to obtain a fixed-length information summary value str; After the information digest value str is concatenated with the pre-buried key, the key of the integer multiple plus one group is derived as the input value of the digest function; Performing an XOR calculation on the key of the integer multiple plus a group and the true random number R to generate the ciphertext data of the integer multiple plus a group; The sending unit is used to send all the ciphertext data in the integer multiple array and the ciphertext data of the integer multiple plus one group as a whole encrypted data to the receiving party.
6. The system according to claim 5, further comprising a decryption unit for decrypting the encrypted data by the receiving party, wherein: The true random number R is obtained as: Calculate the information digest value str2 of the ciphertext data of the first to the first integer multiple arrays based on the digest function, and after splicing the information digest value str2 with the pre-embedded key, derive the first integer multiple plus a group of keys as the input value of the digest function; The true random number R is obtained by performing an XOR calculation based on the key of the integer multiple plus a group and the ciphertext data of the integer multiple plus a group.
7. The system according to claim 6, further comprising a decryption unit for decrypting the encrypted data by the receiving party, wherein: Decrypt all ciphertext data in the integer multiple array as follows: The true random number R is concatenated with the embedded key as the input value of the digest function, and the key stream is obtained after the digest function is operated. The key in the key stream and the corresponding all ciphertext data in the integer multiple array are XORed in turn to obtain all the plaintext data in the integer multiple array.
8. The system according to claim 6, further comprising a decryption unit, configured to decrypt the encrypted data by the receiving party, comprising: Concatenate all the plaintext data in the integer multiple array to obtain the original plaintext data.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 4.
10. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; wherein, The memory is a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method according to any one of claims 1 to 4.
