51NAV
Explained

SM4 vs AES: Parameter Differences Compared

Both are 128-bit block ciphers, but their key sizes, structure, and standards differ. Here is a side-by-side of the parameters that actually matter when you pick one.

3 min read Intermediate
#sm4 #aes #encryption #crypto
Table of Contents

Two 128-bit block ciphers

SM4 and AES both operate on 128-bit blocks. Past that, they diverge. The confusion usually comes from assuming “block cipher” means “interchangeable” — it does not. The parameters below change how you implement and validate each one.

Side-by-side parameters

ParameterSM4AES
Block size128 bits128 bits
Key size128 bits only128 / 192 / 256 bits
Rounds32 (unbalanced Feistel)10 / 12 / 14 (SPN)
StructureFeistel networkSubstitution–permutation network
StandardGM/T 0002 (China)FIPS 197 (NIST)
S-boxfixed, 8-bitfixed, 8-bit (algebraic)
Typical modesECB, CBC, CTR, GCM, CCMECB, CBC, CTR, GCM, CCM, XTS

Key size is the first fork

AES lets you pick 128, 192, or 256-bit keys. SM4 does not — it is always 128 bits. If a spec or auditor demands AES-256, SM4 cannot satisfy it, and you must use AES.

AES-128  -> 10 rounds, 128-bit key
AES-192  -> 12 rounds, 192-bit key
AES-256  -> 14 rounds, 256-bit key
SM4      -> 32 rounds, 128-bit key  (fixed)

Round structure

AES is a substitution–permutation network: layers of byte substitution, row shifting, column mixing, and key addition. SM4 is an unbalanced Feistel network with 32 rounds and a single non-linear substitution per round. Both are well studied; the practical difference is implementation detail, not security posture.

Mode and padding still matter

Neither cipher defines padding — that comes from the mode. ECB needs padding (don’t use ECB), CBC needs PKCS#7 padding and a random IV, and GCM is an AEAD mode that also gives you integrity, not just confidentiality.

// conceptual: same mode, different key length
aes.encrypt(plaintext, aes256Key, { mode: 'gcm', iv });
sm4.encrypt(plaintext, sm4Key128, { mode: 'gcm', iv });

When to use which

  • Use AES when you need 192/256-bit keys, broadest library support, or FIPS/NIST alignment.
  • Use SM4 when a Chinese national standard (GM/T 0002) is required, or the other end only speaks SM4.

Try both

Encrypt and decrypt with each to see the parameters side by side:

Next steps

Frequently asked questions

Is SM4 weaker than AES?

No public break of either at standard parameters. They are different designs from different standards bodies (China's GM/T 0002 vs NIST FIPS 197). Choose based on compliance and interoperability, not on a presumed strength gap.

Can SM4 use a 256-bit key?

No. SM4 fixes the key at 128 bits. If you need 192- or 256-bit keys, that is AES's territory.

Do they support the same modes?

Both support the standard modes (ECB, CBC, CTR, GCM, etc.). The difference is in the key length and round structure, not in which modes exist.

Guide Info

Category
Explained
Difficulty
Intermediate
Reading Time
3 min
Tags
#sm4 #aes #encryption #crypto

Next guide

Unix Timestamp: 10 Digits or 13? Seconds vs Milliseconds

A Unix timestamp is either 10 digits (seconds) or 13 (milliseconds). Mixing them up shifts dates by a factor of 1000 — here is how to tell and convert.

View Next Guide