[英]How do I use the same encryption key on two different platforms?
I am working on a project where the user would access the server and send commands to the server. 我正在一个项目中,用户可以访问服务器并将命令发送到服务器。 The server would then send the information / results back.
然后,服务器将信息/结果发回。 The commands that are sent to the server, and the information received from the server, will be encrypted in AES 128.
发送到服务器的命令以及从服务器接收的信息将在AES 128中加密。
The AES key will be made from the password. AES密钥将从密码中获取。 The password can be any length, so the key would be derived from the password.
密码可以是任何长度,因此密钥将从密码中派生。 An IV and salt will also be generated.
还会产生IV和盐。
The only problem that I have is that the IV, salt and key is different each time on the server and on the client. 我唯一的问题是服务器,客户端上的IV,salt和key每次都不同。 How can I ensure that the keys are the same so that I can successfully encrypt and decrypt my data on both sides?
如何确保密钥相同,以便可以成功地对双方的数据进行加密和解密?
The salt and the IV have to be shared before the encryption starts. 加密开始之前必须共享salt和IV。
They don't need to be kept secret, but they should be generated fresh for every session. 他们不需要保密,但是应该为每个会话重新生成它们。
The derived AES key will be the same if salt and (shared secret) password are the same on both ends. 如果salt和(共享密钥)密码的两端相同,则派生的AES密钥将相同。
The IV can be chosen by the encrypting party and transmitted (in the clear) before the encrypted data. IV可以由加密方选择,并在加密数据之前(以明文形式)传输。 That way the recipient can initialize AES for encryption.
这样,接收者可以初始化AES进行加密。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.