Skip to content
Security2026-09-103 min read

Chinese National Cryptography (SM2/SM3/SM4/SM9/ZUC): A Developer's Introduction

What "Guomi" (国密) is

Chinese national cryptography (商用密码, "SM" = commercial secrets) is the set of algorithm standards published by the Chinese Cryptography Administration. It is not a new branch of cryptography — the algorithms rest on the same foundations as their international counterparts (elliptic curves, hashes, block ciphers) but are China-designed standards used for cryptographic self-sufficiency and compliance.

What each algorithm does

| Algorithm | Type | International analog | Use | |---|---|---|---| | SM2 | ECC public-key | RSA / ECDSA | signatures, key exchange, public-key encryption | | SM3 | hash | SHA-256 | digests, integrity | | SM4 | block cipher | AES-128 | symmetric encryption | | SM9 | identity-based | IBE | use an identity (email/phone) directly as a public key | | ZUC | stream cipher | Snow 3G / AES-CTR | 4G/5G traffic encryption |

Developers mostly meet the first three (the "SM trio"); SM9 and ZUC serve niches (identity crypto, telecom).

Mapping to international algorithms

signing/encryption:  RSA, ECDSA  <->  SM2 (256-bit ECC)
digest:              SHA-256     <->  SM3 (256-bit output)
symmetric:           AES-128     <->  SM4 (128-bit block/key)
protocol suite:      TLS-RSA/AES <->  TLCP (ECC-SM4-SM3 ciphersuite)

Strength equivalences (for intuition):

  • SM2 256-bit ≈ RSA 3072-bit
  • SM3 ≈ SHA-256
  • SM4 ≈ AES-128

Who uses it

  1. Government: e-seals, e-licenses, government cloud (a web of GB/T standards assumes GM)
  2. Finance: banking core migration, UnionPay standards, digital-currency work
  3. 等保 2.0 (classified protection) level 3+: the most common driver — commercial cryptography becomes mandatory
  4. SOEs / critical infrastructure: energy, transport, water
  5. 密评 (crypto application security assessment): passing requires algorithm compliance

How developers implement it, by layer

Application layer (Java/Go/Node/frontend)

  • Java: BouncyCastle (org.bouncycastle.crypto.engines) or hutool's SmUtil
  • JS/Node: sm-crypto (pure JS, encrypt/decrypt/sign)
  • Go: github.com/tjfoc/gmssl, github.com/emmansun/gmsm

Protocol layer (GM HTTPS)

Standard OpenSSL lacks GM TLS. Options:

  • Tongsuo (formerly BabaSSL): Ant-open-sourced, OpenSSL-compatible syntax, GM TLS 1.3 and dual certificates
  • GmSSL: Peking University's fork implementing TLCP (GB/T 38656)
  • Dual-certificate mode: SM2 + RSA in parallel, negotiated per client — the transition-period default

Hardware layer

Production key management requires certified crypto products: PCIe crypto cards, UKeys, cloud HSMs (GM editions from cloud vendors). Software implementations are for development and debugging — production signing keys should never leave certified hardware, a hard requirement of the assessment.

Learn by doing with online tools

One round-trip beats ten documentation reads. This site hosts a full GM toolkit (browser-local, nothing uploaded):

  • SM2 Encrypt/Sign: generate a keypair → encrypt → decrypt → sign → verify, the complete public-key flow; doubles as a verified counterparty during integration
  • SM3 Hash Calculator: reproduce the standard vector (SM3("abc") = 66c7f0f4...) to rule out encoding issues
  • SM4 Encrypt/Decrypt: compare ECB/CBC and see ECB's pattern leakage first-hand

Three FAQs

Q: Are GM algorithms actually secure, or "weakened domestic crypto"? SM2/SM3/SM4 designs passed open international review (SM4 is published as IETF RFC 8998); there are no practical attacks. Strength is on par with international equivalents. "GM = weak" is a misconception.

Q: Does my system have to adopt GM? Two signals: 等保 level (3+ almost always means yes) and industry regulator (government/finance/SOE). Consumer internet generally has no mandate.

Q: How big is a migration? Three tiers: algorithm-layer swaps (RSA→SM2 calls) are days; GM TLS (Tongsuo + GM certificates) are weeks; full assessment compliance (hardware + governance) is a months-long program.

Checklist

  1. Know the trio: SM2 signs/encrypts, SM3 digests, SM4 encrypts symmetrically
  2. Compliance test: 等保 level 3+ or government/finance → GM required
  3. Debug integration with online tools before touching the protocol layer
  4. Production private keys live in certified hardware; software is for development
  5. GM TLS via Tongsuo/GmSSL with dual certificates for the transition

Provided by ToolVault. Related tools: SM2 Encrypt/Sign, SM3 Hash, SM4 Encrypt/Decrypt. Related reading: SM2 vs RSA, SM3 vs SHA-256. See the homepage for more developer tools.


Advertisement