Encryption method and device of dynamic packet length, equipment and storage medium

By dynamically adjusting the block length and multiple rounds of iterative transformation encryption methods, the problem of low encryption efficiency of lightweight block cipher algorithms on resource-constrained devices is solved, and efficient encryption and security enhancement suitable for short data blocks are achieved. .

CN118869192AActive Publication Date: 2024-10-29BEIJING HAITAI FANGYUAN HIGH TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410894637.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-10-29
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

When existing lightweight block cipher algorithms encrypt plaintext data whose data length is less than the block length or does not meet the multiples of the block length, the encryption process is cumbersome and the data processing pressure is high, making it difficult to be suitable for resource-constrained micro-IoT devices.

Method used

The encryption method of dynamic packet length is adopted, the packet length is dynamically adjusted according to business needs, the data to be encrypted is divided into multiple plaintext packets, and is encrypted through multiple rounds of iterative transformations, and non-linear transformation is performed according to the parity of the packet length to avoid The hassle of using S-boxes adds to the complexity of encryption.

Benefits of technology

It improves data encryption efficiency, is suitable for encrypting shorter data blocks, avoids the trouble caused by the mismatch between fixed packet length and plain text data, and enhances the security of data encryption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118869192A_ABST
    Figure CN118869192A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of information security, and provides a dynamic packet length encryption method and device, equipment and a storage medium. The method comprises the following steps: dividing to-be-encrypted data according to a packet length set based on a service demand to obtain a plurality of plaintext packets; performing loop iteration transformation on each plaintext group, and taking a transformation result of the last round as a respective ciphertext group: performing nonlinear transformation on input data of each round according to parity of packet length to obtain a nonlinear transformation result of each round, the input data of the first round being obtained by preprocessing the plaintext group, the input data of the second round being obtained by preprocessing the plaintext group, and the input data of the third round being obtained by preprocessing the plaintext group; the input data of the non-first round is a transformation result output by the last round; and based on the round key of each round, scrambling the nonlinear transformation result to obtain a transformation result of each round. The packet length is dynamically adjusted according to the data length of the to-be-encrypted data, the method is suitable for encrypting short data blocks, and the trouble caused by the fact that the fixed packet length is not matched with the block size of plaintext data is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] With the rapid development of information technology, computer technology and microelectronics technology, the application of resource-constrained devices such as radio frequency identification technology, sensor networks and contactless smart cards is becoming more and more widespread. Traditional block cipher algorithms need to use complex mathematical operations and logical structures to achieve the best security under known circumstances, but this will also consume a lot of software and hardware resources, reduce the efficiency of data encryption and decryption, and is difficult to apply to resource-constrained devices such as micro IoT devices. If too simple a logical structure is used, it is difficult to ensure data security. Therefore, in order to protect the data transmitted and processed by these devices, lightweight block cipher algorithms came into being.

[0003] However, the block length of current lightweight block cipher algorithms is generally 32 bits (bit) or 64 bits. When the encrypted data length is less than the block length or the plaintext data does not meet the multiple of the block length, the encryption process is cumbersome and the data processing pressure is high. Summary of the invention

[0004] The embodiments of the present application provide an encryption method, apparatus, device and storage medium with a dynamic packet length, which is characterized in that the packet length can be changed at will to solve the encryption difficulty problem caused by the incompatibility between the fixed packet length and the data length of the plaintext data.

[0005] In a first aspect, an embodiment of the present application provides an encryption method for dynamic packet length, including:

[0006] Divide the data to be encrypted into multiple plaintext groups according to the group length set based on business requirements;

[0007] Perform multiple rounds of cyclic iterative transformation on each plaintext group, and use the transformation result of the last round as the corresponding ciphertext group, wherein the following operations are performed for one plaintext group: according to the parity of the group length, perform nonlinear transformation on the input data of each round to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of non-first round is the transformation result of the previous round; based on the round key of each round, scramble the nonlinear transformation result of each round to obtain the transformation result output of each round.

[0008] Optionally, performing a nonlinear transformation on the input data of each round according to the parity of the packet length to obtain a nonlinear transformation result of the round includes:

[0009] When the packet length is an odd number, based on the target transformation base determined by the packet length, the input data of each round is split into two candidate data segments, and the two candidate data segments are merged into the nonlinear transformation result of each round;

[0010] When the group length is an even number, the highest bit of the input data of each round is taken as a candidate data segment, and other candidate data segments are obtained based on the remaining N-1 bits of the input data of each round and the target transformation base, and multiple candidate data segments are merged into the nonlinear transformation result of each round, where N is the group length.

[0011] Optionally, the target transformation system determined based on the packet length, splitting the input data of each round into two candidate data segments, includes:

[0012] Performing a remainder operation on the input data of each round and a target conversion system determined based on the packet length, and using the remainder result as the first candidate data segment;

[0013] Performing an integer division operation on the input data of each round and the target transformation system, and using the integer division result as the second candidate data segment;

[0014] Based on a preset odd multiplier, a translation amount and the target transformation base, the first candidate data segment is converted into a third candidate data segment.

[0015] Optionally, the remaining N-1 bits of the input data of each round are converted into the target base, and split to obtain other candidate data segments, including:

[0016] Performing a modulo operation on the remaining N-1 bits of the input data of each round and the target conversion system, and using the modulo operation result as the fourth candidate data segment;

[0017] Performing an integer division operation on the remaining N-1 bits of the input data of each round and the target conversion system, and using the integer division result as the fifth candidate data segment;

[0018] Based on a preset odd multiplier, a translation amount and the target transformation base, the fourth candidate data segment is converted into a sixth candidate data segment.

[0019] Optionally, multiple round keys can be obtained by performing the following operations:

[0020] Recursively expand the original key sequence consisting of L original key bytes to obtain a target key sequence, where L is a positive integer greater than or equal to 8;

[0021] According to the preset round key length and the number of round keys, the target key sequence is segmented multiple times to obtain the multiple round keys.

[0022] Optionally, recursively expanding the original key sequence consisting of L original key bytes to obtain the target key sequence includes:

[0023] The following operations are cyclically performed on the original key sequence consisting of the L original key bytes to obtain a plurality of extended key bytes: byte transformation is performed on a plurality of ik original key bytes to obtain an i-th extended key byte, wherein i is a positive integer greater than or equal to L, and k is a positive integer less than or equal to L;

[0024] The L original key bytes are sequentially concatenated with a plurality of extended key bytes to obtain the target key sequence.

[0025] In a second aspect, an embodiment of the present application further provides an encryption device for dynamic packet length, comprising:

[0026] A length adjustment unit, used to divide the data to be encrypted into a plurality of plaintext packets according to the packet length set based on business requirements;

[0027] A data encryption unit is used to perform multiple rounds of cyclic iterative transformation on each plaintext group, and use the transformation result of the last round as the corresponding ciphertext group, wherein the following operations are performed for a plaintext group: according to the parity of the group length, nonlinear transformation is performed on the input data of each round to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of non-first round is the transformation result outputted in the previous round; based on the round key of each round, the nonlinear transformation result of each round is scrambled to obtain the transformation result outputted in each round.

[0028] Optionally, the data encryption unit is used to:

[0029] When the packet length is an odd number, based on the target transformation base determined by the packet length, the input data of each round is split into two candidate data segments, and the two candidate data segments are merged into the nonlinear transformation result of the round;

[0030] When the group length is an even number, the highest bit of the input data of each round is taken as a candidate data segment, and other candidate data segments are obtained based on the remaining N-1 bits of the input data of each round and the target transformation base, and multiple candidate data segments are merged into the nonlinear transformation result of each round, where N is the group length.

[0031] Optionally, the data encryption unit is used to:

[0032] Performing a remainder operation on the input data of each round and a target conversion system determined based on the packet length, and using the remainder result as the first candidate data segment;

[0033] Performing an integer division operation on the input data of each round and the target transformation system, and using the integer division result as the second candidate data segment;

[0034] Based on a preset odd multiplier, a translation amount and the target transformation base, the first candidate data segment is converted into a third candidate data segment.

[0035] Optionally, the data encryption unit is used to:

[0036] Performing a modulo operation on the remaining N-1 bits of the input data of each round and the target conversion system, and using the modulo operation result as the fourth candidate data segment;

[0037] Performing an integer division operation on the remaining N-1 bits of the input data of each round and the target conversion system, and using the integer division result as the fifth candidate data segment;

[0038] Based on a preset odd multiplier, a translation amount and the target transformation base, the fourth candidate data segment is converted into a sixth candidate data segment.

[0039] Optionally, the data encryption unit obtains multiple round keys by performing the following operations:

[0040] Recursively expand the original key sequence consisting of L original key bytes to obtain a target key sequence, where L is a positive integer greater than or equal to 8;

[0041] According to the preset round key length and the number of round keys, the target key sequence is segmented multiple times to obtain the multiple round keys.

[0042] Optionally, the data encryption unit is used to:

[0043] The following operations are cyclically performed on the original key sequence consisting of the L original key bytes to obtain a plurality of extended key bytes: byte transformation is performed on a plurality of ik original key bytes to obtain an i-th extended key byte, wherein i is a positive integer greater than or equal to L, and k is a positive integer less than or equal to L;

[0044] The L original key bytes are sequentially concatenated with a plurality of extended key bytes to obtain the target key sequence.

[0045] In a third aspect, an embodiment of the present application further provides a computer device, comprising a processor and a memory, wherein the memory stores a program code, and when the program code is executed by the processor, the processor executes the steps of any one of the above-mentioned dynamic packet length encryption methods.

[0046] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of any one of the above-mentioned dynamic packet length encryption methods.

[0047] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising computer instructions, wherein the computer instructions are executed by a processor to perform the steps of any one of the above-mentioned dynamic packet length encryption methods.

[0048] The beneficial effects of this application are as follows:

[0049] The embodiments of the present application provide an encryption method, apparatus, device and storage medium for dynamic group length, the method comprising: dividing the data to be encrypted into multiple plaintext groups according to the group length set based on business requirements; performing multiple rounds of cyclic iterative transformation on each plaintext group, and using the transformation result output by the last round as the corresponding ciphertext group; performing nonlinear transformation on the input data of each round according to the parity of the group length to obtain the nonlinear transformation result of the round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of non-first round is the transformation result output by the previous round; based on the round key of each round, the nonlinear transformation result is scrambled to obtain the transformation result of each round.

[0050] The packet length is dynamically adjusted according to the data length of the data to be encrypted, and the packet length of the plaintext packet is reasonably set. It is suitable for encrypting shorter data blocks, shortening the encryption processing time, improving the data encryption efficiency, and facilitating the encryption of special types of data in a reserved format, which can avoid the trouble caused by the mismatch between the fixed packet length and the block size of the plaintext data. In addition, according to the parity of the packet length, nonlinear transformation of the input data is realized based on multiple modular remainder representations, and the S box (or permutation table) can be omitted, avoiding the trouble of setting and storing the S box, which also increases the complexity of data encryption and further ensures the security of data encryption.

[0051] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0053] Figure 1A A schematic diagram of a process for performing group encryption of encrypted data provided in an embodiment of the present application;

[0054] Figure 1B A schematic diagram of a process for performing cyclic iterative encryption on a plaintext group provided in an embodiment of the present application;

[0055] Figure 1C A schematic diagram of a flow chart of performing nonlinear transformation on input data of each round when the packet length is an odd number provided in an embodiment of the present application;

[0056] Figure 1D A schematic diagram of a flow chart of performing nonlinear transformation on input data of each round when the packet length is an even number provided in an embodiment of the present application;

[0057] Figure 2 A schematic diagram of a complete process of encrypting data using an encryption method using dynamic packet length provided in an embodiment of the present application;

[0058] Figure 3 A schematic diagram of the structure of a dynamic packet length encryption device provided in an embodiment of the present application;

[0059] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present application;

[0060] Figure 5 Schematic diagram of the structure of a computing device in an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.

[0062] Some terms in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0063] 1. Data encryption is to convert information that can be read, understood and recognized by humans or machines (such information can be voice, text, images and symbols, etc.) into information that is obscure or deviates from the original meaning of the information through certain methods, so as to achieve the purpose of ensuring information security. In order to facilitate the understanding of technicians in this field, the following introduces several terms related to the concept of data encryption.

[0064] (1) Plain text: Information that is easily read and understood by humans or machines is called plain text. Plain text can be text, digitized voice stream, or digitized video information.

[0065] (2) Ciphertext: Information data converted from plaintext into obscure data through data encryption is called ciphertext.

[0066] (3) The process of converting plaintext into ciphertext is called encryption, and the process of converting ciphertext into plaintext is called decryption. The decryption process is the inverse process of the encryption process.

[0067] (4) Key: The same parameter or two different but related parameters are referenced during encryption and decryption. This parameter is called a key. The key used during encryption is the encryption key, and the key used during decryption is the decryption key.

[0068] 2. According to the method of data encryption, cryptographic technology can be divided into symmetric encryption technology and asymmetric encryption technology.

[0069] (1) Symmetric encryption technology: The encryption and decryption processes of this technology use the same key, or use two keys that can be deduced from each other. That is, a simple operation is performed on one key to deduce the other key.

[0070] Symmetric encryption technology has the advantages of open algorithm, small amount of calculation, fast encryption speed and high encryption efficiency, so it is usually used when the sender needs to encrypt a large amount of data. However, symmetric encryption technology also has obvious disadvantages: before data transmission, the sender and the receiver must agree on the key, and both parties keep the key separately. If the key of one party is accidentally leaked, the security of data encryption cannot be guaranteed.

[0071] (2) Asymmetric encryption technology: The encryption process and decryption process of this technology use a pair of different but related keys. The encryption key is public, while the decryption key is kept confidential. The decryption key cannot be derived from the encryption key. Even if the attacker knows the encryption key, he cannot crack the ciphertext.

[0072] 3. Block cipher algorithm is a type of symmetric encryption technology. It uses a fixed-length key to encrypt a fixed-length plaintext block to obtain a ciphertext block of the same length. Currently, the commonly used key length and block length are usually 64 bits, 128 bits, 256 bits, etc.

[0073] The following is a brief introduction to the design concept of the embodiment of the present application:

[0074] With the rapid development of information technology, computer technology and microelectronics technology, the application of resource-constrained devices such as radio frequency identification technology, sensor networks and contactless smart cards is becoming more and more widespread. Traditional block cipher algorithms need to use complex mathematical operations and logical structures to achieve the best security under known circumstances, but this will also consume a lot of software and hardware resources, reduce the efficiency of data encryption and decryption, and is difficult to apply to resource-constrained devices such as micro IoT devices. If too simple a logical structure is used, it is difficult to ensure data security. Therefore, in order to protect the data transmitted and processed by these devices, lightweight block cipher algorithms came into being.

[0075] However, the block length of the current lightweight block cipher algorithm is generally 32 bits or 64 bits. When the encrypted data length is less than the block length or the plaintext data does not meet the multiple of the block length, the encryption process is cumbersome and the data processing pressure is high.

[0076] In view of this, in order to solve the above problems, the embodiment of the present application provides an encryption method with a dynamic packet length that is smaller and can arbitrarily select the packet length. The method includes: dividing the data to be encrypted into multiple plaintext packets according to the packet length set based on business needs; performing multiple rounds of cyclic iterative transformation on each plaintext packet, and taking each transformation result output by the last round as the corresponding ciphertext packet: performing nonlinear transformation on the input data of each round according to the parity of the packet length to obtain the nonlinear transformation result of the round, wherein the input data of the first round is obtained by preprocessing the plaintext packet, and the input data of the non-first round is the transformation result output by the previous round; based on the round key of each round, the nonlinear transformation result is scrambled to obtain the linear transformation result of each round.

[0077] If necessary, the packet length can be dynamically adjusted according to the data length of the data to be encrypted, and the packet length of the plaintext packet can be reasonably set, which is suitable for encrypting shorter data blocks, shortening the encryption processing time, improving the data encryption efficiency, and facilitating the encryption of special types of data in a reserved format, which can avoid the trouble caused by the mismatch between the fixed packet length and the block size of the plaintext data. Secondly, according to the parity of the packet length, the nonlinear transformation of the initial ciphertext can be realized based on a variety of modular remainder representations, and the S box (or permutation table) can be omitted, which can avoid the trouble of setting and storing the S box, increase the complexity of data encryption, and further ensure the security of data encryption.

[0078] like Figure 1A As shown, the process of encrypting data using the method provided in the embodiment of the present application is as follows:

[0079] S101: Divide the data to be encrypted into a plurality of plaintext groups according to the group length set based on business requirements.

[0080] At present, the packet length of lightweight block cipher algorithms is generally 32 bits or 64 bits. When the encrypted data length is less than the packet length or the plaintext data does not meet the multiple of the packet length, the encryption process is cumbersome and the data processing pressure is high. Therefore, for the plaintext data whose encrypted data length is less than the packet length, or the plaintext data that does not meet the multiple of the packet length, or the special type of data that needs to retain a certain data format, the packet length can be set according to business needs, and then the data to be encrypted can be divided into multiple plaintext packets of the same length based on the packet length as the division standard.

[0081] For example, the packet length can be set reasonably according to the data length of the plaintext data. If the data length of the divided plaintext packet is still less than the packet length, the data spaces in the packet can be filled with zeros so that the data length after filling is equal to the packet length.

[0082] If the packet length is greater than 32 bits, the encryption process may be slightly cumbersome due to the limitation of computer word length, which will affect the lightweight packet encryption effect. More importantly, the packet length of 33 to 63 bits is not practical. If the packet length is less than 6 bits, the plaintext space of a plaintext packet divided according to the packet length is too small, and the amount of data in the encrypted ciphertext packet is also small, which is easy to be cracked by attackers, making it difficult to ensure the security of data encryption. Therefore, the implementation method proposed in this application controls the packet length value range between 6-32 bits, and determines the packet length from 6-32 bits according to the data length of the data to be encrypted. It has certain practicality and is easy to implement lightweight encryption.

[0083] S102: Perform multiple rounds of cyclic iterative transformation on each plaintext group, and use the transformation result of the last round as the corresponding ciphertext group, wherein the following operations are performed for one plaintext group: according to the parity of the group length, perform nonlinear transformation on the input data of each round to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of non-first round is the transformation result outputted by the previous round; based on the round key of each round, scramble the nonlinear transformation result of each round to obtain the linear transformation result of each round.

[0084] Perform the same operation on each plaintext group. For the sake of convenience, take a plaintext group as an example. Figure 1B The flowchart shown introduces the process of performing multiple rounds of iterative transformation.

[0085] S1021: Perform white noise conversion on a plaintext group to obtain the first round of input data.

[0086] Specifically, as shown in Formula 1, a plaintext group x is XORed with the round key RK0 of the 0th round to obtain the input data x0 of the first round.

[0087]

[0088] S1022: Perform nonlinear transformation on each round of input data according to the parity of the packet length to obtain a nonlinear transformation result of each round.

[0089] According to the parity of the packet length, multiple rules are called to interact and apply reversible nonlinear transformation to the input data to eliminate or weaken the correlation between the output data and the input data, further ensuring the security of data encryption.

[0090] (1) When the packet length is an odd number, execute Figure 1C Steps shown:

[0091] S10221: Split each round of input data into two candidate data segments based on the target transformation base determined by the packet length.

[0092] First, when the packet length N is an odd number, based on the formula M=92 N +1) / 3, determine the corresponding target conversion system M, and appropriately select the odd multiplier A and translation B that are coprime with the target conversion system M.

[0093] For example, when N=15, M=92 15 +1) / 3=10923, we can choose an odd multiplier A=125 which is relatively prime to 10923, and the translation B=7. It can be proved that when N is an odd number, 2 N +1 is a multiple of 3, M = (2 N +1) / 3 is relatively prime to 5, so the power of 5 is always relatively prime to M, so we can choose a power of 5 as the multiplier A.

[0094] Secondly, when the packet length is an odd number, as shown in Formula 2, for the input data x of the jth round j A modulo operation is performed with the target conversion system M determined based on the packet length, and the modulo result is used as the first candidate data segment y0, where j is a positive integer.

[0095] y0=x j mod M formula 2;

[0096] Again, as shown in Formula 3, for the input data x of the jth round j Perform an integer division operation on the target conversion system M, and use the integer division result as the second candidate data segment y1.

[0097] y1=x j / M Formula 3;

[0098] Finally, as shown in Formula 4, the first candidate data segment is converted into a third candidate data segment based on the preset odd multiplier A, the translation amount B and the target transformation system M. Thus, the input data of the jth round is split into (z0, y1).

[0099] z0=Ay0+Bmod M Formula 4;

[0100] S10222: Merge the two candidate data segments into the nonlinear transformation result of each round.

[0101] Based on the formula y=3z0+y1, the two candidate data segments (z0, y1) are merged into the j-th round of nonlinear transformation result y, realizing the transformation from the input data x j A nonlinear transformation between the nonlinear transformation result y.

[0102] (2) When the packet length is an even number, execute Figure 1D Steps shown:

[0103] S10221': The highest bit of each round of input data is taken as a candidate data segment, and based on the lowest bit of each round of input data and the target conversion system, other candidate data segments are obtained by splitting, where N is the group length.

[0104] First, when the packet length N is an odd number, based on the formula M=(2 N-1 +1) / 3, determine the corresponding target conversion system M, and appropriately select an odd multiplier A and a translation amount B that are relatively prime to the target conversion system M. For example, when the packet length N is an even number, assuming N = 10, based on the formula M = (2 N-1 +1) / 3=171, determine the corresponding target conversion base M, and A=125 can still be taken.

[0105] Secondly, when the group length is an even number, the highest bit of the input data of each round is recorded as the seventh candidate data segment y7. As shown in Formula 5, the N-1th bit s0 of the input data of the jth round is modulo the target conversion system M, and the modulo result is used as the fourth candidate data segment y4.

[0106] y4=s0 mod M formula 5;

[0107] Again, as shown in Formula 6, an integer division operation is performed on the N-1th bit s0 of the input data of each round and the target conversion system M, and the integer division result is used as the fifth candidate data segment y4.

[0108] y5=s0 / M Formula 6;

[0109] Finally, as shown in Formula 7, based on the preset odd multiplier A, the translation amount B and the target transformation system M, the fourth candidate data segment y4 is converted into the sixth candidate data segment y6. j Split into (z1,y5,y7).

[0110] z1=Ay4+Bmod M Formula 7;

[0111] S10222': Combine multiple candidate data segments into the transformed ciphertext of each round.

[0112] Based on the formula y=2(3z1+y5)+y7, multiple candidate data segments (z1, y5, y7) are merged into the j-th round of nonlinear transformation result y, realizing the transformation from input data x j A nonlinear transformation between the nonlinear transformation result y.

[0113] S1023: Based on the round key of each round, scramble the nonlinear transformation result of each round to obtain the transformation result outputted in each round.

[0114] Specifically, as shown in Formula 8, the transformed ciphertext y of the jth round and the round key RK of the jth round are j Perform XOR operation to obtain the transformation result of the jth round, that is, the input data x of the j+1th round j+1 .

[0115]

[0116] S1024: Determine whether the set iteration rounds have been reached. If so, use the transformation results output in the last round as the corresponding ciphertext groups; otherwise, return to step 1022.

[0117] Before encrypting data, in addition to setting the group length and determining other related parameters based on the preset group length, the original key sequence consisting of L original key bytes must be recursively expanded to obtain a target key sequence, where L is a positive integer greater than or equal to 8; then the target key sequence is segmented multiple times according to the preset round key length and number of round keys to obtain multiple round keys.

[0118] The specific implementation process of recursive expansion is as follows:

[0119] The following operations are performed cyclically on the original key sequence consisting of L original key bytes to obtain multiple extended key bytes: byte transformation is performed on multiple ij original key bytes to obtain the i-th extended key byte, where i is a positive integer greater than or equal to L, and j is a positive integer less than or equal to L.

[0120] Then, the L original key bytes are sequentially concatenated with multiple extended key bytes to obtain a target key sequence.

[0121] For example, as shown in Formula 9, the following operations are performed to obtain the i-th key byte: first, a function operation is performed on the i-1th key byte, the i-4th key byte, and the i-6th key byte to obtain a first transformed value; secondly, a function operation is performed on the i-2th key byte, the i-3rd key byte, and the i-5th key byte to obtain a second transformed value; finally, based on the iLth key byte and the two transformed values, the i-th key byte is obtained.

[0122] Ri =RK i-L +F(RK i-1 ,RK i-4 ,RK i-6 )+F(RK i-2 ,RK i-3 ,RK i-5 )mod 256(i=L,L+1,L+2,……) Formula 9;

[0123] in, (C<<<5)). Here It means taking the complement of A, (B<<<2) means B is circularly shifted left by 2 bits, (C<<<5) means C is circularly shifted left by 5 bits, ∩ means taking the intersection, and ∪ means taking the union.

[0124] For example, A=01110001,B=00110101,C=11010110,then (A<<<2)=11010100, (C<<<5)=11011010, then, F(A,B,C)=11011110.

[0125] Since the steps performed to obtain the first transformation value and the second transformation value are the same, taking the first transformation value as an example, the i-1th key byte is inverted to obtain the inverted code of the i-1th key byte, and the i-4th key byte and the i-6th key byte are cyclically shifted to obtain the shifted key bytes respectively; then, based on the i-1th inverted key byte and the shifted key bytes, a new key byte is generated.

[0126] The encryption method provided in the embodiment of the present application dynamically adjusts the packet length according to the data length of the data to be encrypted, reasonably sets the packet length of the plaintext packet, is suitable for encrypting shorter data blocks, shortens the encryption processing time, improves the data encryption efficiency, and is easy to implement format-preserving encryption of special types of data, which can avoid the trouble caused by the incompatibility between the fixed packet length and the block size of the plaintext data. In addition, according to the parity of the packet length, nonlinear transformation of the input data is achieved based on multiple modular remainder representations, and the S-box (or permutation table) can be omitted, avoiding the trouble of setting and storing the S-box, which also increases the complexity of data encryption and further ensures the security of data encryption. In order to facilitate the understanding of those skilled in the art, Figure 2 The complete process of encrypting data using the dynamic packet length encryption method is shown.

[0127] S201: Setting the block length according to the data length of the data to be encrypted, and then determining the target transformation mechanism based on the block length, and determining an odd-numbered multiplier and a translation amount that are relatively prime to the target transformation system.

[0128] S202: Divide the data to be encrypted into a plurality of plaintext groups according to the group length.

[0129] S203: Perform multiple rounds of iterative encryption for each plaintext group, and use the transformation results of the last round as their respective ciphertext groups, wherein the following operations are performed for one plaintext group: according to the parity of the group length, a nonlinear transformation is performed on the input data of each round through split transformation and merge transformation to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of non-first round is the transformation result outputted by the previous round; based on the round key of each round, the nonlinear transformation result of each round is scrambled to obtain the transformation result outputted by each round.

[0130] For example, when N=15, we select M=(2 15 +1) / 3=10923, A=125, B=7. Assume that the five round keys expressed in hexadecimal have been recursively obtained as follows: RK0=0x140f, RK1=0x2bab, RK2=0x31d7, RK3=0c0b41, RK4=0x5ea2. Then, a number between 0 and 32767 can be encrypted through 4 rounds of iterations. For example, if the plaintext data 2 (i.e. 2=0x0002) needs to be encrypted, the steps are as follows:

[0131] In the first step, the plaintext 0x0002 is XORed with RK0=0x140f to obtain the preprocessed plaintext 0x0002^0x140f=0x140d.

[0132] Step 2: Start the first round of transformation and split 0x140d into (0, 0x140d) according to 0x140d=0×M+0x140d. Calculate 0x140d×A+B mod 2 15 =0x140d×125+7mod 2 15 =0x1fa2. Combine 0x1fa2 and 0 to get 0x1fa2×3+0mod 2 15 = 0x5ee6, and finally 0x5ee6 is XORed with the round key RK1 = 0x2bab to obtain 0x5ee6⊕0x2bab=0x754d, where the symbol “⊕” represents XOR operation. Thus, 0x754d is the transformation result output after the first round.

[0133] Step 3: Start the second round of transformation, split 0x754d into (2, 0x1ff7) according to 0x754d=2×M+0x1ff7. Calculate 0x1ff7×A+B mod 2 15 =0x1ff7×125+7mod 2 15= 0x1b83. Combine 0x1b83 and 2 to get 0x1b83×3+2mod 2 15 = 0x528b, and finally XOR 0x528b with the round key RK2 = 0x31d7 to get 0x528b⊕0x31d7 = 0x635c. In this way, 0x635c is the transformation result output after the second round.

[0134] Step 4: Start the third round of transformation, according to 0x635c=2×M+0x0e06, split into (2, 0x0e06). Calculate 0x0e06×A+B mod 2 15 =0x0392. After merging, we get 0x0392×3+2mod 2 15 = 0x0ab8, XOR 0x0ab8 with round key RK3 = 0x0b41 to get 0x0ab8⊕0x0b41 = 0x01f9. Thus, 0x01f9 is the transformation result output after the third round.

[0135] Step 5: Start the fourth round of transformation, according to 0x01f9=0×M+0x01f9, split into (0, 0x01f9). Calculate 0x01f9×A+B mod 2 15 =0x2145. After merging, we get 0x2145×3+0mod 2 15 = 0x63cf, XOR 0x63cf with round key RK4 = 0x5ea2 to get 0x63cf⊕0x5ea2 = 0x3d6d. In this way, 0x3d6d is the final ciphertext block.

[0136] When decrypting, the ciphertext 0x3d6d is XORed with the round key RK4=0x5ea2 to get 0x63cf. By dividing 0x63cf by 3 and adding modulo 3, we get 0x2145 and 0. Since 125×1136≡1mod 2 15 , calculate 0x2145-1136×7mod 2 15 =0x2145-7952 mod 2 15 =0x01f9. Combining 0x01f9 with 0, we get 0×M+0x01f9=0x01f9. Thus, 0x01f9 is the input of the fourth round and the output of the third round. Similarly, 0x01f9 can be used to deduce the input of the third round 0x635c, and 0x635c can be used to deduce the input of the second round 0x754d and the input of the first round 0x140d. XOR 0x140d with the round key RK0=0x140f to get the plaintext 0x0002=2.

[0137] Based on the same inventive concept as the above method embodiment, the present application embodiment also provides an encryption device for dynamic packet length. Figure 3As shown, the dynamic packet length encryption device 300 may include:

[0138] The length adjustment unit 301 is used to divide the data to be encrypted into a plurality of plaintext packets according to the packet length set based on the service requirements;

[0139] The data encryption unit 302 is used to perform multiple rounds of cyclic iterative transformation on each plaintext group, and use the transformation result of the last round as the corresponding ciphertext group, wherein the following operations are performed for a plaintext group: according to the parity of the group length, the input data of each round is nonlinearly transformed to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing a plaintext group, and the input data of non-first round is the transformation result outputted by the previous round; based on the round key of each round, the nonlinear transformation result of each round is scrambled to obtain the transformation result outputted by each round.

[0140] Optionally, the data encryption unit 302 is used to:

[0141] When the packet length is an odd number, the input data of each round is split into two candidate data segments based on the target transformation base determined by the packet length, and the two candidate data segments are merged into the nonlinear transformation result of the round;

[0142] When the group length is an even number, the highest bit of the input data of each round is taken as a candidate data segment, and other candidate data segments are split based on the remaining N-1 bits of the input data of each round and the target transformation base, and multiple candidate data segments are merged into the nonlinear transformation result of each round, where N is the group length.

[0143] Optionally, the data encryption unit 302 is used to:

[0144] Performing a remainder operation on the input data of each round and the target conversion system determined based on the packet length, and using the remainder result as the first candidate data segment;

[0145] Perform integer division operation on the input data of each round and the target transformation system, and use the integer division result as the second candidate data segment;

[0146] Based on a preset odd multiplier, a translation amount, and a target transformation base, the first candidate data segment is converted into a third candidate data segment.

[0147] Optionally, the data encryption unit 302 is used to:

[0148] Perform a modulo operation on the remaining N-1 bits of the input data of each round and the target conversion system, and use the modulo result as the fourth candidate data segment;

[0149] Perform integer division operation on the remaining N-1 bits of the input data of each round and the target conversion system, and use the integer division result as the fifth candidate data segment;

[0150] Based on a preset odd multiplier, a translation amount, and a target transformation base, the fourth candidate data segment is converted into a sixth candidate data segment.

[0151] Optionally, the data encryption unit 302 obtains multiple round keys by performing the following operations:

[0152] Recursively expand the original key sequence consisting of L original key bytes to obtain a target key sequence, where L is a positive integer greater than or equal to 8;

[0153] According to the preset round key length and the number of round keys, the target key sequence is segmented multiple times to obtain multiple round keys.

[0154] Optionally, the data encryption unit 302 is used to:

[0155] The following operations are cyclically performed on an original key sequence consisting of L original key bytes to obtain a plurality of extended key bytes: byte transformation is performed on a plurality of ik original key bytes to obtain an i-th extended key byte, wherein i is a positive integer greater than or equal to L, and k is a positive integer less than or equal to L;

[0156] The L original key bytes are sequentially concatenated with multiple extended key bytes to obtain a target key sequence.

[0157] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.

[0158] After introducing the encryption method and apparatus for dynamic packet length according to an exemplary embodiment of the present application, next, a computer device according to another exemplary embodiment of the present application is introduced.

[0159] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.

[0160] Based on the same inventive concept as the above method embodiment, the present application embodiment also provides a computer device, see Figure 4As shown, the computer device 400 may include at least a processor 401 and a memory 402. The memory 402 stores program codes, and when the program codes are executed by the processor 401, the processor 401 executes the steps of any one of the above-mentioned dynamic packet length encryption methods.

[0161] In some possible implementations, the computing device according to the present application may include at least one processor and at least one memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the encryption method of dynamic packet length according to various exemplary implementations of the present application described above in this specification. For example, the processor may execute the following steps: Figure 1A Follow the steps shown in .

[0162] Refer to the following Figure 5 hereinafter, a computing device 500 according to this embodiment of the present application is described. Figure 5 The computing device 500 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0163] like Figure 5 As shown, the computing device 500 is in the form of a general computing device. The components of the computing device 500 may include but are not limited to: at least one processing unit 501, at least one storage unit 502, and a bus 503 connecting different system components (including the storage unit 502 and the processing unit 501).

[0164] Bus 503 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0165] The storage unit 502 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 5021 and / or a cache memory unit 5022 , and may further include a read-only memory (ROM) 5023 .

[0166] The storage unit 502 may also include a program / utility 5025 having a set (at least one) of program modules 5024, such program modules 5024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0167] The computing device 500 may also communicate with one or more external devices 504 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the computing device 500, and / or communicate with any device that enables the computing device 500 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 505. In addition, the computing device 500 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 506. As shown, the network adapter 506 communicates with other modules for the computing device 500 via a bus 503. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computing device 500, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0168] Based on the same inventive concept as the above method embodiment, various aspects of the dynamic packet length encryption method provided by the present application can also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the dynamic packet length encryption method according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device can execute the following steps: Figure 1A Follow the steps shown in .

[0169] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0170] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional 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 falling within the scope of the present application.

[0171] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A dynamic packet length encryption method, characterized in that: include: Divide the data to be encrypted into multiple plaintext groups according to the group length set based on business requirements; Perform multiple rounds of cyclic iterative transformation on each plaintext group, and use the transformation result of the last round as the corresponding ciphertext group, wherein the following operations are performed for one plaintext group: according to the parity of the group length, perform nonlinear transformation on the input data of each round to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of non-first round is the transformation result outputted in the previous round; based on the round key of each round, scramble the nonlinear transformation result of each round to obtain the transformation result outputted in each round.

2. The method according to claim 1, characterized in that The step of performing nonlinear transformation on each round of input data according to the parity of the packet length to obtain each round of nonlinear transformation results includes: When the packet length is an odd number, based on the target transformation base determined by the packet length, the input data of each round is split into two candidate data segments, and the two candidate data segments are merged into the nonlinear transformation result of each round; When the group length is an even number, the highest bit of the input data of each round is taken as a candidate data segment, and other candidate data segments are split based on the remaining N-1 bits of the input data of each round and the target transformation base, and multiple candidate data segments are merged into the nonlinear transformation result of each round, where N is the group length.

3. The method according to claim 2, characterized in that The target transformation system determined based on the packet length, splitting the input data of each round into two candidate data segments, comprises: Performing a remainder operation on the input data of each round and a target conversion system determined based on the packet length, and using the remainder result as the first candidate data segment; Performing an integer division operation on the input data of each round and the target transformation system, and using the integer division result as the second candidate data segment; Based on a preset odd multiplier, a translation amount and the target transformation base, the first candidate data segment is converted into a third candidate data segment.

4. The method according to claim 2, characterized in that The remaining N-1 bits of the input data of each round are converted into the target system, and the other candidate data segments are obtained by splitting, including: Performing a modulo operation on the remaining N-1 bits of the input data of each round and the target conversion system, and using the modulo operation result as the fourth candidate data segment; Performing an integer division operation on the remaining N-1 bits of the input data of each round and the target conversion system, and using the integer division result as the fifth candidate data segment; Based on a preset odd multiplier, a translation amount and the target transformation base, the fourth candidate data segment is converted into a sixth candidate data segment.

5. The method according to any one of claims 1 to 4, characterized in that: Multiple round keys are obtained by performing the following operations: Recursively expand the original key sequence consisting of L original key bytes to obtain a target key sequence, where L is a positive integer greater than or equal to 8; According to the preset round key length and the number of round keys, the target key sequence is segmented multiple times to obtain the multiple round keys.

6. The method according to claim 5, characterized in that The recursive expansion of the original key sequence consisting of L original key bytes to obtain the target key sequence includes: The following operations are cyclically performed on the original key sequence consisting of the L original key bytes to obtain a plurality of extended key bytes: byte transformation is performed on a plurality of ik original key bytes to obtain an i-th extended key byte, wherein i is a positive integer greater than or equal to L, and k is a positive integer less than or equal to L; The L original key bytes are sequentially concatenated with a plurality of extended key bytes to obtain the target key sequence.

7. A dynamic packet length encryption device, characterized in that: include: A length adjustment unit, used to divide the data to be encrypted into a plurality of plaintext packets according to the packet length set based on business requirements; The data encryption unit is used to perform multiple rounds of cyclic iterative transformation on each plaintext group, and use the transformation result of the last round as the respective ciphertext group, wherein the following operations are performed on a plaintext group: according to the parity of the group length, nonlinear transformation is performed on the input data of each round to obtain the nonlinear transformation result of each round, wherein the input data of the first round is obtained by preprocessing the plaintext group, and the input data of the non-first round is the transformation result outputted in the previous round; based on the round key of each round, the nonlinear transformation result of each round is scrambled to obtain the transformation result outputted in each round.

8. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: It includes program codes. When the program codes are run on a computer device, the program codes are used to enable the computer device to execute the steps of the method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Lightweight block cipher GFCS implementation method and device and readable storage medium

    CN112202547A

  • Lightweight block cipher implementation method and system of novel PSP structure

    CN116647328A

  • Data encryption and decryption

    US20140298006A1