user4155352
user4155352

Reputation: 11

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.

The AES key will be made from the password. The password can be any length, so the key would be derived from the password. An IV and salt will also be generated.

The only problem that I have is that the IV, salt and key is different each time on the server and on the client. How can I ensure that the keys are the same so that I can successfully encrypt and decrypt my data on both sides?

Upvotes: 0

Views: 276

Answers (1)

Thilo
Thilo

Reputation: 262794

The salt and the IV have to be shared before the encryption starts.

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.

The IV can be chosen by the encrypting party and transmitted (in the clear) before the encrypted data. That way the recipient can initialize AES for encryption.

Upvotes: 1

Related Questions