SM4 encryption and decryption optimization method and system

By uploading the round key to the InterPlanetary File System and setting up indexing operations in the SM4 algorithm, the problems of limited round key storage capacity and low data access efficiency are solved, realizing secure sharing of round keys and improving overall performance.

CN120915616BActive Publication Date: 2026-02-24SUZHOU HONGCUNXINJIE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511450224.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-11
Publication Date
2026-02-24
Estimated Expiration
2045-10-11

AI Technical Summary

Technical Problem

The existing SM4 algorithm suffers from limited round key storage capacity and low data access efficiency during encryption and decryption, which affects overall performance.

Method used

By encapsulating and identifying the round keys used in the encryption program and uploading them to the InterPlanetary File System, and by setting up an index operation for the round keys on ordinary functional modules, secure sharing and efficient storage of the round keys can be achieved.

Benefits of technology

It significantly improves the overall efficiency of the SM4 algorithm, overcomes the shortcomings of limited storage capacity and low data access efficiency, and realizes secure sharing of round keys.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120915616B_ABST
    Figure CN120915616B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of SM4 encryption and decryption algorithm optimization, and discloses an SM4 encryption and decryption optimization method and system, which specifically comprises a key expansion task issuing module, a round key expansion module, an encryption module, a space file system and a decryption module; the round key expansion module is composed of 32 calculation modules and a round key generation module. In the application, the round key used in an encryption program is encapsulated and identified, uploaded to the space file system for storage, and an index operation of the round key is arranged on a common function module; the pre-stored round key provides efficient technical support for a decryption program; the technical mode overcomes the defects of limited storage capacity and low data access efficiency of the common function module, realizes safe sharing of the round key, and significantly improves the overall working efficiency of the SM4 algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of SM4 encryption and decryption algorithm optimization technology, and in particular to an SM4 encryption and decryption optimization method and system. Background Technology

[0002] The SM4 block cipher algorithm, the first block symmetric cipher algorithm independently developed and adopted in my country, was published in 2006, became a national cryptography industry standard in 2012, officially became a national standard in June 2018, and was officially released as an international standard by the International Organization for Standardization (ISO / IEC) in 2021.

[0003] The SM4 algorithm has a block size of 128 bits and a key length of 128 bits. Both the encryption and key expansion algorithms employ a non-linear iterative structure, with 32 rounds of operation each. The data decryption and encryption algorithms have the same structure, except that the order of the round keys is reversed; the decryption round keys are the reverse of the encryption round keys.

[0004] The SM4 algorithm has advantages such as strong security, high efficiency and ease of hardware implementation. It is widely used in sensitive but non-confidential occasions in China, especially in the fields of communications, medical care and finance. It will gradually replace foreign block cipher standards such as Data Encryption Standard (DES) and Advanced Encryption Standard (AES). Therefore, the performance requirements for the SM4 algorithm are getting higher and higher.

[0005] This invention aims to provide a new SM4 encryption and decryption optimization scheme to improve the overall performance of the SM4 algorithm and ensure data security. Summary of the Invention

[0006] This invention provides an SM4 encryption and decryption optimization method and system, which has the advantage of improving the overall working efficiency of the SM4 algorithm and is used to solve the problem of secure sharing of round keys.

[0007] To achieve the above objectives, the present invention adopts the following technical solution:

[0008] An SM4 encryption / decryption optimization method includes the following steps:

[0009] Step 1: The encryption user publishes a round key calculation task on the key expansion task publishing module and transmits plaintext data to the encryption module;

[0010] Step 2: The key expansion task publishing module generates system parameters, fixed parameters, and an initial key for the key expansion algorithm, which are accompanied by a key version number. It also sets the encapsulation rules for the round key and the calculation rules for the iteration identifier of the round key, and transmits them to the round key expansion module.

[0011] Step 3: The round key expansion module generates a round key by executing a key expansion algorithm, and transmits the round key with the key version number to the encryption module;

[0012] The encryption module uses the round key to encrypt plaintext data and returns the generated ciphertext data and key version number to the encryption user.

[0013] The round key expansion module synchronously generates the encapsulation information and iteration identifier information of the round key. It encapsulates the encapsulation information and iteration identifier information of the round key, the system parameters and fixed parameters used for the key expansion algorithm, the encapsulation rules of the round key, the iteration identifier calculation rules of the round key, and the corresponding key version number into a key file and stores the key file in a node of the InterPlanetary File System.

[0014] The InterPlanetary File System calculates a unique hash value for the key file as an index, associates this index with the key version number, and then transmits it to the key extension task publishing module.

[0015] Step 4: The encryption user transmits the ciphertext data with the key version number to the decryption user, who then transmits the key version number to the key extension task publishing module and the ciphertext to the decryption module.

[0016] The key extension task publishing module retrieves the key file index based on the key version number, searches for the key file in the InterPlanetary File System based on the index, and transmits the key file to the decryption module. This module calculates the round key based on the information in the key file, uses the round key to decrypt the ciphertext data, and returns the generated plaintext data to the decryption user.

[0017] Preferably, the encapsulation information of the round key is obtained by XORing the round key with the system parameters used for the key expansion algorithm.

[0018] Preferably, the iteration identifier information of the round key is obtained by XORing the round key with the fixed parameters used for the key expansion algorithm.

[0019] An SM4 encryption / decryption optimization system is provided for executing SM4 encryption / decryption optimization methods. The SM4 encryption / decryption optimization system includes a key expansion task publishing module, a round key expansion module, an encryption module, an interplanetary file system, and a decryption module.

[0020] Preferably, the round key expansion module consists of 32 calculation modules and a round key generation module.

[0021] The beneficial effects of this invention are as follows:

[0022] This invention encapsulates and identifies the round keys used in the encryption program and uploads them to the InterPlanetary File System for storage. It also sets up index operations for the round keys on ordinary functional modules. The pre-stored round keys provide efficient technical support for the decryption program. This technical mode overcomes the shortcomings of limited storage capacity and low data access efficiency of ordinary functional modules, while realizing secure sharing of round keys and significantly improving the overall working efficiency of the SM4 algorithm. Attached Figure Description

[0023] Figure 1 A schematic diagram illustrating the implementation principle of the SM4 encryption / decryption optimization system. Detailed Implementation

[0024] An SM4 encryption / decryption optimization system, such as Figure 1 As shown, it includes: a key expansion task publishing module, an SM4 algorithm round key expansion module, an SM4 algorithm encryption module, an interplanetary file system, and an SM4 algorithm decryption module;

[0025] The SM4 algorithm round key expansion module includes computation modules Node-1, Node-2, ..., Node-31, Node-32 and a round key generation module;

[0026] The specific execution program for the SM4 encryption / decryption optimization method is as follows:

[0027] Program 1-1: SM4 algorithm encryption users publish SM4 algorithm round key calculation tasks on the key expansion task publishing module;

[0028] Procedure 1-2: The user transmits plaintext data to the SM4 encryption module using the SM4 algorithm.

[0029] Program 2: The key expansion task publishing module generates system parameters (FK=(FK0, FK1, FK2, FK3)) and fixed parameters (CK=(CK0, CK1, ..., CK3)) for the key expansion algorithm using a true random number generator. 31 The initial key (MK=(MK0, MK1, MK2, MK3)) and its version number are denoted as V. SM4-i ;

[0030] The key expansion task publishing module sets the encapsulation rules for round keys and the calculation rules for the iteration identifier of round keys, as follows:

[0031] The encapsulation rules for round keys are as follows:

[0032] When i = 0, 1, 2, 3, 4, 5, 6, 7, C(rk) i )=rk i ⊕FK0;

[0033] When i = 8, 9, 10, 11, 12, 13, 14, 15, C(rk) i )=rk i ⊕FK1;

[0034] When i = 16, 17, 18, 19, 20, 21, 22, 23, C(rk) i )=rk i ⊕FK2;

[0035] When i = 24, 25, 26, 27, 28, 29, 30, 31, C(rk) i )=rk i ⊕FK3;

[0036] The iteration identifier information for the round key is: ID(rk) i )=rk i ⊕CK i ;

[0037] The key expansion task publishing module transmits the system parameters, fixed parameters, key version number, round key encapsulation rules, and round key iteration identifier calculation rules used for the key expansion algorithm to the round key generation module;

[0038] Program 2-1: The key expansion task publishing module will encapsulate the system parameters FK=(FK0, FK1, FK2, FK3), fixed parameter CK0, initial key MK=(MK0, MK1, MK2, MK3), key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rk i ⊕CK i Transmitted to computing module Node-1;

[0039] Program 2-2, the key expansion task publishing module will fix the parameters CK1, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rk i ⊕CK i Transmitted to the computing module Node-2;

[0040] In procedures 2-3, the key expansion task publishing module will fix the parameters CK2, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rki ⊕CK i Transmitted to the computing module Node-3;

[0041] In Program 2-4, the key expansion task publishing module will fix the parameters CK3, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rk i ⊕CK i Transmitted to the computing module Node-4;

[0042] Program 2-5, the key expansion task publishing module will fix the parameters CK4, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rk i ⊕CK i Transmitted to the computing module Node-5;

[0043] Program 2-6, the key expansion task publishing module will fix the parameters CK5, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rk i ⊕CK i Transmitted to the computing module Node-6;

[0044] Program 2-7, the key expansion task publishing module will fix the parameters CK6, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK0) and the round key (ID(rk)) i )=rk i ⊕CK i Transmitted to the computing module Node-7;

[0045] Program 2-8, the key expansion task publishing module will fix the parameters CK7, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-8;

[0046] Program 2-9, the key expansion task publishing module will fix the parameters CK8, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-9;

[0047] Program 2-10, the key expansion task publishing module will fix the parameters CK9, key version number, and round key encapsulation rules (C(rk)). i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-10;

[0048] Program 2-11, the key expansion task publishing module will fix the parameter CK. 10 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-11;

[0049] Program 2-12, the key expansion task publishing module will fix the parameter CK. 11 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-12;

[0050] Program 2-13, the key expansion task publishing module will fix the parameter CK. 12 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to computing module Node-13;

[0051] Program 2-14, the key expansion task publishing module will fix the parameter CK.13 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-14;

[0052] Program 2-15, the key expansion task publishing module will fix the parameter CK. 14 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK1) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-15;

[0053] Program 2-16, the key expansion task publishing module will fix the parameter CK. 15 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-16;

[0054] Program 2-17, the key expansion task publishing module will fix the parameter CK. 16 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-17;

[0055] Program 2-18, the key expansion task publishing module will fix the parameter CK. 17 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-18;

[0056] Program 2-19, the key expansion task publishing module will fix the parameter CK.18 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-19;

[0057] Program 2-20, the key expansion task publishing module will fix the parameter CK. 19 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-20;

[0058] Program 2-21, the key expansion task publishing module will fix the parameter CK. 20 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-21;

[0059] Program 2-22, the key expansion task publishing module will fix the parameter CK. 21 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-22;

[0060] Program 2-23, the key expansion task publishing module will fix the parameter CK. 22 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK2) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-23;

[0061] Program 2-24, the key expansion task publishing module will fix the parameter CK.23 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-24;

[0062] Program 2-25, the key expansion task publishing module will fix the parameter CK. 24 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-25;

[0063] Program 2-26, the key expansion task publishing module will fix the parameter CK. 25 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-26;

[0064] Program 2-27, the key expansion task publishing module will fix the parameter CK. 26 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-27;

[0065] Program 2-28, the key expansion task publishing module will fix the parameter CK. 27 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-28;

[0066] Program 2-29, the key expansion task publishing module will fix the parameter CK28 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-29;

[0067] Program 2-30, the key expansion task publishing module will fix the parameter CK. 29 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-30;

[0068] Program 2-31, the key expansion task publishing module will fix the parameter CK. 30 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-31;

[0069] Program 2-32, the key expansion task publishing module will fix the parameter CK. 31 Encapsulation rules for key version number and round key (C(rk)) i )=rk i The iterative identifier calculation rule for ⊕FK3) and round keys (ID(rk) i )=rk i ⊕CK i Transmitted to the computing module Node-32;

[0070] In Program 3-1, according to the key expansion algorithm, the computing module Node-1 calculates the round key rk0 by executing the key expansion operation program, generates the four intermediate key state parameters for the first round of iteration by sliding update, and synchronously executes Program 3-1a to transmit them to the computing module Node-2. Then, Program 3-1b is executed to calculate the encapsulation information C(rk0)=rk0⊕FK0 and the iteration identification information ID(rk0)=rk0⊕CK0 of the round key rk0 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0071] In program 3-2, according to the key expansion algorithm, the computing module Node-2 calculates the round key rk1 by executing the key expansion operation program, generates the four intermediate key state parameters for the second round of iteration through sliding update, and synchronously executes program 3-2a to transmit them to the computing module Node-3. Then, program 3-2b is executed to calculate the encapsulation information C(rk1)=rk1⊕FK0 and the iteration identification information ID(rk1)=rk1⊕CK1 of the round key rk1 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0072] In program 3-3, according to the key expansion algorithm, the computing module Node-3 calculates the round key rk2 by executing the key expansion operation program, generates the four intermediate key state parameters for the third round of iteration by sliding update, and synchronously executes program 3-3a to transmit them to the computing module Node-4. Then, program 3-3b is executed to calculate the encapsulation information C(rk2)=rk2⊕FK0 and the iteration identification information ID(rk2)=rk2⊕CK2 of the round key rk2 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0073] In procedure 3-4, according to the key expansion algorithm, the computing module Node-4 calculates the round key rk3 by executing the key expansion operation program, generates the four intermediate key state parameters for the fourth round of iteration through sliding update, and synchronously executes procedure 3-4a to transmit them to the computing module Node-5. Then, procedure 3-4b is executed to calculate the encapsulation information C(rk3)=rk3⊕FK0 and the iteration identification information ID(rk3)=rk3⊕CK3 of the round key rk3 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0074] In procedure 3-5, according to the key expansion algorithm, the computing module Node-5 calculates the round key rk4 by executing the key expansion operation program, generates the four intermediate key state parameters for the fifth round of iteration through sliding update, and synchronously executes procedure 3-5a to transmit them to the computing module Node-6. Then, procedure 3-5b is executed to calculate the encapsulation information C(rk4)=rk4⊕FK0 and the iteration identification information ID(rk4)=rk4⊕CK4 of the round key rk4 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0075] In procedure 3-6, according to the key expansion algorithm, the computing module Node-6 calculates the round key rk5 by executing the key expansion operation program, generates the four intermediate key state parameters for the sixth round of iteration through sliding update, and synchronously executes procedure 3-6a to transmit them to the computing module Node-7. Then, procedure 3-6b is executed to calculate the encapsulation information C(rk5)=rk5⊕FK0 and the iteration identification information ID(rk5)=rk5⊕CK5 of the round key rk5 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0076] In procedure 3-7, according to the key expansion algorithm, the computing module Node-7 calculates the round key rk6 by executing the key expansion operation program, generates the four intermediate key state parameters for the seventh round of iteration through sliding update, and synchronously executes procedure 3-7a to transmit them to the computing module Node-8. Then, procedure 3-7b is executed to calculate the encapsulation information C(rk6)=rk6⊕FK0 and the iteration identification information ID(rk6)=rk6⊕CK6 of the round key rk6 and transmit them to the round key generation module, and synchronously transmit the corresponding key version number.

[0077] In procedure 3-8, according to the key expansion algorithm, the computing module Node-8 calculates the round key rk7 by executing the key expansion operation program, generates the four intermediate key state parameters for the eighth round of iteration through sliding update, and synchronously executes procedure 3-8a to transmit them to the computing module Node-9. Then, procedure 3-8b is executed to calculate the encapsulation information C(rk7)=rk7⊕FK0 and the iteration identification information ID(rk7)=rk7⊕CK7 of the round key rk7 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0078] In procedure 3-9, according to the key expansion algorithm, the computing module Node-9 calculates the round key rk8 by executing the key expansion operation program, generates the four intermediate key state parameters for the ninth round of iteration through sliding update, and synchronously executes procedure 3-9a to transmit them to the computing module Node-10. Then, procedure 3-9b is executed to calculate the encapsulation information C(rk8)=rk8⊕FK1 and the iteration identification information ID(rk8)=rk8⊕CK8 of the round key rk8 and transmit them to the round key generation module, and synchronously transmit the corresponding key version number.

[0079] In program 3-10, according to the key expansion algorithm, the computing module Node-10 calculates the round key rk9 by executing the key expansion operation program, generates the four intermediate key state parameters for the tenth round of iteration through sliding update, and synchronously executes program 3-10a to transmit them to the computing module Node-11. Then, program 3-10b is executed to calculate the encapsulation information C(rk9)=rk9⊕FK1 and the iteration identification information ID(rk9)=rk9⊕CK9 of the round key rk9 and transmits them to the round key generation module, and synchronously transmits the corresponding key version number.

[0080] In program 3-11, based on the key expansion algorithm, the computation module Node-11 calculates the round key rk by executing the key expansion operation program. 10 The sliding update generates the four intermediate key state parameters for the eleventh iteration and synchronously executes program 3-11a, which is then transmitted to the computing module Node-12. Afterwards, program 3-11b is executed to calculate the round key rk. 10 Encapsulation information C(rk) 10 )=rk 10 ⊕FK1 and iteration identifier information ID(rk) 10 )=rk 10 ⊕CK 10 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0081] In program 3-12, based on the key expansion algorithm, the computing module Node-12 calculates the round key rk by executing the key expansion operation program. 11 The sliding update generates the four intermediate key state parameters for the twelfth round iteration and synchronously executes program 3-12a, which is then transmitted to the computing module Node-13. Afterwards, program 3-12b is executed to calculate the round key rk. 11 Encapsulation information C(rk) 11 )=rk 11 ⊕FK1 and iteration identifier information ID(rk) 11 )=rk 11 ⊕CK 11 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0082] In program 3-13, based on the key expansion algorithm, the computation module Node-13 calculates the round key rk by executing the key expansion operation program. 12 The sliding update generates the four intermediate key state parameters for the thirteenth iteration and synchronously executes program 3-13a, transmitting them to the computing module Node-14. Then, program 3-13b is executed to calculate the round key rk. 12 Encapsulation information C(rk) 12 )=rk 12⊕FK1 and iteration identifier information ID(rk) 12 )=rk 12 ⊕CK 12 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0083] In program 3-14, based on the key expansion algorithm, the computation module Node-14 calculates the round key rk by executing the key expansion operation program. 13 The sliding update generates the four intermediate key state parameters for the fourteenth iteration and synchronously executes program 3-14a, transmitting them to the computing module Node-15. Then, program 3-14b is executed to calculate the round key rk. 13 Encapsulation information C(rk) 13 )=rk 13 ⊕FK1 and iteration identifier information ID(rk) 13 )=rk 13 ⊕CK 13 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0084] In program 3-15, based on the key expansion algorithm, the computation module Node-15 calculates the round key rk by executing the key expansion operation program. 14 The sliding update generates the four intermediate key state parameters for the fifteenth iteration and synchronously executes program 3-15a, transmitting them to the computing module Node-16. Then, program 3-15b is executed to calculate the round key rk. 14 Encapsulation information C(rk) 14 )=rk 14 ⊕FK1 and iteration identifier information ID(rk) 14 )=rk 14 ⊕CK 14 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0085] In program 3-16, based on the key expansion algorithm, the computing module Node-16 calculates the round key rk by executing the key expansion operation program. 15 The sliding update generates the four intermediate key state parameters for the sixteenth iteration and synchronously executes program 3-16a, which is then transmitted to the computing module Node-17. Afterwards, program 3-16b is executed to calculate the round key rk. 15 Encapsulation information C(rk) 15 )=rk 15 ⊕FK1 and iteration identifier information ID(rk) 15 )=rk 15 ⊕CK 15 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0086] In program 3-17, based on the key expansion algorithm, the computing module Node-17 calculates the round key rk by executing the key expansion operation program. 16 The sliding update generates the four intermediate key state parameters for the seventeenth iteration and synchronously executes program 3-17a, transmitting them to the computing module Node-18. Then, program 3-17b is executed to calculate the round key rk. 16 Encapsulation information C(rk) 16 )=rk 16 ⊕FK2 and Iteration Identifier ID (rk) 16 )=rk 16 ⊕CK 16 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0087] In program 3-18, based on the key expansion algorithm, the computing module Node-18 calculates the round key rk by executing the key expansion operation program. 17 The sliding update generates the four intermediate key state parameters for the eighteenth iteration and synchronously executes program 3-18a, transmitting them to the computing module Node-19. Then, program 3-18b is executed to calculate the round key rk. 17 Encapsulation information C(rk) 17 )=rk 17 ⊕FK2 and Iteration Identifier ID (rk) 17 )=rk 17 ⊕CK 17 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0088] Program 3-19: Based on the key expansion algorithm, the computing module Node-19 calculates the round key rk by executing the key expansion operation program. 18 The sliding update generates the four intermediate key state parameters for the nineteenth iteration and synchronously executes program 3-19a, transmitting them to the computing module Node-20. Then, program 3-19b is executed to calculate the round key rk. 18 Encapsulation information C(rk) 18 )=rk 18 ⊕FK2 and Iteration Identifier ID (rk) 18 )=rk 18 ⊕CK 18 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0089] In program 3-20, based on the key expansion algorithm, the computing module Node-20 calculates the round key rk by executing the key expansion operation program. 19The sliding update generates the four intermediate key state parameters for the twentieth round of iteration and synchronously executes program 3-20a, which is then transmitted to the computing module Node-21. Afterwards, program 3-20b is executed to calculate the round key rk. 19 Encapsulation information C(rk) 19 )=rk 19 ⊕FK2 and Iteration Identifier ID (rk) 19 )=rk 19 ⊕CK 19 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0090] In program 3-21, based on the key expansion algorithm, the computing module Node-21 calculates the round key rk by executing the key expansion operation program. 20 The sliding update generates the four intermediate key state parameters for the twenty-first round of iterations and synchronously executes program 3-21a, which is then transmitted to the computing module Node-22. Afterwards, program 3-21b is executed to calculate the round key rk. 20 Encapsulation information C(rk) 20 )=rk 20 ⊕FK2 and Iteration Identifier ID (rk) 20 )=rk 20 ⊕CK 20 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0091] In program 3-22, based on the key expansion algorithm, the computing module Node-22 calculates the round key rk by executing the key expansion operation program. 21 The sliding update generates the four intermediate key state parameters for the twenty-second round of iterations and synchronously executes program 3-22a, which is then transmitted to the computing module Node-23. Afterwards, program 3-22b is executed to calculate the round key rk. 21 Encapsulation information C(rk) 21 )=rk 21 ⊕FK2 and Iteration Identifier ID (rk) 21 )=rk 21 ⊕CK 21 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0092] In program 3-23, based on the key expansion algorithm, the computation module Node-23 calculates the round key rk by executing the key expansion operation program. 22 The sliding update generates the four intermediate key state parameters for the twenty-third round of iterations and synchronously executes program 3-23a, which is then transmitted to the computing module Node-24. Afterwards, program 3-23b is executed to calculate the round key rk. 22 Encapsulation information C(rk) 22)=rk 22 ⊕FK2 and Iteration Identifier ID (rk) 22 )=rk 22 ⊕CK 22 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0093] In program 3-24, based on the key expansion algorithm, the computation module Node-24 calculates the round key rk by executing the key expansion operation program. 23 The sliding update generates the four intermediate key state parameters for the twenty-fourth round of iteration and synchronously executes program 3-24a, which is then transmitted to the computing module Node-25. Afterwards, program 3-24b is executed to calculate the round key rk. 23 Encapsulation information C(rk) 23 )=rk 23 ⊕FK2 and Iteration Identifier ID (rk) 23 )=rk 23 ⊕CK 23 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0094] Program 3-25: Based on the key expansion algorithm, the computing module Node-25 calculates the round key rk by executing the key expansion operation program. 24 The sliding update generates the four intermediate key state parameters for the twenty-fifth round of iteration and synchronously executes program 3-25a, which is then transmitted to the computing module Node-26. Afterwards, program 3-25b is executed to calculate the round key rk. 24 Encapsulation information C(rk) 24 )=rk 24 ⊕FK3 and Iteration Identifier ID (rk) 24 )=rk 24 ⊕CK 24 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0095] Program 3-26: Based on the key expansion algorithm, the computing module Node-26 calculates the round key rk by executing the key expansion operation program. 25 The sliding update generates the four intermediate key state parameters for the twenty-sixth iteration and synchronously executes program 3-26a, transmitting them to the computing module Node-27. Then, program 3-26b is executed to calculate the round key rk. 25 Encapsulation information C(rk) 25 )=rk 25 ⊕FK3 and Iteration Identifier ID (rk) 25 )=rk 25 ⊕CK 25It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0096] In program 3-27, based on the key expansion algorithm, the computation module Node-27 calculates the round key rk by executing the key expansion operation program. 26 The sliding update generates the four intermediate key state parameters for the twenty-seventh iteration and synchronously executes program 3-27a, transmitting them to the computing module Node-28. Then, program 3-27b is executed to calculate the round key rk. 26 Encapsulation information C(rk) 26 )=rk 26 ⊕FK3 and Iteration Identifier ID (rk) 26 )=rk 26 ⊕CK 26 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0097] Program 3-28: Based on the key expansion algorithm, the computing module Node-28 calculates the round key rk by executing the key expansion operation program. 27 The sliding update generates the four intermediate key state parameters for the twenty-eighth iteration and synchronously executes program 3-28a, transmitting them to the computing module Node-29. Then, program 3-28b is executed to calculate the round key rk. 27 Encapsulation information C(rk) 27 )=rk 27 ⊕FK3 and Iteration Identifier ID (rk) 27 )=rk 27 ⊕CK 27 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0098] Program 3-29: Based on the key expansion algorithm, the computing module Node-29 calculates the round key rk by executing the key expansion operation program. 28 The sliding update generates the four intermediate key state parameters for the twenty-ninth iteration and synchronously executes program 3-29a, transmitting them to the computing module Node-30. Then, program 3-29b is executed to calculate the round key rk. 28 Encapsulation information C(rk) 28 )=rk 28 ⊕FK3 and Iteration Identifier ID (rk) 28 )=rk 28 ⊕CK 28 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0099] In program 3-30, based on the key expansion algorithm, the computing module Node-30 calculates the round key rk by executing the key expansion operation program.29 The sliding update generates the four intermediate key state parameters for the thirtieth round of iteration and synchronously executes program 3-30a, which is then transmitted to the computing module Node-31. Afterwards, program 3-30b is executed to calculate the round key rk. 29 Encapsulation information C(rk) 29 )=rk 29 ⊕FK3 and Iteration Identifier ID (rk) 29 )=rk 29 ⊕CK 29 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0100] In program 3-31, based on the key expansion algorithm, the computation module Node-31 calculates the round key rk by executing the key expansion operation program. 30 The sliding update generates the four intermediate key state parameters for the thirty-first iteration and synchronously executes program 3-31a, transmitting them to the computing module Node-32. Then, program 3-31b is executed to calculate the round key rk. 30 Encapsulation information C(rk) 30 )=rk 30 ⊕FK3 and Iteration Identifier ID (rk) 30 )=rk 30 ⊕CK 30 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0101] In program 3-32, based on the key expansion algorithm, the computing module Node-32 calculates the round key rk by executing the key expansion operation program. 31 Then execute program 3-32 to calculate the round key rk. 31 Encapsulation information C(rk) 31 )=rk 31 ⊕FK3 and Iteration Identifier ID (rk) 31 )=rk 31 ⊕CK 31 It is then transmitted to the round key generation module, and the corresponding key version number is transmitted synchronously.

[0102] Program 4: The round key generation module executes the following program:

[0103] (1) Calculate the XOR value rk of the encapsulated information. 0-1 =C(rk0)⊕FK0;

[0104] Calculate the XOR operation value rk of the iterative identifier information. 0-2 =ID(rk0)⊕CK0;

[0105] If rk 0-1 =rk0-2 When it is established, then rk is determined. 0-1 or rk 0-2 The round key is rk0;

[0106] ...

[0107] (32) Calculate the XOR value rk of the encapsulated information. 31-1 =C(rk 31 )⊕FK3;

[0108] Calculate the XOR operation value rk of the iterative identifier information. 31-2 =ID(rk 31 )⊕CK 31 ;

[0109] If rk 31-1 =rk 31-2 When it is established, then rk is determined. 31-1 or rk 31-2 For the round key rk 31 ;

[0110] Based on this, the round key {rk0, rk1, rk2, ..., rk} is generated. 29 rk 30 rk 31 The program 4-1 is executed and transmitted to the SM4 algorithm encryption module, and the corresponding key version number is transmitted synchronously.

[0111] Then, program 4-2 is executed, which stores the SM4 key file, consisting of the encapsulation information and iteration identification information of the round key, the system parameters and fixed parameters used for the key expansion algorithm, the encapsulation rules of the round key and the iteration identification calculation rules of the round key, and the corresponding key version number, to the node of the InterPlanetary File System. After successful storage, the InterPlanetary File System calculates a unique hash value for the SM4 key file, associates the hash value with the key version number as the index of the SM4 key file, and transmits it to the key expansion task publishing module for storage.

[0112] In program 5, the SM4 algorithm encryption module uses the round key to encrypt the plaintext data and returns the generated ciphertext data to the SM4 algorithm encryption user, and synchronously transmits the corresponding key version number to the SM4 algorithm encryption user.

[0113] In step 7, the SM4 algorithm encryption user transmits the ciphertext data along with the key version number to the SM4 algorithm decryption user; the SM4 algorithm decryption user first executes step 7-1 to transmit the key version number to the key extension task publishing module, and then executes step 7-2 to transmit the ciphertext to the SM4 algorithm decryption module.

[0114] The key extension task publishing module retrieves the SM4 key file index based on the key version number, starts executing program 8, retrieves file blocks in the InterPlanetary File System based on the index hash value and reconstructs them to obtain the SM4 key file, and then executes program 9 to transfer the SM4 key file to the SM4 algorithm decryption module;

[0115] Program 10: The SM4 algorithm decryption module calculates the round key based on the information in the SM4 key file, uses the round key to decrypt the ciphertext data, and returns the generated plaintext data to the SM4 algorithm decryption user. This concludes the SM4 encryption and decryption optimization program.

Claims

1. An SM4 encryption / decryption optimization method, characterized in that, Includes the following steps: Step 1: The encryption user publishes a round key calculation task on the key expansion task publishing module and transmits plaintext data to the encryption module; Step 2: The key expansion task publishing module generates system parameters, fixed parameters, and an initial key for the key expansion algorithm, which are accompanied by a key version number. It also sets the encapsulation rules for the round key and the calculation rules for the iteration identifier of the round key, and transmits them to the round key expansion module. Step 3: The round key expansion module generates a round key by executing a key expansion algorithm, and transmits the round key with the key version number to the encryption module; The encryption module uses the round key to encrypt plaintext data and returns the generated ciphertext data and key version number to the encryption user. The round key expansion module synchronously generates the encapsulation information and iteration identifier information of the round key. It encapsulates the encapsulation information and iteration identifier information of the round key, the system parameters and fixed parameters used for the key expansion algorithm, the encapsulation rules of the round key, the iteration identifier calculation rules of the round key, and the corresponding key version number into a key file and stores the key file in a node of the InterPlanetary File System. The InterPlanetary File System calculates a unique hash value for the key file as an index, associates this index with the key version number, and then transmits it to the key extension task publishing module. Step 4: The encryption user transmits the ciphertext data with the key version number to the decryption user, who then transmits the key version number to the key extension task publishing module and the ciphertext to the decryption module. The key extension task publishing module retrieves the key file index based on the key version number, searches for the key file in the InterPlanetary File System based on the index, and transmits the key file to the decryption module. This module calculates the round key based on the information in the key file, uses the round key to decrypt the ciphertext data, and returns the generated plaintext data to the decryption user.

2. The SM4 encryption / decryption optimization method according to claim 1, characterized in that, The encapsulation information of the round key is obtained by XORing the round key with the system parameters used for the key expansion algorithm.

3. The SM4 encryption / decryption optimization method according to claim 1, characterized in that, The iteration identifier information of the round key is obtained by XORing the round key with the fixed parameters used in the key expansion algorithm.

4. An SM4 encryption / decryption optimization system, used to execute the SM4 encryption / decryption optimization method according to any one of claims 1-3, characterized in that, The SM4 encryption and decryption optimization system includes a key expansion task publishing module, a round key expansion module, an encryption module, an interplanetary file system, and a decryption module.

5. The SM4 encryption / decryption optimization system according to claim 4, characterized in that, The round key expansion module consists of 32 computation modules and a round key generation module.

Citation Information

Patent Citations

  • High-performance block cipher construction method and device, electronic equipment and storage medium

    CN116318631A

  • SM4 heterogeneous acceleration system based on FPGA

    CN120675698A