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

对sm2 enc 和dec的疑问 #44

Closed
mrpre opened this issue Sep 2, 2016 · 1 comment
Closed

对sm2 enc 和dec的疑问 #44

mrpre opened this issue Sep 2, 2016 · 1 comment

Comments

@mrpre
Copy link

mrpre commented Sep 2, 2016

首先第一点
1:test_sm2_enc 测试函数中,未对 size_t msglen 赋初始值,而 SM2_decrypt_with_recommended 函数会对改值进行判断操作 'else if (*outlen < (size_t)len)' 。
2:使用 SM2_decrypt_with_recommended前 ,是否需要将 msglen 赋为 明文 msg长度?

若 2 是,SM2_decrypt_with_recommended 函数中 是否真的需要 判断 明文长度 和 密文长度的 合法性?
根据sm2公钥加密算法,msg明文长度确实和密文长度有对应关系,也的确能够从想要得到的msg长度来判断密文是否合法,但是个人觉得,SM2_decrypt_with_recommended 仅 需要执行decode 和 decrypt 即可。至于decrypt 之后 实际得到的明文长度 是否 是 对的,应该由外层调用 SM2_decrypt_with_recommended 者进行判断,SM2_decrypt_with_recommended 只负责私钥解密。

@guanzhi
Copy link
Owner

guanzhi commented Sep 2, 2016

  1. 是一个bug,最近的merge (可能)解决了这个问题
  2. SM2的密文比明文长。如果不能预估输出长度,可以通过两段式调用加解密函数。

@mrpre mrpre closed this as completed Sep 5, 2016
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

2 participants