SM2 seeded key generation always produces private key 1
Nov 24 find · published Nov 20GIgithub.com · 2 min readRead original
SM2 weak RNGPredictable private key generationKnown private key vulnerability
sm-crypto-v2 versions 1.2.2–2.0.1 compute seeded SM2 private keys using mod(BigInt(seed), 1) + 1, which always equals 1 regardless of input. Every application using the seeded generateKeyPairHex API generates the same publicly known private key and public key (the standard SM2 generator point G). Attackers can forge signatures and decrypt ciphertext for any such key. Version 2.0.2 fixes the seed reduction to mod(BigInt(seed), curve.n - 1) + 1. Unseeded key generation is unaffected.
1.2.2–2.0.1Affected versions
2.0.2Patched version
Comments
Sign in to join the conversation.