Method and system for quickly realizing cryptographic algorithm encryption and decryption based on key derivation function

Through pre-computation and SIMD instructions, the key derived function in the SM2 public key encryption and decryption algorithm is optimized, which solves the problem of high computational complexity of key derived function, significantly improves the encryption and decryption speed, and has the characteristics of efficiency and security.

CN119483914AInactive Publication Date: 2025-02-18SHANDONG UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510045082.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, the key derivation function of the SM2 public key encryption and decryption algorithm has high computational complexity, resulting in slow operation speed and affecting the speed of encryption and decryption.

Method used

Through pre-calculation and SIMD instructions, the calculation complexity of the key derived function is reduced. The specific method includes performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits of data, obtaining a 256 bit hash value, and the remaining 32 bits of data The bits are batch processed to obtain the calculation results of the key derived function.

Benefits of technology

It greatly improves the execution speed of key-derived functions, and has the advantages of universality, low memory usage, high efficiency, and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119483914A_ABST
    Figure CN119483914A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of cryptographic algorithm encryption and decryption, in particular to a cryptographic algorithm encryption and decryption method and system based on a key derivation function, and the method comprises the steps of encrypting a message and decrypting a ciphertext. A key derivation function in the step of encrypting a message and the step of decrypting a ciphertext is accelerated and comprises the following steps of: firstly, executing message expansion and iterative compression of a standard SM3 Hash algorithm on the first 512 bits Z to obtain a 256-bit Hash value H; and then, carrying out batch processing on the remaining 32 bits to obtain a calculation result of the key derivation function. The calculation complexity is reduced through pre-calculation and SIMD instructions, the KDF speed is greatly improved, and the method has the advantages of being universal, small in memory occupation, high in efficiency, safe to achieve and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of encryption and decryption of national secret algorithms, and in particular to a method and system for encryption and decryption of national secret algorithms that are quickly implemented based on a key derivation function. Background Art

[0002] The SM2 public key encryption algorithm is a public key encryption algorithm based on elliptic curve cryptography and is widely used in data encryption, decryption, digital signature and other operations.

[0003] The SM2 public key encryption algorithm includes executing a key derivation function. The execution process of the key derivation function is a key factor affecting the encryption and decryption performance of the elliptic curve algorithm. Although the prior art has accelerated the SM3 algorithm based on the SIMD parallel method, which has greatly improved the speed compared to the standard implementation, its speed is still far behind the symmetric encryption algorithm.

[0004] In the process of encryption and decryption tasks, because the key derivation function in the elliptic curve has high computational complexity and slow operation speed, it occupies computer memory and affects the speed of encryption and decryption. Summary of the invention

[0005] In order to address the deficiencies in the prior art, the present invention provides a national secret algorithm encryption and decryption method and system based on a key derivation function that is quickly implemented; the computational complexity is reduced through pre-calculation and SIMD instructions, and the KDF speed is greatly improved. The method of the present invention has the advantages of being universal, having low memory usage, high efficiency, and being secure.

[0006] On the one hand, a national secret algorithm encryption and decryption method based on a key derivation function that is quickly implemented is provided, including: a step of encrypting a message and a step of decrypting a ciphertext; the key derivation function in the step of encrypting a message and the step of decrypting a ciphertext is accelerated, including: first, performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits Z to obtain a 256-bit hash value H; then, batch processing the remaining 32 bits to obtain the calculation result of the key derivation function.

[0007] On the other hand, a national secret algorithm encryption and decryption system based on a fast implementation of a key derivation function is provided, including: a module for encrypting messages and a module for decrypting ciphertext; the key derivation function in the module for encrypting messages and the module for decrypting ciphertext is accelerated, including: first, performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits Z to obtain a 256-bit hash value H; then, batch processing the remaining 32 bits to obtain the calculation result of the key derivation function.

[0008] The above technical solution has the following advantages or beneficial effects: The key derivation function in the step of encrypting a message and the step of decrypting a ciphertext is executed at an accelerated speed. First, the message expansion and iterative compression of the standard SM3 hash algorithm are performed on the first 512 bits Z to obtain a 256-bit hash value H; then, the remaining 32 bits are processed in batches to obtain the calculation result of the key derivation function; compared with the previous technology, the method of the present invention reduces the calculation complexity through pre-calculation and SIMD instructions, greatly improves the KDF speed, and has the advantages of generality, small memory occupation, high efficiency, and security. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0010] Figure 1 This is a flow chart of the method of embodiment 1. DETAILED DESCRIPTION

[0011] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.

[0012] Embodiment 1, as Figure 1 As shown, this embodiment provides a national secret algorithm encryption and decryption method based on a key derivation function for rapid implementation, including: a step of encrypting a message and a step of decrypting a ciphertext; the key derivation function in the step of encrypting a message and the step of decrypting a ciphertext is accelerated, including: first, performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits Z to obtain a 256-bit hash value H; then, batch processing the remaining 32 bits to obtain a calculation result of the key derivation function.

[0013] Furthermore, the step of encrypting the message includes: Suppose the message to be sent is a bit string , for The bit length of In order to Encryption, the user who acts as the encryptor Implement the following operation steps: A1: Use a random number generator to generate random numbers ; A2: Calculate elliptic curve points ,Will The data type is converted to a bit string; A3: Calculate elliptic curve points ,like If it is a point at infinity, an error is reported and the system exits; A4: Calculate elliptic curve points ,Will The data type is converted to a bit string; A5: Calculation ,like If it is a string of all 0 bits, return A1; A6: Calculation ; A7: Calculation ; A8: Output ciphertext .

[0014] Furthermore, the step of decrypting the ciphertext includes: Assumptions In the ciphertext bit length; in order to To decrypt, user B, as the decryptor, should implement the following operation steps: B1: From the ciphertext Extract the bit string ,Will The data type is converted to a point on the elliptic curve and verified Whether the elliptic curve equation is satisfied. If not, an error is reported and the system exits. B2: Calculate elliptic curve points ,like If it is a point at infinity, an error will be reported and the system will exit; B3: Calculation ,Will The data type is converted to a bit string; B4: Calculation ,like If it is a string of all 0 bits, an error is reported and the system exits; B5: From the ciphertext Extract the bit string ,calculate ; B6: Calculation , from the ciphertext Extract the bit string ,if , then report an error and exit; B7: Output plain text .

[0015] Furthermore, the key derivation function includes: Suppose the cryptographic hash function is , whose output is of length The hash value of the bits.

[0016] Key derivation function : Input: bit string , integer ; Indicates the bit length of the key data to be obtained; Output: Length is The key data bit string ; (a) Initialize a 32-bit counter ; (b) Yes From 1 to implement: (b1) Calculation ; (b2)ct plus 1; (c) If is an integer, then let , otherwise, let for The leftmost Bit; (d) Order .

[0017] Furthermore, before the key derivation function in the step of encrypting the message and the step of decrypting the ciphertext is accelerated, the method further includes: Precompute and save the parameter table: SM3_Tj

[64] ={0x79cc4519,0xf3988a32,0xe7311465,0xce6228cb,0x9cc45197,0x3988a32f,0x7311465e, 0xe6228cbc,0xcc451979,0x988a32f3,0x311465e7,0x6228cbce,0xc451979c,0x88a32f39,0x11465e73,0 x228cbce6,0x9d8a7a87,0x3b14f50f,0x7629ea1e,0xec53d43c,0xd8a7a879,0xb14f50f3,0x629ea1e7,0x c53d43ce,0x8a7a879d,0x14f50f3b,0x29ea1e76,0x53d43cec,0xa7a879d8,0x4f50f3b1,0x9ea1e762,0x3d 43cec5,0x7a879d8a,0xf50f3b14,0xea1e7629,0xd43cec53,0xa879d8a7,0x50f3b14f,0xa1e7629e,0x43c ec53d,0x879d8a7a,0x0f3b14f5,0x1e7629ea,0x3cec53d4,0x79d8a7a8,0xf3b14f50,0xe7629ea1,0xcec53 d43,0x9d8a7a87,0x3b14f50f,0x7629ea1e,0xec53d43c,0xd8a7a879,0xb14f50f3,0x629ea1e7,0xc53d43 ce,0x8a7a879d,0x14f50f3b,0x29ea1e76,0x53d43cec,0xa7a879d8,0x4f50f3b1,0x9ea1e762,0x3d43cec5}.

[0018] Because the input message length is fixed at 544 bits, and only the first 32 bits of the last 512 bits are different, and the rest are fixed values, some message extension values ​​can be pre-calculated.

[0019] Furthermore, the key derivation function in the step of encrypting the message and the step of decrypting the ciphertext is accelerated, including: assuming that the width of a single instruction multiple data SIMD register is w bits (usually 128, 256 or 512), assuming that the step size is n=w / 32, each register can be divided into n 32-bit blocks, setting the contents of each block in the SIMD register m0 to 1, 2, ... n-1 respectively, H=SM3Update(Z), dividing H into 8 32-bit data blocks B0, B1....B7, filling the SIMD array SW[8], filling SW[i] with Bi for i from 0 to 8, and i equals 0; (1): A= SW[0]; B= SW[1]; C= SW[2]; D= SW[3]; E= SW[4]; F= SW[5]; G= SW[6]; H=SW[7]; Among them, A, B, C, D, E, F, G, H represent 8 SIMD registers; Execute the p1(x) function on register m0 to get the array SW_0; fill SW_1 with 0x80404000; fill SW_2 with 0x01108888; fill SW_4 with 0x10005000; fill SW_5 with 0x0022028a; fill SW_7 with 0xac545c04; fill SW_8 with 0x99cda89a; SW_0 is grouped into 32 bits and then circularly shifted left by 15 bits. Then, the p1(x) function is executed to obtain SW_3. Execute a 15-bit circular left shift on SW_3 in 32-bit groups to obtain t0; execute the p1(x) function on t0, and then perform an XOR operation with SW_0 to obtain SW_6; execute a 15-bit circular left shift on SW_6 in 32-bit groups, and then perform an XOR operation with SW_0 to obtain t0; execute p1(x) on t0, and then perform an XOR operation with SW_3 to obtain SW_9; fill SW_10 with 0xa0003000; fill SW_11 with 0x002202a8; fill SW_12 with 0x11000; fill SW_13 with 0xa4505804; among them, SW_0 to SW_15 are all SIMD registers; SW_9 is grouped into 32 bits and then cyclically shifted left by 15 bits, and then XORed with SW_3 to obtain t0; Execute p1(x) on t0, and then perform XOR operation with SW_3 and SW_12 to obtain SW_12; SW_0 is grouped into 32 bits and then cyclically shifted left by 7 bits. Then, it is XORed with SW_13 to obtain SW_13. SW_14 is filled with 0xf45691fb. T4 is filled with 0x00000220. Call the status word generation instruction sequence Gen_W (T4, SW_6, SW_12, SW_2, SW_15, SW_9); t0 = T4; Call the first round function instruction sequence OneRoundA(A,E,B,F,C,G,D,H,m0,m0,SM3_Tj[0]); Fill t1 with 0x80000000; Call the first round function instruction sequence OneRoundA(D,H,A,E,B,F,C,G,t1,t1,SM3_Tj[1]); Call the second round function instruction sequence OneRoundB(C,G,D,H,A,E,B,F,SM3_Tj[2]); Call the second round function instruction sequence OneRoundB(B,F,C,G,D,H,A,E,SM3_Tj[3]); Call the second round function instruction sequence OneRoundB(A,E,B,F,C,G,D,H,SM3_Tj[4]); Call the second round function instruction sequence OneRoundB(D,H,A,E,B,F,C,G,SM3_Tj[5]); Call the second round function instruction sequence OneRoundB(C,G,D,H,A,E,B,F,SM3_Tj[6]); Call the second round function instruction sequence OneRoundB(B,F,C,G,D,H,A,E,SM3_Tj[7]); Call the second round function instruction sequence OneRoundB(A,E,B,F,C,G,D,H,SM3_Tj[8]); Call the second round function instruction sequence OneRoundB(D,H,A,E,B,F,C,G,SM3_Tj[9]); Call the second round function instruction sequence OneRoundB(C,G,D,H,A,E,B,F,SM3_Tj

[10] ); Call the third round function instruction sequence OneRounds(B,F,C,G,D,H,A,E,t0,SM3_Tj

[11] ); Call the third round function instruction sequence OneRounds(A,E,B,F,C,G,D,H,SW_0,SM3_Tj

[12] ); Call the third round function instruction sequence OneRounds(D,H,A,E,B,F,C,G,SW_1,SM3_Tj

[13] ); Call the third round function instruction sequence OneRounds(C,G,D,H,A,E,B,F,SW_2,SM3_Tj

[14] ); Perform an XOR operation on t0 and SW_3 to obtain T3; Call the first round function instruction sequence OneRoundA(B,F,C,G,D,H,A,E,t0,T3,SM3_Tj

[15] ); Perform an XOR operation on SW_0 and SW_4 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_0,T3,SM3_Tj

[16] ); Call the status word generation instruction sequence Gen_W (SW_0, SW_7, SW_13, SW_3, SW_0, SW_10); Perform an XOR operation on SW_1 and SW_5 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_1,T3,SM3_Tj

[17] ); call the status word generation instruction sequence Gen_W(SW_1,SW_8,SW_14,SW_4,SW_1,SW_11); Perform XOR operation on SW_2 and SW_6 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_2,T3,SM3_Tj

[18] ); Call the status word generation instruction sequence Gen_W (SW_2, SW_9, SW_15, SW_5, SW_2, SW_12) Perform XOR operation on SW_3 and SW_7 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_3,T3,SM3_Tj

[19] ); Call the status word generation instruction sequence Gen_W (SW_3, SW_10, SW_0, SW_6, SW_3, SW_13) Perform XOR operation on SW_4 and SW_8 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_4,T3,SM3_Tj

[20] )); call the status word generation instruction sequence Gen_W(SW_4,SW_11,SW_1,SW_7,SW_4,SW_14); Perform XOR operation on SW_5 and SW_9 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_5,T3,SM3_Tj

[21] ); call the status word generation instruction sequence Gen_W(SW_5,SW_12,SW_2,SW_8,SW_5,SW_15); Perform XOR operation on SW_6 and SW_10 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_6,T3,SM3_Tj

[22] ); Call the status word generation instruction sequence Gen_W (SW_6, SW_13, SW_3, SW_9, SW_6, SW_0) Perform XOR operation on SW_7 and SW_11 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_7,T3,SM3_Tj

[23] ); call the status word generation instruction sequence Gen_W(SW_7,SW_14,SW_4,SW_10,SW_7,SW_1); Perform XOR operation on SW_8 and SW_12 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_8,T3,SM3_Tj

[24] ); call the status word generation instruction sequence Gen_W(SW_8,SW_15,SW_5,SW_11,SW_8,SW_2); Perform XOR operation on SW_9 and SW_13 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_9,T3,SM3_Tj

[25] ); call the status word generation instruction sequence Gen_W(SW_9,SW_0,SW_6,SW_12,SW_9,SW_3); Perform XOR operation on SW_10 and SW_14 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_10, T3, SM3_Tj

[26] ); call the status word generation instruction sequence Gen_W(SW_10, SW_1, SW_7, SW_13, SW_10, SW_4); Perform XOR operation on SW_11 and SW_15 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_11,T3,SM3_Tj

[27] ); call the status word generation instruction sequence Gen_W(SW_11,SW_2,SW_8,SW_14,SW_11,SW_5); Perform XOR operation on SW_12 and SW_0 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_12,T3,SM3_Tj

[28] ); call the status word generation instruction sequence Gen_W(SW_12,SW_3,SW_9,SW_15,SW_12,SW_6); Perform XOR operation on SW_13 and SW_1 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_13,T3,SM3_Tj

[29] ); call the status word generation instruction sequence Gen_W(SW_13,SW_4,SW_10,SW_0,SW_13,SW_7); Perform XOR operation on SW_14 and SW_2 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_14, T3, SM3_Tj

[30] ); call the status word generation instruction sequence Gen_W(SW_14, SW_5, SW_11, SW_1, SW_14, SW_8); Perform XOR operation on SW_15 and SW_3 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_15,T3,SM3_Tj

[31] ); call the status word generation instruction sequence Gen_W(SW_15,SW_6,SW_12,SW_2,SW_15,SW_9); Perform XOR operation on SW_0 and SW_4 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_0,T3,SM3_Tj

[32] ); call the status word generation instruction sequence Gen_W(SW_0,SW_7,SW_13,SW_3,SW_0,SW_10); Perform XOR operation on SW_1 and SW_5 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_1,T3,SM3_Tj

[33] ); call the status word generation instruction sequence Gen_W(SW_1,SW_8,SW_14,SW_4,SW_1,SW_11); Perform XOR operation on SW_2 and SW_6 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_2, T3, SM3_Tj

[34] ); call the status word generation instruction sequence Gen_W(SW_2, SW_9, SW_15, SW_5, SW_2, SW_12); Perform XOR operation on SW_3 and SW_7 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_3,T3,SM3_Tj

[35] ); call the status word generation instruction sequence Gen_W(SW_3,SW_10,SW_0,SW_6,SW_3,SW_13); Perform XOR operation on SW_4 and SW_8 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_4,T3,SM3_Tj

[36] ); call the status word generation instruction sequence Gen_W(SW_4,SW_11,SW_1,SW_7,SW_4,SW_14); Perform XOR operation on SW_5 and SW_9 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_5,T3,SM3_Tj

[37] ); call the status word generation instruction sequence Gen_W(SW_5,SW_12,SW_2,SW_8,SW_5,SW_15); Perform XOR operation on SW_6 and SW_10 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_6, T3, SM3_Tj

[38] ); call the status word generation instruction sequence Gen_W(SW_6, SW_13, SW_3, SW_9, SW_6, SW_0); Perform XOR operation on SW_7 and SW_11 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_7,T3,SM3_Tj

[39] ); call the status word generation instruction sequence Gen_W(SW_7,SW_14,SW_4,SW_10,SW_7,SW_1); Perform XOR operation on SW_8 and SW_12 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_8,T3,SM3_Tj

[40] )); call the status word generation instruction sequence Gen_W(SW_8,SW_15,SW_5,SW_11,SW_8,SW_2); Perform XOR operation on SW_9 and SW_13 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_9,T3,SM3_Tj

[41] ); call the status word generation instruction sequence Gen_W(SW_9,SW_0,SW_6,SW_12,SW_9,SW_3); Perform XOR operation on SW_10 and SW_14 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_10, T3, SM3_Tj

[42] ); call the status word generation instruction sequence Gen_W(SW_10, SW_1, SW_7, SW_13, SW_10, SW_4); Perform XOR operation on SW_11 and SW_15 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_11,T3,SM3_Tj

[43] ); call the status word generation instruction sequence Gen_W(SW_11,SW_2,SW_8,SW_14,SW_11,SW_5); Perform XOR operation on SW_12 and SW_0 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_12,T3,SM3_Tj

[44] ); call the status word generation instruction sequence Gen_W(SW_12,SW_3,SW_9,SW_15,SW_12,SW_6); Perform XOR operation on SW_13 and SW_1 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_13,T3,SM3_Tj

[45] ); call the status word generation instruction sequence Gen_W(SW_13,SW_4,SW_10,SW_0,SW_13,SW_7); Perform XOR operation on SW_14 and SW_2 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_14, T3, SM3_Tj

[46] ); call the status word generation instruction sequence Gen_W(SW_14, SW_5, SW_11, SW_1, SW_14, SW_8); Perform XOR operation on SW_15 and SW_3 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_15,T3,SM3_Tj

[47] ); call the status word generation instruction sequence Gen_W(SW_15,SW_6,SW_12,SW_2,SW_15,SW_9); Perform XOR operation on SW_0 and SW_4 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_0,T3,SM3_Tj

[48] ); call the status word generation instruction sequence Gen_W(SW_0,SW_7,SW_13,SW_3,SW_0,SW_10); Perform XOR operation on SW_1 and SW_5 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_1,T3,SM3_Tj

[49] ); call the status word generation instruction sequence Gen_W(SW_1,SW_8,SW_14,SW_4,SW_1,SW_11); Perform XOR operation on SW_2 and SW_6 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_2, T3, SM3_Tj

[50] ); call the status word generation instruction sequence Gen_W(SW_2, SW_9, SW_15, SW_5, SW_2, SW_12); Perform XOR operation on SW_3 and SW_7 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_3,T3,SM3_Tj

[51] ); call the status word generation instruction sequence Gen_W(SW_3,SW_10,SW_0,SW_6,SW_3,SW_13); Perform XOR operation on SW_4 and SW_8 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_4,T3,SM3_Tj

[52] ); Perform XOR operation on SW_5 and SW_9 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_5,T3,SM3_Tj

[53] ); Perform XOR operation on SW_6 and SW_10 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_6,T3,SM3_Tj

[54] ); Perform XOR operation on SW_7 and SW_11 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_7,T3,SM3_Tj

[55] ); Perform XOR operation on SW_8 and SW_12 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_8,T3,SM3_Tj

[56] ); Perform XOR operation on SW_9 and SW_13 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_9,T3,SM3_Tj

[57] ); Perform an XOR operation on SW_10 and SW_14 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_10,T3,SM3_Tj

[58] ); Perform an XOR operation on SW_11 and SW_15 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_11,T3,SM3_Tj

[59] ); Perform XOR operation on SW_12 and SW_0 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_12,T3,SM3_Tj

[60] ); Perform an XOR operation on SW_13 and SW_1 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_13,T3,SM3_Tj

[61] ); Perform XOR operation on SW_14 and SW_2 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_14,T3,SM3_Tj

[62] ); Perform XOR operation on SW_15 and SW_3 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_15,T3,SM3_Tj

[63] ); Perform an XOR operation on A and SW[2] to obtain A; perform an XOR operation on B and SW[3] to obtain B; perform an XOR operation on C and SW[4] to obtain C; perform an XOR operation on D and SW[5] to obtain D; perform an XOR operation on E and SW_Simd[6] to obtain E; perform an XOR operation on F and SW[7] to obtain F; perform an XOR operation on G and SW[8] to obtain G; perform an XOR operation on H and SW[9] to obtain H; (2): Group A, B, C, D, E, F, G, and H into 32-bit blocks, which are then divided into n 32-bit blocks. (3): Let the sequence number j be from 0 to 8. Extract the jth 32-bit data block from A, B, C, D, E, F, G, H and output it to the position m0 starting from the w+j*32th byte of K. Group it into 32 bits, each group + n; (4): Add w to the value of i. If i is less than klen / v, go to step (1); otherwise, go to step (5). (5): SW[0] = m0.

[0020] Furthermore, the p0(x) is specifically implemented as follows: performing a 9-bit cyclic left shift on x in 32-bit groups and performing a 17-bit cyclic left shift on x in 32-bit groups, performing an XOR operation on the cyclic left shift and the XOR operation on x, and then outputting the result to x.

[0021] Furthermore, the p1(x) is specifically implemented as follows: performing a 15-bit cyclic left shift on x in 32-bit groups and performing a 23-bit cyclic left shift on x in 32-bit groups, performing an XOR operation on the cyclic left shift and x, and then outputting the result to x.

[0022] Furthermore, Ff(A, B, C) = A XOR B XOR C. Furthermore, FF(A,B,C) = (A and B) or (A and C) or (B and C).

[0023] Further, GG(A,B,C) = C XOR(A&(B XOR C)).

[0024] Furthermore, the instructions for the status word generation instruction sequence Gen_W (SW_0, SW_7, SW_13, SW_3, SW_out, SW_10) are: SW_13 is grouped into 32 bits and circularly shifted left by 15 bits, XORed with SW_7 and SW_0, and then output to t0; SW_3 is grouped into 32 bits and circularly shifted left by 7 bits, and then output to t1; t0 is grouped into 32 bits and then XORed with SW_10 and t1, and then output to SW_out.

[0025] Furthermore, OneRoundA( A,E,B,F,C,G,D,H, w0smd,w4smd,Ti) is implemented as follows: A is grouped into 32 bits and then cyclically shifted left by 12 bits and output to the extended message word sm3ff; A, E, B, F, C, G, D, H, w0smd, w4smd, Ti all represent formal parameters, and the names of the corresponding positions will be replaced by the actual corresponding registers during the execution process; After executing Ff(E,F,G), perform unsigned addition operation on the output result of Ff(E,F,G) function, w0smd and H in 32-bit groups and output to H; Tismd is filled with Ti, Ti is grouped with sm3ff and E to perform unsigned addition operation, and then a circular left shift of 7 bits is performed and output to T2; Perform unsigned addition on H and T2 in 32-bit groups, then execute p0(x) function and output to H; After performing XOR operation on T2 and sm3ff, output to T2; Perform unsigned addition operation on D and extended message word w4smd in 32-bit groups and output to D; After executing Ff(A,B,C), perform unsigned addition operation on the output result of Ff(A,B,C) function and T2 in 32-bit groups and output to T2; For D and T2, perform unsigned addition operation in 32-bit groups and output to D; F is grouped into 32 bits and then cyclically shifted left by 19 bits and output to F; B is grouped into 32-bit groups and then cyclically shifted left by 9 bits and output to B. Furthermore, OneRoundB(A,E,B,F,C,G,D,H,Ti) is implemented as follows: A is grouped into 32 bits and then cyclically shifted left by 12 bits and output to sm3ff; After executing Ff(E,F,G), perform unsigned addition operation on the output result of Ff(E,F,G) and H in 32-bit groups and output to H; Fill Tismd with Ti, perform unsigned addition operation on Ti, sm3ff and E in 32-bit groups, perform cyclic left shift by 7 bits, and output to T2; After performing unsigned addition operation on H and T2 in 32-bit groups, execute the p0(x) function and output to H; After performing XOR operation on T2 and sm3ff, output to T2; After executing Ff(A,B,C), perform unsigned addition operation on the output value of Ff(A,B,C) and T2 in 32-bit groups and output to T2; For D and T2, perform unsigned addition operation in 32-bit groups and output to D; Execute a 19-bit circular left shift on F in 32-bit groups and output to F; B is grouped into 32-bit groups and then cyclically shifted left by 9 bits and output to B.

[0026] Furthermore, OneRounds (A,E,B,F,C,G,D,H, w4smd,Ti) is implemented as follows: A is grouped into 32 bits and then circularly shifted left by 12 bits and output to register sm3ff; After executing Ff(E,F,G), perform unsigned addition operation on the output value of Ff(E,F,G) function and H in 32-bit groups and output to H; Fill Tismd with Ti, perform unsigned addition operation on Ti, sm3ff and E in 32-bit groups, perform cyclic left shift by 7 bits and output to T2; For H and T2, perform unsigned addition operation in 32-bit groups and then execute p0(x) function, and output to H; After performing XOR operation on T2 and sm3ff, output to T2; Perform unsigned addition operation on D and w4simd in 32-bit groups and output to D; After executing Ff(A,B,C), the output value of Ff(A,B,C) and T2 are grouped into 32 bits and then unsignedly added and output to T2. For D and T2, perform unsigned addition operation in 32-bit groups and output to D; Execute a 19-bit circular left shift on F in 32-bit groups and output to F; B is grouped into 32 bits and then cyclically shifted left by 9 bits and output to B.

[0027] Furthermore, OneRoundC ( A,E,B,F,C,G,D,H, w0smd,w4smd,Ti) is implemented as follows: A is grouped into 32 bits and then cyclically shifted left by 12 bits and output to sm3ff; After executing GG(E,F,G), perform unsigned addition operation on the output value of GG(E,F,G), w0smd and H in 32-bit groups and output to H; Tismd is filled with Ti, Ti is grouped with sm3ff and E to perform unsigned addition operation, and then a circular left shift of 7 bits is performed and output to T2; For H and T2, perform unsigned addition operation on 32-bit groups and then execute the p0(x) function of the SM3 algorithm and output to H; After performing XOR operation on T2 and sm3ff, output to T2; Perform unsigned addition operation on D and w4simd in 32-bit groups and output to D; After executing FF(A,B,C), perform unsigned addition operation on the output value of FF(A,B,C) and T2 in 32-bit groups and output to T2; Perform unsigned addition on D and T2 in 32-bit groups and output to D; For F, perform a 19-bit circular left shift in 32-bit groups and output to F; For B, perform a 9-bit circular left shift in 32-bit groups and output it to B.

[0028] Embodiment 2. This embodiment provides a national secret algorithm encryption and decryption system based on a fast implementation of a key derivation function, including: a module for encrypting messages and a module for decrypting ciphertext; the key derivation function in the module for encrypting messages and the module for decrypting ciphertext is accelerated, including: first, performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits Z to obtain a 256-bit hash value H; then, batch processing the remaining 32 bits to obtain the calculation result of the key derivation function.

[0029] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. The encryption and decryption method of the national secret algorithm based on the key derivation function is quickly implemented, which is characterized by: include: The steps to encrypt a message and the steps to decrypt the ciphertext; The key derivation function in the step of encrypting the message and the step of decrypting the ciphertext is accelerated, including: first, performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits Z to obtain a 256-bit hash value H; Then, the remaining 32 bits are processed in batches to obtain the calculation result of the key derivation function.

2. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 1 is characterized in that: Before the key derivation function in the step of encrypting the message and the step of decrypting the ciphertext is accelerated, the method further includes: precalculating and saving a parameter table: SM3_Tj[64]={0x79cc4519,0xf3988a32,0xe7311465,0xce6228cb,0x9cc45197,0x3988a32f,0x7311465e, 0xe6228cbc,0xcc451979,0x988a32f3,0x311465e7,0x6228cbce,0xc451979c,0x88a32f39,0x11465e73,0x 228cbce6,0x9d8a7a87,0x3b14f50f,0x7629ea1e,0xec53d43c,0xd8a7a879,0xb14f50f3,0x629ea1e7,0xc 53d43ce,0x8a7a879d,0x14f50f3b,0x29ea1e76,0x53d43cec,0xa7a879d8,0x4f50f3b1,0x9ea1e762,0x3d4 3cec5,0x7a879d8a,0xf50f3b14,0xea1e7629,0xd43cec53,0xa879d8a7,0x50f3b14f,0xa1e7629e,0x43ce c53d,0x879d8a7a,0x0f3b14f5,0x1e7629ea,0x3cec53d4,0x79d8a7a8,0xf3b14f50,0xe7629ea1,0xcec53d 43,0x9d8a7a87,0x3b14f50f,0x7629ea1e,0xec53d43c,0xd8a7a879,0xb14f50f3,0x629ea1e7,0xc53d43ce ,0x8a7a879d,0x14f50f3b,0x29ea1e76,0x53d43cec,0xa7a879d8,0x4f50f3b1,0x9ea1e762,0x3d43cec5}.

3. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 1 is characterized in that: The key derivation function in the step of encrypting a message and the step of decrypting a ciphertext is accelerated, including: Assume that the width of the SIMD register is w bits, and the step size is n=w / 32. Each register can be split into n 32-bit blocks. Set the contents of each block in SIMD register m0 to 1, 2, ... n-1 respectively. H=SM3Update(Z), split H into 8 32-bit data blocks B0, B1....B7, fill the SIMD array SW[8], and fill SW[i] with Bi for i from 0 to 8, where i is equal to 0. (1): A = SW[0]; B = SW[1]; C = SW[2]; D = SW[3]; E = SW[4]; F = SW[5]; G = SW[6]; H = SW[7]; where A, B, C, D, E, F, G, and H represent eight SIMD registers; Execute the p1(x) function on register m0 to get the array SW_0; fill SW_1 with 0x80404000; fill SW_2 with 0x01108888; fill SW_4 with 0x10005000; fill SW_5 with 0x0022028a; fill SW_7 with 0xac545c04; fill SW_8 with 0x99cda89a; SW_0 is grouped into 32 bits and then circularly shifted left by 15 bits. Then, the p1(x) function is executed to obtain SW_3. Execute a 15-bit circular left shift on SW_3 in 32-bit groups to obtain t0; execute the p1(x) function on t0, and then perform an XOR operation with SW_0 to obtain SW_6; execute a 15-bit circular left shift on SW_6 in 32-bit groups, and then perform an XOR operation with SW_0 to obtain t0; execute p1(x) on t0, and then perform an XOR operation with SW_3 to obtain SW_9; fill SW_10 with 0xa0003000; fill SW_11 with 0x002202a8; fill SW_12 with 0x11000; fill SW_13 with 0xa4505804; among them, SW_0 to SW_15 are all SIMD registers; SW_9 is grouped into 32 bits and then cyclically shifted left by 15 bits, and then XORed with SW_3 to obtain t0; Execute p1(x) on t0, and then perform XOR operation with SW_3 and SW_12 to obtain SW_12; SW_0 is grouped into 32 bits and then cyclically shifted left by 7 bits. Then, it is XORed with SW_13 to obtain SW_13. SW_14 is filled with 0xf45691fb. T4 is filled with 0x00000220. Calling status word generation instruction sequence and calling function instruction sequence; Perform an XOR operation on A and SW[2] to obtain A; perform an XOR operation on B and SW[3] to obtain B; perform an XOR operation on C and SW[4] to obtain C; perform an XOR operation on D and SW[5] to obtain D; perform an XOR operation on E and SW_Simd[6] to obtain E; perform an XOR operation on F and SW[7] to obtain F; perform an XOR operation on G and SW[8] to obtain G; perform an XOR operation on H and SW[9] to obtain H; (2): Group A, B, C, D, E, F, G, and H into 32-bit blocks, which are then divided into n 32-bit blocks. (3): Let the sequence number j be from 0 to 8. Extract the jth 32-bit data block from A, B, C, D, E, F, G, H and output it to Kth w+j The position m0 starting from 32 bytes is grouped into 32 bits, each group + n; (4): Add w to the value of i. If i is less than klen / v, go to step (1); otherwise, go to step (5). (5): SW[0] = m0.

4. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 3 is characterized in that: The calling status word generation instruction sequence and the calling function instruction sequence include: Call the status word generation instruction sequence Gen_W (T4, SW_6, SW_12, SW_2, SW_15, SW_9); t0 = T4; Call the first round function instruction sequence OneRoundA(A,E,B,F,C,G,D,H,m0,m0,SM3_Tj[0]); Fill t1 with 0x80000000; Call the first round function instruction sequence OneRoundA(D,H,A,E,B,F,C,G,t1,t1,SM3_Tj[1]); Call the second round function instruction sequence OneRoundB(C,G,D,H,A,E,B,F,SM3_Tj[2]); Call the second round function instruction sequence OneRoundB(B,F,C,G,D,H,A,E,SM3_Tj[3]); Call the second round function instruction sequence OneRoundB(A,E,B,F,C,G,D,H,SM3_Tj[4]); Call the second round function instruction sequence OneRoundB(D,H,A,E,B,F,C,G,SM3_Tj[5]); Call the second round function instruction sequence OneRoundB(C,G,D,H,A,E,B,F,SM3_Tj[6]); Call the second round function instruction sequence OneRoundB(B,F,C,G,D,H,A,E,SM3_Tj[7]); Call the second round function instruction sequence OneRoundB(A,E,B,F,C,G,D,H,SM3_Tj[8]); Call the second round function instruction sequence OneRoundB(D,H,A,E,B,F,C,G,SM3_Tj[9]); Call the second round function instruction sequence OneRoundB(C,G,D,H,A,E,B,F,SM3_Tj[10]); Call the third round function instruction sequence OneRounds(B,F,C,G,D,H,A,E,t0,SM3_Tj[11]); Call the third round function instruction sequence OneRounds(A,E,B,F,C,G,D,H,SW_0,SM3_Tj[12]); Call the third round function instruction sequence OneRounds(D,H,A,E,B,F,C,G,SW_1,SM3_Tj[13]); Call the third round function instruction sequence OneRounds(C,G,D,H,A,E,B,F,SW_2,SM3_Tj[14]); Perform an XOR operation on t0 and SW_3 to obtain T3.

5. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 4 is characterized in that: After performing an XOR operation on t0 and SW_3 to obtain T3, it also includes: Call the first round function instruction sequence OneRoundA(B,F,C,G,D,H,A,E,t0,T3,SM3_Tj[15]); Perform an XOR operation on SW_0 and SW_4 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_0,T3,SM3_Tj[16]); Call the status word generation instruction sequence Gen_W (SW_0, SW_7, SW_13, SW_3, SW_0, SW_10); Perform an XOR operation on SW_1 and SW_5 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_1,T3,SM3_Tj[17]); call the status word generation instruction sequence Gen_W(SW_1,SW_8,SW_14,SW_4,SW_1,SW_11); Perform XOR operation on SW_2 and SW_6 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_2,T3,SM3_Tj[18]); Call the status word generation instruction sequence Gen_W (SW_2, SW_9, SW_15, SW_5, SW_2, SW_12) Perform XOR operation on SW_3 and SW_7 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_3,T3,SM3_Tj[19]); Call the status word generation instruction sequence Gen_W (SW_3, SW_10, SW_0, SW_6, SW_3, SW_13) Perform XOR operation on SW_4 and SW_8 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_4,T3,SM3_Tj[20])); call the status word generation instruction sequence Gen_W(SW_4,SW_11,SW_1,SW_7,SW_4,SW_14); Perform XOR operation on SW_5 and SW_9 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_5,T3,SM3_Tj[21]); call the status word generation instruction sequence Gen_W(SW_5,SW_12,SW_2,SW_8,SW_5,SW_15); Perform XOR operation on SW_6 and SW_10 to obtain T3; call the fourth round function instruction sequence OneRoundC(C,G,D,H,A,E,B,F,SW_6,T3,SM3_Tj[22]); Call the status word generation instruction sequence Gen_W (SW_6, SW_13, SW_3, SW_9, SW_6, SW_0) Perform XOR operation on SW_7 and SW_11 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_7,T3,SM3_Tj[23]); call the status word generation instruction sequence Gen_W(SW_7,SW_14,SW_4,SW_10,SW_7,SW_1).

6. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 5 is characterized in that: After the calling status word generation instruction sequence Gen_W (SW_7, SW_14, SW_4, SW_10, SW_7, SW_1), it also includes: Perform XOR operation on SW_8 and SW_12 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_8,T3,SM3_Tj[24]); call the status word generation instruction sequence Gen_W(SW_8,SW_15,SW_5,SW_11,SW_8,SW_2); Perform XOR operation on SW_9 and SW_13 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_9,T3,SM3_Tj[25]); call the status word generation instruction sequence Gen_W(SW_9,SW_0,SW_6,SW_12,SW_9,SW_3); Perform XOR operation on SW_10 and SW_14 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_10, T3, SM3_Tj[26]); call the status word generation instruction sequence Gen_W(SW_10, SW_1, SW_7, SW_13, SW_10, SW_4); Perform XOR operation on SW_11 and SW_15 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_11,T3,SM3_Tj[27]); call the status word generation instruction sequence Gen_W(SW_11,SW_2,SW_8,SW_14,SW_11,SW_5); Perform XOR operation on SW_12 and SW_0 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_12,T3,SM3_Tj[28]); call the status word generation instruction sequence Gen_W(SW_12,SW_3,SW_9,SW_15,SW_12,SW_6); Perform XOR operation on SW_13 and SW_1 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_13,T3,SM3_Tj[29]); call the status word generation instruction sequence Gen_W(SW_13,SW_4,SW_10,SW_0,SW_13,SW_7); Perform XOR operation on SW_14 and SW_2 to obtain T3; call the fourth round function instruction sequence OneRoundC(C, G, D, H, A, E, B, F, SW_14, T3, SM3_Tj[30]); call the status word generation instruction sequence Gen_W(SW_14, SW_5, SW_11, SW_1, SW_14, SW_8); Perform XOR operation on SW_15 and SW_3 to obtain T3; call the fourth round function instruction sequence OneRoundC(B,F,C,G,D,H,A,E,SW_15,T3,SM3_Tj[31]); call the status word generation instruction sequence Gen_W(SW_15,SW_6,SW_12,SW_2,SW_15,SW_9); Perform XOR operation on SW_0 and SW_4 to obtain T3; call the fourth round function instruction sequence OneRoundC(A,E,B,F,C,G,D,H,SW_0,T3,SM3_Tj[32]); call the status word generation instruction sequence Gen_W(SW_0,SW_7,SW_13,SW_3,SW_0,SW_10); Perform XOR operation on SW_1 and SW_5 to obtain T3; call the fourth round function instruction sequence OneRoundC(D,H,A,E,B,F,C,G,SW_1,T3,SM3_Tj[33]); call the status word generation instruction sequence Gen_W(SW_1,SW_8,SW_14,SW_4,SW_1,SW_11).

7. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 4 is characterized in that: OneRoundA( A,E,B,F,C,G,D,H, w0smd,w4smd,Ti) is implemented as follows: A is grouped into 32 bits and then cyclically shifted left by 12 bits and output to the extended message word sm3ff; A, E, B, F, C, G, D, H, w0smd, w4smd, Ti all represent formal parameters, and the names of the corresponding positions will be replaced by the actual corresponding registers during the execution process; After executing Ff(E,F,G), perform unsigned addition operation on the output result of Ff(E,F,G) function, w0smd and H in 32-bit groups and output to H; Tismd is filled with Ti, Ti is grouped with sm3ff and E to perform unsigned addition operation, and then a circular left shift of 7 bits is performed and output to T2; Perform unsigned addition on H and T2 in 32-bit groups, then execute p0(x) function and output to H; After performing XOR operation on T2 and sm3ff, output to T2; Perform unsigned addition operation on D and extended message word w4smd in 32-bit groups and output to D; After executing Ff(A,B,C), perform unsigned addition operation on the output result of Ff(A,B,C) function and T2 in 32-bit groups and output to T2; For D and T2, perform unsigned addition operation in 32-bit groups and output to D; Execute a 19-bit circular left shift on F in 32-bit groups and output to F; Perform a 9-bit cyclic left shift on B in 32-bit groups and output to B; OneRoundB( A,E,B,F,C,G,D,H, Ti) is implemented as follows: A is grouped into 32 bits and then cyclically shifted left by 12 bits and output to sm3ff; After executing Ff(E,F,G), perform unsigned addition operation on the output result of Ff(E,F,G) and H in 32-bit groups and output to H; Fill Tismd with Ti, perform unsigned addition operation on Ti, sm3ff and E in 32-bit groups, perform cyclic left shift by 7 bits, and output to T2; After performing unsigned addition operations on H and T2 in 32-bit groups, execute the p0(x) function and output to H; After performing XOR operation on T2 and sm3ff, output to T2; After executing Ff(A,B,C), perform unsigned addition operation on the output value of Ff(A,B,C) and T2 in 32-bit groups and output to T2; For D and T2, perform unsigned addition operation in 32-bit groups and output to D; Execute a 19-bit circular left shift on F in 32-bit groups and output to F; B is grouped into 32 bits and then cyclically shifted left by 9 bits and output to B.

8. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 4 is characterized in that: OneRounds ( A,E,B,F,C,G,D,H, w4smd,Ti) is implemented as follows: A is grouped into 32 bits and then circularly shifted left by 12 bits and output to register sm3ff; After executing Ff(E,F,G), perform unsigned addition operation on the output value of Ff(E,F,G) function and H in 32-bit groups and output to H; Fill Tismd with Ti, perform unsigned addition operation on Ti, sm3ff and E in 32-bit groups, perform cyclic left shift by 7 bits and output to T2; For H and T2, perform unsigned addition operation in 32-bit groups and then execute p0(x) function, and output to H; After performing XOR operation on T2 and sm3ff, output to T2; Perform unsigned addition operation on D and w4simd in 32-bit groups and output to D; After executing Ff(A,B,C), the output value of Ff(A,B,C) and T2 are grouped into 32 bits and then unsignedly added and output to T2. For D and T2, perform unsigned addition operation in 32-bit groups and output to D; Execute a 19-bit circular left shift on F in 32-bit groups and output to F; B is grouped into 32 bits and then cyclically shifted left by 9 bits and output to B.

9. The encryption and decryption method of the national secret algorithm based on the rapid implementation of the key derivation function as claimed in claim 5 is characterized in that: OneRoundC ( A,E,B,F,C,G,D,H, w0smd,w4smd,Ti) is implemented as follows: A is grouped into 32 bits and then cyclically shifted left by 12 bits and output to sm3ff; After executing GG(E,F,G), perform unsigned addition operation on the output value of GG(E,F,G), w0smd and H in 32-bit groups and output to H; Tismd is filled with Ti, Ti is grouped with sm3ff and E to perform unsigned addition operation, and then a circular left shift of 7 bits is performed and output to T2; For H and T2, perform unsigned addition operation in 32-bit groups and then execute the p0(x) function of the SM3 algorithm and output to H; After performing XOR operation on T2 and sm3ff, output to T2; Perform unsigned addition operation on D and w4simd in 32-bit groups and output to D; After executing FF(A,B,C), perform unsigned addition operation on the output value of FF(A,B,C) and T2 in 32-bit groups and output to T2; Perform unsigned addition on D and T2 in 32-bit groups and output to D; For F, perform a 19-bit circular left shift in 32-bit groups and output to F; For B, perform a 9-bit circular left shift in 32-bit groups and output it to B.

10. The encryption and decryption system of the national secret algorithm based on the key derivation function is quickly implemented, which is characterized by: include: A module for encrypting messages and a module for decrypting ciphertext; The key derivation function in the module for encrypting the message and the module for decrypting the ciphertext is accelerated, including: first, performing message expansion and iterative compression of the standard SM3 hash algorithm on the first 512 bits Z to obtain a 256-bit hash value H; Then, the remaining 32 bits are processed in batches to obtain the calculation result of the key derivation function.

Citation Information

Patent Citations

  • Processor with elliptic curve cryptographic algorithm and processing method thereof

    CN113704741A

  • SM2 encryption and decryption rapid implementation method based on SIMD

    CN115174038A

  • Hardware accelerator supporting SM2 cryptographic algorithm and acceleration method

    CN118353636A