A new dynamic block cipher HFSP encryption and decryption consistent encryption and decryption implementation method

CN116743352BActive Publication Date: 2026-08-21HENGYANG NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310437143.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-21
Publication Date
2026-08-21
Estimated Expiration
2043-04-21

AI Technical Summary

Technical Problem

对于传统的Feistel网络结构密码,每次只有一部分经过混淆和扩散,以至于要经过两轮的变换才能使得每一位都发生变换,而SP网络结构密码只需要一轮,所有的位都发生了变化,但是解密时需要对每个部件进行求逆,消耗了额外的硬件资源

Benefits of technology

[0044]The technical advantage of this invention lies in its design of a novel cryptographic structure, FRX, which is a different type of cryptographic structure from the three major mainstream cryptographic structures, achieving consistent encryption and decryption. The key to this consistency lies in the symmetrical structure of the upper and lower parts of the FRX, where the initial permutation and initial inverse permutation in the PSP structure do not cancel each other out. The S-box used also achieves cryptographic properties, ensuring the security of the algorithm. The dynamic key arrangement section employs random number XOR operations related to the round counter, as well as round-specific operations for prime and composite rounds, to dynamically generate subkeys. This significantly reduces the linear correlation between keys in each round, improving algorithm security and reducing the hardware implementation area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116743352B_ABST
    Figure CN116743352B_ABST
Patent Text Reader

Abstract

The application discloses a new dynamic grouping cipher HFSP encryption and decryption implementation method with consistent encryption and decryption, and comprises the following steps: obtaining to-be-encrypted data and an initial key, and performing each round of operation from the 0th round to the last 1st round, wherein each round of operation comprises FRX structure transformation and key arrangement operation. The application associates the key arrangement part with a prime number and a linear congruence equation, performs different operations on the prime number round and the composite number round respectively, so that the effect of dynamic key generation is achieved, meanwhile, the FRX structure can solve the problem that the traditional SPN structure cannot be consistent in encryption and decryption, so that the algorithm can be quickly realized in software, and the key presents a dynamic form in the whole encryption process. In addition, the new algorithm structure and the key arrangement construction method not only reduce the consumption of hardware resources in the decryption process of the algorithm, but also improve the security of the algorithm by hiding the relationship between the keys.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of information security encryption technology, specifically relating to a novel dynamic block cipher HFSP encryption and decryption implementation method that ensures consistent encryption and decryption. Background Technology

[0002] With the rapid development of computer and network technologies, the demand for comprehensive network security solutions in the informatization construction of various industries is constantly increasing, and symmetric cryptography has become the core foundation for building secure information systems. Block ciphers, as an important branch of symmetric encryption, play an extremely important role in information security and have always been a research hotspot. The design of block ciphers has also consistently followed the "confusion" and "diffusion" principles proposed by Shannon.

[0003] Since the introduction of linear attacks and correlated key attacks, cryptographic algorithms have employed various methods to resist these two types of attacks. Their core ideas can be broadly categorized into two types: The first type uses the linear approximation of block ciphers to achieve key recovery attacks, which are known-plaintext attacks. Using a linear discriminator, this can be transformed into a key recovery attack against an r-round cipher. Guided by this principle, algorithms must carefully select complex key arrangement operations and closely related encryption function operations. Furthermore, key arrangement, as a crucial component of modern cryptographic algorithms, requires the selection of keys with low linear probability, which are then XORed with the plaintext during the encryption process to reduce the algorithm's linear correlation.

[0004] Another type of attack occurs when the attacker does not know the key, but can choose other keys with a specific relationship to the current key and access the plaintext and ciphertext encrypted by the original key and its related keys. By exploiting weaknesses in the key arrangement scheme and choosing appropriate key relationships, the attacker can obtain the association between the cryptographic algorithms corresponding to the original key and its related keys, thus recovering the original key. If the key arrangement scheme has a high degree of nonlinearity, the master key differential that satisfies the differential chain requirement may be unknown, which increases the difficulty of the attack. Therefore, both linear and related key attacks require specific analysis of the key arrangement. Thus, this type of cryptographic algorithm can resist linear and related key attacks by employing complex key arrangement schemes.

[0005] In block cipher algorithms, there are three cryptographic structures: Feistel network structure, SP network structure, and Lai-Massey network structure. Among these three, Feistel and SP network structures are the two most commonly used. However, SP network block ciphers have gained favor among block cipher designers because they can achieve confusion and diffusion much faster than Feistel network block ciphers. Traditional Feistel network ciphers only involve a portion of the data being confused and diffused at a time, requiring two rounds of transformation to change every bit. SP network ciphers, on the other hand, only require one round, changing all bits. However, decryption requires inverting each component, consuming additional hardware resources. Summary of the Invention

[0006] The purpose of this invention is to provide a novel dynamic block cipher (HFSP) that ensures consistent encryption and decryption. By increasing the complexity of key arrangement—specifically, by determining whether the round number is prime and generating subkeys using two different methods—the key maintains a dynamic form throughout the encryption process, thereby increasing the overall security of the algorithm. Furthermore, by constructing a consistent encryption / decryption algorithm structure (FRX), not only can all bits be changed in a single round, but the hardware resource consumption of the algorithm is also reduced. In HFSP, H represents the operational structure similar to the letter H, and F refers to the FRX structure used in this invention (FRX is an abbreviation for F function, rotation, and bitwise XOR). SP in HFSP refers to the S-box and P-permutation operations included in the FRX structure.

[0007] To achieve the above-mentioned technical objectives, the technical solution of the present invention is as follows:

[0008] A novel encryption implementation method for the dynamic block cipher HFSP with consistent encryption and decryption includes the following steps:

[0009] Step 1: Set a 128-bit key (Key) and perform a shift operation to obtain k. a .

[0010] Step 2: Based on the current iteration round number, adjust k... a Two different round-robin operations are performed. The first round-robin operation is: [The text abruptly ends here, likely due to an incomplete sentence or a formatting error.] a Perform S-box replacement to obtain 128-bit data ks, and then perform P-permutation on ks to obtain key.

[0011] The second type of round-robin operation is: k aPerform S-box replacement to obtain 128-bit data `ks`. Then, depending on whether the current iteration round number is greater than a preset value, perform two different sub-round operations: If it is not greater than the preset value, the sub-round operation is: XOR `ks` with the number of the current iteration round to obtain `kx`. If it is greater than the preset value, the sub-round operation is: XOR `ks` with the generated number `X` to obtain `kx`. Finally, perform P-permutation on `kx` to obtain `key`.

[0012] Then save the key and use the key as the k. a This key is used for the next iteration, and then used as the key in the current iteration.

[0013] Step 3: Based on the key, the 64-bit plaintext to be encrypted is sequentially subjected to FRX structure transformations, including high-round key XOR, first circular shift, first round constant XOR, F function, second round constant XOR, second circular shift, and low-round key XOR. The result is then used as the plaintext to be encrypted in the next iteration. The F function includes the sequential execution of initial permutation, S-box substitution, and initial inverse permutation.

[0014] Step four: Check the current iteration count. If the preset iteration count has not been reached, return to step two to continue iterating. Otherwise, output the result of step three as the encrypted ciphertext.

[0015] The encryption implementation method, in step one, includes the following steps in the shift operation:

[0016] The 128-bit key is divided into 16 8-bit bytes and arranged in sequence to form a 4×4 matrix. Then, the first row of the matrix is ​​swapped with the third row, and the second row is swapped with the fourth row, thus achieving the shift operation.

[0017] In the encryption implementation method, step two involves performing a round-division operation based on the current iteration round number. This means setting the iteration round number to a multi-round iteration starting from round 0, performing the first type of round-division operation when the iteration round number is a composite number, and performing the second type of round-division operation when it is a prime number. The first type of round-division operation is performed in both round 0 and round 1.

[0018] In the aforementioned encryption implementation method, step two and step three, the S-box replacement includes:

[0019] S-box replacement is accomplished using logical operations or table lookups. The formula for logical operations is as follows:

[0020]

[0021]

[0022]

[0023]

[0024] Where a, b, c, and d represent the four bits from the most significant bit to the least significant bit of a 4-bit binary number. After transformation, a', b', c', and d' are obtained, and then combined to form a 4-bit binary number. The range of the binary number converted to decimal is 0 to 15.

[0025] The table lookup is performed based on the preset S-box replacement table, which is obtained based on the result of logical operations.

[0026] In the encryption implementation method described above, step two involves performing a permutation operation on 128-bit data, with each bit as a unit. The permutation is performed according to a preset P permutation table. In step two of the encryption implementation method described above, the generated number X is obtained through the following process:

[0027]

[0028] Where RD represents the current iteration round number, and mod represents the modulo operation.

[0029] The encryption implementation method described above, step three is as follows:

[0030] First, the key is used as the left branch K0 with the high 64 bits and the right branch K1 with the low 64 bits. Then, the 64-bit plaintext to be encrypted is used as the left branch P0 with the high 32 bits and the right branch P1 with the low 32 bits.

[0031] Then, the plaintext left branch P0 is XORed with the high 32 bits of the key left branch K0 to obtain Lp1, and the plaintext right branch P1 is XORed with the high 32 bits of the key left branch K0 to obtain Rp1, thus completing the high-round key XOR.

[0032] Next, Lp1 is cyclically shifted left by 9 bits to obtain Ls1, and the right branch Rp1 is cyclically shifted right by 9 bits to obtain Rs1, thus completing the first cyclic shift.

[0033] Then, perform the first round of constant XOR. Set the iteration round number to start from round 0. If the current iteration round number is odd, XOR Ls1 with the round constant r3 to obtain Lp2, and XOR Rs1 with the round constant r4 to obtain Rp2. If the current iteration round number is even, XOR Ls1 with the round constant r1 to obtain Lp2, and XOR Rs1 with the round constant r2 to obtain Rp2. The round constants are preset values.

[0034] Then, perform the F function, which includes initial permutation, S-box replacement, and initial inverse permutation, on Lp2 to obtain Lp3. Similarly, perform the F function on Rp2 to obtain Rp3.

[0035] Then, perform a second round of constant XOR. Set the iteration round number to start from round 0. When the current iteration round number is odd, XOR Lp3 with the round constant r3 to get Lp4, and XOR Rp3 with the round constant r4 to get Rp4. When the current iteration round number is even, XOR Lp3 with the round constant r1 to get Lp4, and XOR Rp3 with the round constant r2 to get Rp4. The round constants are preset values.

[0036] Then, Lp4 is circularly shifted right by 9 bits to obtain Ls2, and Rp4 is circularly shifted left by 9 bits to obtain Rs2, thus completing the second circular shift.

[0037] Finally, XOR Ls2 with the high 32 bits of the right branch of the key K1 to obtain Lp5, and XOR Rs2 with the high 32 bits of the right branch of the key K1 to obtain Rp5.

[0038] Use the obtained Lp5 and Rp5 as P0 and P1 in the next iteration to complete step three.

[0039] The encryption implementation method, wherein the F function comprising initial permutation, S-box substitution, and initial inverse permutation is:

[0040] Initial permutation: Using the initial permutation table in the DES-like algorithm, Lp2 is obtained by performing a diffusion operation by querying the initial permutation table, and Rp2 is obtained by performing a diffusion operation by querying the initial permutation table.

[0041] S-box substitution: The S-box substitution method, which uses logical operations or table lookup, transforms the results Lp2′ and Rp2′ obtained from the initial permutation operation.

[0042] Initial inverse permutation: Using the initial inverse permutation table in the DES-like algorithm, Lp2′ and Rp2′, which have completed the S-box replacement operation, are queried from the initial inverse permutation table to complete the diffusion operation and obtain Lp3 and Rp3.

[0043] A novel dynamic block cipher HFSP decryption implementation method with consistent encryption and decryption is proposed. The encrypted ciphertext output by the aforementioned encryption implementation method is used as the decryption object. Step three in the encryption implementation method is performed iteratively on the ciphertext. The number of iteration rounds is the same as the number of iteration rounds in the encryption implementation method, but the number of rounds in the iteration process is counted backwards. The key of the corresponding round number is reversed to use for decryption.

[0044] The technical advantage of this invention lies in its design of a novel cryptographic structure, FRX, which is a different type of cryptographic structure from the three major mainstream cryptographic structures, achieving consistent encryption and decryption. The key to this consistency lies in the symmetrical structure of the upper and lower parts of the FRX, where the initial permutation and initial inverse permutation in the PSP structure do not cancel each other out. The S-box used also achieves cryptographic properties, ensuring the security of the algorithm. The dynamic key arrangement section employs random number XOR operations related to the round counter, as well as round-specific operations for prime and composite rounds, to dynamically generate subkeys. This significantly reduces the linear correlation between keys in each round, improving algorithm security and reducing the hardware implementation area. Attached Figure Description

[0045] Figure 1 This is a flowchart of the encryption algorithm described in this invention.

[0046] Figure 2 This is a flowchart of the key arrangement process described in this invention.

[0047] Figure 3 This is a flowchart of the F function in the encryption algorithm structure described in this invention. Detailed Implementation

[0048] This embodiment provides a novel encryption and decryption implementation method for the dynamic block cipher HFSP with consistent encryption and decryption. The initial iteration is denoted as round 0, and each round of iteration includes FRX structure transformation and key arrangement operations.

[0049] See Figure 1 The FRX structure transformation in this embodiment includes performing high-round key XOR, first round cyclic shift, first round constant XOR, F function, second round constant XOR, second round cyclic shift, and low-round key XOR on the grouped data.

[0050] See Figure 3 The F-function structure transformation in this embodiment includes initial permutation, S-box replacement, and initial inverse permutation of the data that has completed the first round of constant XOR.

[0051] See Figure 2 The key arrangement includes row shifting of the key (in this embodiment, row shifting is only required in round 0, and not in rounds 1 to 15), followed by round division. Based on the round division results, the keys in prime rounds with round counters greater than 3 are sequentially subjected to S-box replacement, random number XOR, and P-permutation. The keys in prime rounds with round counters less than or equal to 3 are sequentially subjected to S-box replacement, round counter XOR, and P-permutation. The keys in composite rounds are sequentially subjected to S-box replacement and P-permutation.

[0052] This example provides a novel dynamic block cipher (HFSP) for encryption and decryption consistency. The method utilizes a novel cryptographic structure, FRX, which solves both the limitations of traditional Feistel network structures in achieving full diffusion in a single round and the inability of traditional SP network structures to achieve encryption-decryption consistency. Furthermore, by associating the key arrangement with prime numbers and linear congruence equations, the key can be divided into two dynamic operation flows by determining whether the round constant is a prime number. This makes the key dynamic throughout the encryption process, improving algorithm security and reducing hardware resource consumption by hiding the relationships between keys. The following example further illustrates the invention. This example uses 64-bit plaintext, a 128-bit key, and performs 16 rounds of iteration. In practice, more or fewer plaintext bits, more or fewer keys, and more or fewer rounds of iteration can be used as needed. To ensure encryption security, the number of iteration rounds is generally no less than 16 rounds.

[0053] This example provides a novel encryption and decryption implementation method for the dynamic block cipher HFSP, which achieves consistent encryption and decryption, including the following steps:

[0054] Step 1: Obtain 64 bits of plaintext as the data to be encrypted, and input it from the most significant bit to the least significant bit. Plaintext=p 63 p 62 …p1p0, divide the 64-bit plaintext into two groups, and determine the number of rounds Nr as 16. The specific process of grouping is as follows:

[0055] Let each group be represented as Pi (i=0,1), and the left branch P0=p 63 ||p 62 …p 33 ||p 32 The right branch P1=p 31 ||p 30 …p1||p0.

[0056] Step 2: Obtain the 128-bit key Key as the initial subkey k. Perform a row shift operation on the subkey k to obtain k. a The specific process of the row shift is as follows:

[0057] Divide the 128-bit k into 16 8-bit bytes, namely a 15 a 14 a 13 a 12 a 11 a 10 Given the numbers a9, a8, a7, a6, a5, a4, a3, a2, a1, and a0, plot them as a 4×4 matrix.15 ||a 14 ||a 13 ||a 12 The data 'a' in row 0, the second least significant 8 bits 11 ||a 10 ||a9||a8 are arranged in the first row, the second most significant 8 bits a7||a6||a5||a4 are arranged in the second row, and the most significant 8 bits a3||a2||a1||a0 are arranged in the last row. Let the i-th row be A. i (i=0,1,2,3), the specific arrangement is as follows. For ease of description, the matrix is ​​represented in a two-dimensional form, that is, row 0 is a. 0,3 ||a 0,2 ||a 0,1 ||a 0,0 The first line is a 1,3 ||a 1,2 ||a 1,1 ||a 1,0 The second line is a 2,3 ||a 2,2 ||a 2,1 ||a 2,0 The third line is a 3,3 ||a 3,2 ||a 3,1 ||a 3,0 The two-dimensional arrangement is as follows:

[0058]

[0059] Then swap rows 0 and 2, and rows 1 and 3 to obtain the subkey k. a As shown in the image below:

[0060]

[0061] Step 3: Based on the mathematical properties of the round counter RD, namely whether the value is a prime number or a composite number, the rounds are divided into prime rounds and composite rounds. Since Nr is determined to be 16 in this invention, but 0 and 1 are neither prime nor composite numbers, rounds 0 and 1 are classified as composite rounds in this embodiment. Therefore, rounds 2, 3, 5, 7, 11, and 13 are prime rounds. Rounds 0, 1, 4, 6, 8, 9, 10, 12, 14, and 15 are composite rounds.

[0062] Step 4: Take the k obtained in Step 2 a Based on the results of step 3, perform different operations respectively.

[0063] The operation process for each round is as follows:

[0064] A1: In the round of combining, the subkey k will be... a The key S box performs nonlinear operations to obtain 128-bit data ks. Then, ks undergoes P permutation to complete the diffusion operation and obtain key.

[0065] The prime round first sets the subkey k. a The data is fed into the key box S to perform nonlinear operations and obtain 128-bit data ks. The prime rounds are then further divided based on whether the round count RD is greater than 3.

[0066] A2: If the wheel counter is less than or equal to 3, then XOR the newly obtained ks with the wheel counter RD to obtain kx, as shown in the following formula:

[0067] .

[0068] If the round counter is greater than 3, then the newly obtained ks is XORed with the random number X to obtain kx, where X is generated by a system of linear congruence equations related to the round counter RD, and the main formulas are as follows:

[0069]

[0070] .

[0071] Where RD represents the current iteration round number, and mod represents the modulo operation.

[0072] A3: Perform a P permutation on the obtained 128-bit kx to complete the diffusion operation and obtain the key.

[0073] Step 5: Check if the current round counter RD is less than 15. If so, set RD = RD + 1, and assign the key as the input data for the next round to k. a Then store the key for each round and return to step 4. Otherwise, only store the key and do not perform any further operations.

[0074] Step 6: Set the 128-bit key used in this round to k 127 k 126 …k0, based on the high 64 bits and low 64 bits, yields two branches, left and right, as follows:

[0075] Let each group be represented by Ki (i=0,1), and the left branch K0=k 127 ||k 126 …||k 64 The right branch K1=k 63 ||k 62 …||k0.

[0076] Step 7: XOR the plaintext left branch P0 with the high 32 bits of the key left branch K0 to obtain Lp1, and XOR the plaintext right branch P1 with the high 32 bits of the key left branch K0 to obtain Rp1.

[0077] Step 8: Circularly shift the newly obtained left branch Lp1 9 bits to the left to obtain Ls1. At the same time, circularly shift the newly obtained right branch Rp1 9 bits to the right to obtain Rs1.

[0078] Step 9: Based on the parity of the wheel counter RD, perform the first XOR operation on Ls1 and Rs1 from Step 8 simultaneously. The specific process is as follows:

[0079] If the wheel counter RD is odd, then Ls1 is XORed with the wheel constant r3 to get Lp2, and Rs1 is XORed with the wheel constant r4 to get Rp2.

[0080] If the wheel counter RD is even, then Ls1 is XORed with the wheel constant r1 to get Lp2, and Rs1 is XORed with the wheel constant r2 to get Rp2.

[0081] Perform round constant XOR according to Table 2:

[0082] Table 2. Wheel Constants in the Algorithm

[0083]

[0084] The main formulas are as follows:

[0085] ;

[0086]

[0087] Step 10: Perform the F function on Lp2 obtained in Step 9 to obtain Lp3. At the same time, perform the F function on Rp2 to obtain Rp3. The F function operation includes initial permutation, S-box substitution, and initial inverse permutation in sequence. The specific process is as follows:

[0088] Initial permutation: Using the initial permutation table in the DES-like algorithm, Lp2 is obtained by performing a diffusion operation by querying the initial permutation table, and Rp2 is obtained by performing a diffusion operation by querying the initial permutation table.

[0089] S-box replacement: Use the same 4-key S-box. The reflexive S-box of 4 transforms the results Lp2′ and Rp2′ obtained from the initial permutation operation, respectively.

[0090] Initial inverse permutation: Using the initial inverse permutation table in the DES-like algorithm, Lp2′ and Rp2′, which have completed the S-box replacement operation, are queried from the initial inverse permutation table to complete the diffusion operation and obtain Lp3 and Rp3.

[0091] Step 11: Similar to step 9, based on the parity determination of the wheel counter RD in step 9, perform a second round of XOR operation on Lp3 and Rp3 simultaneously. The specific process is as follows:

[0092] If the wheel counter RD is odd, then Lp3 is XORed with the wheel constant r3 to get Lp4, and Rp3 is XORed with the wheel constant r4 to get Rp4.

[0093] If the wheel counter RD is even, then Lp3 is XORed with the wheel constant r1 to get Lp4, and Rp3 is XORed with the wheel constant r2 to get Rp4.

[0094] Perform round constant XOR according to Table 2:

[0095] Table 2. Wheel Constants in the Algorithm

[0096]

[0097] The main formulas are as follows:

[0098] ;

[0099] ;

[0100] Step 12: Similar to Step 8, the difference is that in this step, the newly obtained left branch Lp4 is cyclically shifted 9 bits to the right to obtain Ls2, and the newly obtained right branch Rp4 is cyclically shifted 9 bits to the left to obtain Rs2.

[0101] Step 13: Similar to Step 7, the difference is that in this step, the plaintext left branch Ls2 is XORed with the high 32 bits of the key right branch K1 to obtain Lp5, and the plaintext right branch Rs2 is XORed with the high 32 bits of the key right branch K1 to obtain Rp5.

[0102] Step 14: Determine if the current round counter RD is less than 15. If so, set RD = RD + 1, and assign Lp5 and Rp5 as the data for the new round of input to P0 and P1 respectively, then return to step 2. Otherwise, output Lp5 and Rp5 as ciphertext from the most significant bit to the least significant bit.

[0103] The decryption process in this embodiment also follows the above steps. However, because the subkeys generated in the 16 rounds of encryption were stored during the encryption process, decryption only requires decrypting the 16 subkeys. 15 ,key 14…… The decryption process can be performed by reusing key1 and key0 sequentially, and includes the following steps:

[0104] Step B1: Obtain the 64-bit ciphertext as the data to be decrypted. Ciphertext=c 63 c 62 …c1c0 divides the 64-bit ciphertext into two groups, C0 and C1, and determines the number of rounds Nr to be 16.

[0105] Step B2: Obtain the 128-bit encryption key stored during this round. 15 =k 127 k 126 ... k0, and key 15 Reverse the order, i.e., key 15 =k0...k 126 k 127 As the initial subkey.

[0106] Step B3: The obtained 128-bit key 15 As a subkey in this round of key addition, the 128-bit key is divided into left and right branches based on the high 64 bits and the low 64 bits, i.e., K0 = k0||k1…k 62 ||k 63 and K1= k 64 ||k 65 …k 126 ||k 127 ;

[0107] Step B4: XOR the left branch of ciphertext C0 with the high 32 bits of the left branch of key K0 to obtain Lc1, and XOR the right branch of ciphertext C1 with the high 32 bits of the left branch of key K0 to obtain Rc1.

[0108] Step B5: Circularly shift the newly obtained left branch Lc1 9 bits to the left to obtain Ls1; simultaneously, circularly shift the newly obtained right branch Rc1 9 bits to the right to obtain Rs1.

[0109] Step B6: Based on the parity of the wheel counter RD, perform the first wheel constant XOR operation on Ls1 and Rs1 from Step B5 to obtain Lc2 and Rc2 respectively;

[0110] Step B7: Apply the F function to Lp2 obtained in Step B6 to obtain Lc3. Simultaneously, apply the F function to Rp2 to obtain Rc3.

[0111] The F-function operation includes, in sequence, initial permutation, S-box substitution, and initial inverse permutation.

[0112] Step B8: Similar to step B6, based on the parity determination of the wheel counter RD in step B5, perform a second XOR operation on Lc3 and Rc3 simultaneously to obtain Lc4 and Rc4.

[0113] Step B9: Similar to Step B5, the difference is that in this step, the newly obtained left branch Lc4 is cyclically shifted 9 bits to the right to obtain Ls2, and the newly obtained right branch Rc4 is cyclically shifted 9 bits to the left to obtain Rs2.

[0114] Step B10: Similar to step B4, the difference is that in this step, the left branch of the ciphertext Ls2 is XORed with the high 32 bits of the right branch of the key K1 to obtain Lc5, and the right branch of the plaintext Rs2 is XORed with the high 32 bits of the right branch of the key K1 to obtain Rc5.

[0115] Step B11: Determine if the current round counter RD is greater than 0. If so, set RD = RD - 1, assign Lc5 and Rc5 as the data for the new round of input to C0 and C1 respectively, and return to step B2. Otherwise, output Lc5 and Rc5 as plaintext from high to low bits.

[0116] In this embodiment, the algorithm is named HFSP. The algorithm block size is 64 bits, the key length is 128 bits, and the number of iteration rounds is 16. The algorithm adopts an FRX structure. The F function includes initial permutation, S-box replacement, and initial inverse permutation. Dynamic key arrangement includes row shifting, S-box replacement, random number XOR, round counter XOR, and P permutation. Since the row shifting module and the round counter XOR module in dynamic key arrangement have already been described in detail, they will not be repeated here. The following describes each module of the F function and other modules of dynamic key arrangement in detail.

[0117] like Figure 3 As shown, the F function includes initial permutation, S-box substitution, and initial inverse permutation.

[0118] Initial Permutation IP: By studying the pattern of the initial permutation table IP of DES, a 32-bit initial permutation IP was constructed. It is applied to the data obtained after the first round of constant XOR between the left and right branches to achieve the diffusion effect. The permutation operation is performed on the 32-bit data with each bit as a unit. The initial permutation table IP is shown in Table 3.

[0119]

[0120] The table above uses the original data as i. After finding the corresponding value in the table, it is replaced with the IP(i) value in the second row.

[0121] S-box replacement: This is accomplished using logical operations or table lookup. The logical operations mainly include the following steps: where a, b, c, and d represent the four bits of a binary number from 0 to 15, from the most significant bit to the least significant bit. Each bit is replaced according to the following replacement formula to obtain a', b', c', and d', which are then rearranged and combined. The logical formula is as follows:

[0122]

[0123]

[0124]

[0125]

[0126] When using a lookup table, the S-box elements shown in Table 1 below are used for replacement. In this embodiment, the S-box elements are obtained based on the results of logical operations.

[0127] Table 1 Algorithm S-box Elements

[0128]

[0129] This embodiment uses a 4-in, 4-out S-box, so the value X passed into the S-box must be one of hexadecimal 0-F. That is, when X is one of 0-F, it is replaced with the corresponding value of S[x] below according to this table. For example, when X is 6, it is replaced with F after passing through the S-box, so the output of the S-box is F.

[0130] Initial inverse permutation IP -1 By studying the initial inverse permutation table IP of DES -1 Based on the pattern, a 32-bit initial inverse permutation IP was constructed. -1 After the S-box replacement is completed in both the left and right branches, the data is further diffused. The 32-bit data is then permuted using each bit as a unit. The initial inverse permutation table IP... -1 As shown in Table 4.

[0131] Table 4 shows the initial inverse permutation table (IP) in the algorithm. -1

[0132]

[0133] like Figure 2 As shown, dynamic key arrangement includes row shifting, S-box substitution, random number XOR, round counter XOR, and P permutation.

[0134] S-box replacement: The same S-box is used for non-linear operations as in the encryption process, which can reduce the resources consumed in hardware implementation to a certain extent. It can also be completed through logical operations or table lookup. The logical formula is as follows, and the S-box elements are shown in Table 1.

[0135]

[0136]

[0137]

[0138]

[0139] Random number XOR: This module is an important part of implementing dynamic key arrangement. It is mainly generated by a set of linear congruent equations related to the round counter RD. According to this formula, a sufficiently large periodic sequence can be generated, which satisfies a certain uniform distribution characteristic. Its advantage is that it can quickly generate a large number of random numbers and is very easy to implement. The main formula and random number table 5 are as follows:

[0140]

[0141] Table 5: Random Numbers Generated in Each Round of Prime Rounds with a Number Greater Than 3

[0142]

[0143] P-permutation: The initial permutation table IP similar to DES was adopted. By studying the initial permutation table of DES, the pattern was found and a 128-bit P-permutation table was constructed for full key diffusion. The permutation operation was performed on the 128-bit data with each bit as a unit. The P-permutation table is shown in Table 6.

[0144] Table 6 shows the P-permutation table in the algorithm.

[0145]

[0146] P-permutation means taking the original data as i, finding the corresponding value, and replacing it with the value P(i) in the second row.

[0147] The main idea of ​​this invention is to combine the different number of rounds with key generation. That is, by judging whether the number of rounds is a prime number, two different methods are used to generate subkeys, so that the key takes a dynamic form throughout the encryption process. This improves the security of the algorithm by reducing the correlation between subkeys and makes up for the shortcomings of strong correlation between subkeys in the past.

[0148] The method of this invention includes FRX structure transformation and key arrangement. The FRX structure transformation includes high-round key XOR, first cyclic shift, first round constant XOR, F function, second round constant XOR, second cyclic shift, and low-round key XOR. Key arrangement includes, in turn, row shifting of the key in round 0, followed by sequential round-by-round operations. Based on the round-by-round results, for keys in prime rounds with a round counter greater than 3, S-box replacement, random number XOR, and P-permutation are performed sequentially; for keys in prime rounds with a round counter less than 3, S-box replacement, round counter XOR, and P-permutation are performed sequentially; and for keys in composite rounds, S-box replacement and P-permutation are performed sequentially. The PSP structure transformation in the F function of the FRX structure transformation ensures that the initial permutation and initial inverse permutation are not canceled out, and the two permutations ensure sufficient diffusion of the algorithm. The S-box guarantees the algorithm's confusion. The random number XOR in the key arrangement increases the complexity of the key arrangement, thereby reducing the algorithm's linear dependence. Because the entire encryption process uses the FRX structure, the decryption process can use the same structure as the encryption process. The only difference is that the subkeys used in the encryption process are used in reverse order during the decryption process.

[0149] test:

[0150] The method provided in the embodiments of the present invention was tested, and the cryptographic algorithm data provided by the present invention is shown in Table 7.

[0151] Table 7 Experimental Test Data

[0152]

[0153] When the cryptographic algorithm described in this invention is implemented on a Xilinx Virtex-5 FPGA, the algorithm clock period is 2.894 ns, the clock frequency is 424.493MHz, and the throughput is 400Kbps.

[0154] The cryptographic algorithm described in this invention is implemented in ASIC hardware using the SMIC 0.18 synthesis library. The algorithm occupies 1983 GE of resources. Table 8 shows the FPGA hardware implementation of typical block cipher algorithms with minimum key length, and Table 9 shows the ASIC hardware implementation of typical block cipher algorithms with minimum key length.

[0155] Table 8 FPGA Implementation of Various Block Cipher Algorithms

[0156]

[0157] Table 9 ASIC Implementations of Block Cipher Algorithms

[0158]

[0159] A comparison of the data in Tables 8 and 9 shows that, compared to current block ciphers, HFSP has higher performance in terms of frequency and throughput while occupying roughly the same area and resources.

[0160] It should be emphasized that the examples described in this invention are illustrative rather than limiting. Therefore, this invention is not limited to the examples described in the specific embodiments. Any other embodiments derived by those skilled in the art based on the technical solutions of this invention, without departing from the spirit and scope of this invention, whether modifications or substitutions, are also within the protection scope of this invention.

Claims

1. A novel encryption implementation method for a dynamic block cipher (HFSP) with consistent encryption and decryption, characterized in that, Includes the following steps: Step 1: Set a 128-bit key (Key) and perform a shift operation to obtain k. a ; Step 2: Based on the current iteration round number, adjust k... a Perform two different round-robin operations; the first round-robin operation is: set k a Perform S-box replacement to obtain 128-bit data ks, and then perform P-permutation on ks to obtain key; The second type of round-robin operation is: k a Perform S-box replacement to obtain 128-bit data ks. Then, depending on whether the current iteration round number is greater than a preset value, perform two different sub-round operations: when it is not greater than the preset value, the sub-round operation is to XOR ks with the number of the current iteration round to obtain kx; when it is greater than the preset value, the sub-round operation is to XOR ks with the generated number X to obtain kx. Finally, perform P-permutation on kx to obtain key. Then save the key and use the key as the k. a This key is used for the next iteration, and then used as the key in the current iteration. Step 3: Based on the key, the 64-bit plaintext to be encrypted is sequentially subjected to FRX structure transformation, including high-round key XOR, first circular shift, first round constant XOR, F function, second round constant XOR, second circular shift, and low-round key XOR. The result is then used as the plaintext to be encrypted in the next iteration. The F function includes the sequential execution of initial permutation, S-box substitution, and initial inverse permutation. The key is used with the high 64 bits as the left key branch K0 and the low 64 bits as the right key branch K1. High-round key XOR refers to XORing based on the high 32 bits of the left key branch K0; low-round key XOR refers to XORing based on the high 32 bits of the right key branch K1. Step 4: Check the current iteration count. If the preset iteration count has not been reached, return to Step 2 to continue iterating. Otherwise, the result of step three will be output as the encrypted ciphertext.

2. The encryption implementation method according to claim 1, characterized in that, In step one, the shifting operation includes the following steps: Divide the 128-bit key into 16 8-bit bytes and arrange them in sequence to form a 4×4 matrix. Then, swap the first and third rows of the matrix, and swap the second and fourth rows.

3. The encryption implementation method according to claim 1, characterized in that, In step two, the round-division operation is performed according to the current iteration round number. The iteration round number is set to a multi-round iteration starting from round 0. The first round-division operation is performed when the iteration round number is a composite number, and the second round-division operation is performed when it is a prime number. The first round-division operation is performed in both round 0 and round 1.

4. The encryption implementation method according to claim 1, characterized in that, In steps two and three, the S-box replacement includes: S-box replacement is accomplished using logical operations or table lookups. The formula for logical operations is as follows: ; ; ; ; Where a, b, c, and d represent the four bits from the most significant bit to the least significant bit of a 4-bit binary number. After transformation, a', b', c', and d' are obtained, and then combined into a 4-bit binary number. The range of the binary number converted to decimal is 0 to 15. The table lookup is performed based on the preset S-box replacement table, which is obtained based on the result of logical operations.

5. The encryption implementation method according to claim 1, characterized in that, In step two, the P permutation is a permutation operation performed on 128-bit data, with each bit as a unit. The permutation is performed according to a preset P permutation table.

6. The encryption implementation method according to claim 1, characterized in that, In step two, the generated number X is obtained through the following process: ; Where RD represents the current iteration round number, and RD > 3, and mod represents the modulo operation.

7. The encryption implementation method according to claim 1, characterized in that, The third step is as follows: First, the key is used as the left branch K0 with the high 64 bits and the right branch K1 with the low 64 bits; and the 64-bit plaintext to be encrypted is used as the left branch P0 with the high 32 bits and the right branch P1 with the low 32 bits. Then, the plaintext left branch P0 is XORed with the high 32 bits of the key left branch K0 to obtain Lp1, and the plaintext right branch P1 is XORed with the high 32 bits of the key left branch K0 to obtain Rp1, thus completing the high-round key XOR. Next, Lp1 is circularly shifted left by 9 bits to obtain Ls1, and the right branch Rp1 is circularly shifted right by 9 bits to obtain Rs1, thus completing the first circular shift; Then perform the first round of constant XOR, setting the iteration round number to start from round 0. When the current iteration round number is odd, XOR Ls1 with the round constant r3 to obtain Lp2, and XOR Rs1 with the round constant r4 to obtain Rp2; when the current iteration round number is even, XOR Ls1 with the round constant r1 to obtain Lp2, and XOR Rs1 with the round constant r2 to obtain Rp2; where the round constant is a preset value. Then, perform the F function, which includes initial permutation, S-box replacement, and initial inverse permutation, on Lp2 to obtain Lp3. Similarly, perform the F function on Rp2 to obtain Rp3. Then, perform a second round of constant XOR. Set the iteration round number to start from round 0. When the current iteration round number is odd, XOR Lp3 with the round constant r3 to get Lp4, and XOR Rp3 with the round constant r4 to get Rp4. When the current iteration round number is even, XOR Lp3 with the round constant r1 to get Lp4, and XOR Rp3 with the round constant r2 to get Rp4. The round constants are preset values. Then, Lp4 is circularly shifted right by 9 bits to obtain Ls2, and Rp4 is circularly shifted left by 9 bits to obtain Rs2, thus completing the second circular shift; Finally, XOR Ls2 with the high 32 bits of the right branch of the key K1 to get Lp5, and XOR Rs2 with the high 32 bits of the right branch of the key K1 to get Rp5. Use the obtained Lp5 and Rp5 as P0 and P1 in the next iteration to complete step three.

8. The encryption implementation method according to claim 7, characterized in that, The F-function, which includes the initial permutation, S-box substitution, and initial inverse permutation, is as follows: Initial permutation: Using an initial permutation table design method similar to that in the DES algorithm, Lp2 is obtained by querying the initial permutation table to complete the diffusion operation and obtain Lp2′, and Rp2 is obtained by querying the initial permutation table to complete the diffusion operation and obtain Rp2′. S-box replacement: The S-box replacement method, which uses logical operations or table lookup, transforms the results Lp2′ and Rp2′ obtained from the initial permutation operation respectively. Initial inverse permutation: Using an initial inverse permutation table design method similar to that in the DES algorithm, Lp2′ and Rp2′ that have completed the S-box replacement operation are queried from the initial inverse permutation table to complete the diffusion operation and obtain Lp3 and Rp3.

9. A novel dynamic block cipher HFSP decryption implementation method with consistent encryption and decryption, characterized in that, The encrypted ciphertext output by any one of the encryption implementation methods described in claims 1-8 is used as the decryption object, and step three of the encryption implementation method described in any one of claims 1-8 is iteratively executed on the ciphertext. The number of iteration rounds is the same as the number of iteration rounds of the encryption implementation method described in any one of claims 1-8, but the number of rounds in the iteration process is counted backwards, and the key of the corresponding round number is used in reverse order for decryption. The key of the corresponding round number is reversed in reverse order, which means that the key saved in all iteration rounds in the encryption process is used in reverse order according to the generation order, and the bits of a single key are arranged in reverse order from back to front.

Citation Information

Patent Citations

  • Novel ultra-lightweight QTL (Quasi-Transmission Line) block cipher implementation method

    CN104333446A

  • Improved lightweight grouping encryption and decryption method and device based on P replacement and storage medium

    CN111614457A