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

关于密钥加密交换的疑问 #2

Open
ghost opened this issue Sep 22, 2021 · 4 comments
Open

关于密钥加密交换的疑问 #2

ghost opened this issue Sep 22, 2021 · 4 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Sep 22, 2021

请问密钥加密交换的流程,用后端公钥加密客户端公钥这步有些不明白它的用意,客户端生成公钥私钥后,直接将公钥发送给后端,后端用客户端公钥加密交换密钥返回,然后客户端用私钥解密,这样走是不是更容易一些

@yl-yue
Copy link
Owner

yl-yue commented Sep 23, 2021

密钥交换加解密是TLS协议的动态实现,HTTPS的证书是静态的,而使用密钥交换加解密,全局过程中的密钥都是随机的。

步骤2.1的作用正是为了在传输过程中,不泄露最终交换的密钥

@yl-yue
Copy link
Owner

yl-yue commented Sep 23, 2021

是的,复杂了。可以简化流程,感谢你的指出。我梳理了多一个交换步骤,能隐藏客户端公钥和增大劫持成本,但意义不大。后续我考虑优化下,简化流程降低使用成本。
至于当初这样设计的意义,我理不清了,应该就是设计缺陷,搞复杂了,也可能是受SSL/TLS协议影响,应用层是做不到防劫持的。

@yl-yue yl-yue self-assigned this Sep 23, 2021
@yl-yue
Copy link
Owner

yl-yue commented Sep 23, 2021

优化后流程:

  1. 客户端获得对称密钥,请求参数:密钥存储key、密钥交换类型、客户端非对称加密公钥
  2. 服务端生成对称密钥,并使用客户端非对称公钥加密,响应加密报文
  3. 客户端私有解密,获得对称密钥

@ghost
Copy link
Author

ghost commented Sep 26, 2021

感谢回复

@ghost ghost closed this as completed Sep 26, 2021
@yl-yue yl-yue reopened this May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant