Block ciphers

SM4

China's national 128-bit block cipher, an unbalanced Feistel design

standard Safe API

About SM4

SM4 is a block cipher. It uses a 16-byte (128-bit) key and a 16-byte (128-bit) block. Its registry entry cites GB/T 32907-2016 and ISO/IEC 18033-3:2010/Amd 1. NextSSL lists it in the standard tier and exposes it through the safe API.

Overview

SM4 (formerly SMS4) is the block cipher of the Chinese commercial cryptography standards, published in 2006 for wireless LAN security and later standardised as GB/T 32907-2016 and in ISO/IEC 18033-3. It has a 128-bit block and 128-bit key.

SM4 uses 32 rounds of an unbalanced Feistel structure on four 32-bit words. Each round XORs three words with a round key, applies a byte-wise 8-bit S-box and a linear transformation of XORed rotations, and XORs the result into the fourth word. The key schedule uses the same structure with different linear transformations and constants.

SM4 is used in Chinese TLS profiles (RFC 8998), WAPI wireless security and national banking systems. SM4 has dedicated instructions on some recent ARM and x86 processors, and it is commonly used in GCM and CCM modes defined for Chinese TLS cipher suites. Its 128-bit key gives security comparable to AES-128.

History

2006–2021
  1. SMS4 published for Chinese wireless LAN (WAPI)

  2. Specified in ISO/IEC 18033-3:2010/Amd 1

  3. Standardised as GB/T 32907-2016

  4. Added to ISO/IEC 18033-3

Security notes

No practical attacks on full SM4 are known; published cryptanalysis reaches about 23 of its 32 rounds.

Typical uses

Chinese commercial cryptography complianceTLS with SM cipher suites

Sizes

FieldBytesMeaning
key16Secret key
block16Block

Use it

from nextssl_demo import NextSSL

ns = NextSSL()              # safe API: safe and standard tiers
block = ns.call("blockcipher_encrypt", "sm4", None, key, plaintext_block)[0]

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Similar names

Looking for something else?

Frequently asked questions

What is SM4?

SM4 is a block cipher in the SM4 family. SM4 (formerly SMS4) is the block cipher of the Chinese commercial cryptography standards, published in 2006 for wireless LAN security and later standardised as GB/T 32907-2016 and in ISO/IEC 18033-3.

What are the SM4 sizes?

In NextSSL, SM4 uses: key 16 bytes, block 16 bytes.

Who designed SM4 and when?

SM4 belongs to the SM4 family, first published in 2006. Its origin: GB/T 32907-2016; ISO/IEC 18033-3.

Which standards define SM4?

SM4 is referenced by GB/T 32907-2016, ISO/IEC 18033-3:2010/Amd 1.

Is SM4 safe to use?

SM4 is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.