Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sm2encrypt后通过管道传递给sm2decrypt在windows上解密会出现失败情况 #1797

Open
uioz opened this issue Mar 7, 2025 · 0 comments

Comments

@uioz
Copy link

uioz commented Mar 7, 2025

我是在node.js里面调用shell执行gmssl通过sm2加密后将原始buffer传递给了sm2解密, 测试了几次发现时不时会解密失败
经过几次测试, 发现只有输出成文件, 然后再解密才不会出现这个问题.

后来发现在powershell里用管道运算符也能重现类似的效果:

gmssl sm2encrypt -cert .\platform.cer -in .\raw_data.txt | gmssl sm2decrypt -key .\platform.pem -pass 1

运行几次会出现报错:

C:\Users\Guan Zhi\code\github\GmSSL\src\asn1.c:214:asn1_length_from_der():
C:\Users\Guan Zhi\code\github\GmSSL\src\asn1.c:327:asn1_type_from_der():
C:\Users\Guan Zhi\code\github\GmSSL\src\sm2_lib.c:728:sm2_ciphertext_from_der():
C:\Users\Guan Zhi\code\github\GmSSL\src\sm2_lib.c:848:sm2_decrypt():
sm2decrypt: decryption failure

在linux里用完全一样的gmssl版本 执行相同测试内容, 没有出现相同的错误

GmSSL 3.1.1
windows
版本号 24H2
操作系统版本 26100.3194
powershell 7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant