The SM4 cipher has a key size and a block size of 128 bits each.56 Encryption or decryption of one block of data is composed of 32 rounds. A non-linear key schedule is used to produce the round keys and the decryption uses the same round keys as for encryption, except that they are in reversed order.
The length of encryption keys is 128 bits, represented as M K = ( M K 0 , M K 1 , M K 2 , M K 3 ) {\displaystyle MK=(MK_{0},\ MK_{1},\ MK_{2},\ MK_{3})} , in which M K i ( i = 0 , 1 , 2 , 3 ) {\displaystyle MK_{i}\ (i=0,\ 1,\ 2,\ 3)} is a 32-bit word. The round keys are represented by ( r k 0 , r k 1 , … , r k 31 ) {\displaystyle (rk_{0},\ rk_{1},\ \ldots ,\ rk_{31})} , where each r k i ( i = 0 , … , 31 ) {\displaystyle rk_{i}(i=0,\ \ldots ,\ 31)} is a word. It is generated by the encryption key and the following parameters:
F K i {\displaystyle FK_{i}} and C K i {\displaystyle CK_{i}} are words, used to generate the round keys.
Each round are computed from the four previous round outputs X i , X i + 1 , X i + 2 , X i + 3 {\displaystyle X_{i},X_{i+1},X_{i+2},X_{i+3}} such that: X i + 4 = X i ⊕ F ( X i + 1 ⊕ X i + 2 ⊕ X i + 3 ⊕ r k i ) {\displaystyle X_{i+4}=X_{i}\oplus F(X_{i+1}\oplus X_{i+2}\oplus X_{i+3}\oplus rk_{i})}
Where F {\displaystyle F} is a substitution function composed of a non-linear transform, the S-box and linear transform L {\displaystyle L}
Further information: AES instruction set § Application beyond AES
SM4's S-box is fixed for 8-bit input and 8-bit output, noted as Sbox(). As with Advanced Encryption Standard (AES), the S-box is based on the multiplicative inverse over GF(28). The affine transforms and polynomial bases are different from that of AES, but due to affine isomorphism it can be calculated efficiently given an AES S-Box.7
On March 21, 2012, the Chinese government published the industrial standard "GM/T 0002-2012 SM4 Block Cipher Algorithm", officially renaming SMS4 to SM4.8
A description of SM4 in English is available as an Internet Draft. It contains a reference implementation in ANSI C.9
SM4 is part of the ARMv8.4-A expansion to the ARM architecture.10 SM4 support for the RISC-V architecture was ratified in 2021 as the Zksed extension.11
SM4 is supported by Intel processors, starting from Arrow Lake S, Lunar Lake, Diamond Rapids and Clearwater Forest.12
"Announcement No.23 of the State Cryptography Administration" (in Chinese (China)). The Office of the State Commercial Code Administration (OSCCA). 2012-03-21. Archived from the original on 2016-08-14. Retrieved 2016-07-24. https://web.archive.org/web/20160814151056/http://www.oscca.gov.cn/News/201204/News_1228.htm ↩
Martinkauppi, Louise Bergman; He, Qiuping; Ilie, Dragos (June 2020). "On the Design and Performance of Chinese OSCCA-approved Cryptographic Algorithms". 2020 13th International Conference on Communications (COMM). pp. 119–124. doi:10.1109/COMM48946.2020.9142035. ISBN 978-1-7281-5611-8. S2CID 220668639. 978-1-7281-5611-8 ↩
Yang, P (March 2021). RFC 8998. IETF. doi:10.17487/RFC8998. Retrieved 2022-07-30. https://datatracker.ietf.org/doc/html/rfc8998 ↩
Lu Shuwang. Overview on SM4 Algorithm[J]. Journal of Information Security Research, 2016, 2(11): 995-1007. http://ris.sic.gov.cn/CN/Y2016/V2/I11/995 ↩
"无线局域网产品使用的 SMS4 密码算法" (PDF) (in Simplified Chinese). State Cryptography Administration of the People's Republic of China. Archived from the original (PDF) on 2007-07-10. https://web.archive.org/web/20070710015158/http://www.oscca.gov.cn/UpFile/200621016423197990.pdf ↩
SMS4 Encryption Algorithm for Wireless Networks http://eprint.iacr.org/2008/329.pdf ↩
Saarinen, Markku-Juhani O. (17 April 2020). "mjosaarinen/sm4ni: Demonstration that AES-NI instructions can be used to implement the Chinese Encryption Standard SM4". GitHub. https://github.com/mjosaarinen/sm4ni ↩
Tse, Ronald; Kit, Wong; Saarinen, Markku-Juhani (22 April 2018). "The SM4 Blockcipher Algorithm And Its Modes Of Operations". tools.ietf.org. https://tools.ietf.org/html/draft-ribose-cfrg-sm4-10 ↩
"Introducing 2017's extensions to the Arm Architecture". community.arm.com. 2 November 2017. https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/introducing-2017s-extensions-to-the-arm-architecture ↩
"RISC-V Cryptography Extensions Task Group Announces Public Review of the Scalar Cryptography Extensions". riscv.org. https://riscv.org/blog/2021/09/risc-v-cryptography-extensions-task-group-announces-public-review-of-the-scalar-cryptography-extensions ↩
"Intel® Architecture Instruction Set Extensions and Future Features" (PDF). Intel Corporation. December 2024. p. 1-3. Retrieved 2 February 2025. https://cdrdv2-public.intel.com/843860/architecture-instruction-set-extensions-programming-reference-dec-24.pdf ↩