Pure Javascript implementation of the SM2/SM3/SM4 functions based on jsrsasign
npm install gmsm-sm2jssm2js is a pure Javascript implementation of the GM-Standards SM2 (also support sm3/sm4) based on jsrsasign.
基于jsrsasign实现的优势在于充分利用jsrsasign的PKIX,CSR,CERT,PKCS8等处理能力。您也可以参考另外一个实现:sjcl-sm。
- sign/verify functions (Passed integration test with ALI KMS)
- sm2Sign/sm2Verify functions (include uid and curve related parameters in signature)
- encrypt/decrypt functions (Passed integration test with ALI KMS), support both PLAIN and ASN.1 encoding format ciphertext output
- SM2 certificate signing request generation and parse
- SM2 certificate parse and verify signature, test CA & certificate are generated from https://www.gmcert.org/
- Parse SM2 private key in PKCS8 format (both encrypted and plaintext).
For usage, please reference sm2_test.js
在NodeJS环境下,修改过的``KJUR.crypto.Cipher.encrypt`和`KJUR.crypto.Cipher.decrypt``会优先使用NodeJS Native实现,这两个方法目前只支持以下模式:
- aes128-CBC
- aes256-CBC
- des-EDE3-CBC
- sm4-CBC
[npm-downloads-image]: https://badgen.net/npm/dm/gmsm-sm2js
[npm-url]: https://npmjs.org/package/gmsm-sm2js