开发者

Using AES to store passwords

开发者 https://www.devze.com 2023-02-11 18:38 出处:网络
So I need to be able to actually decrypt the password because some old websites don\'t use OAuth and I need to have s开发者_开发百科ome of my users have access to them through there API. Therefore one

So I need to be able to actually decrypt the password because some old websites don't use OAuth and I need to have s开发者_开发百科ome of my users have access to them through there API. Therefore one way hashing does not work for me. I have been told that the best way to store the passwords with AES and using the salted hash of the passwords as the key. How do I store all the keys and where do I store the salt? Basically how would I exactly implement this.

Thank You


If I understand you correctly you have the following situation. Users log in to your system with a username and password. Your system then needs to impersonate these users by logging into another system that you do not control using the user's username and password for that system which they have given to you.

If that is correct, then it might be reasonable to encrypt their credentials for the other websites using AES. In this case, I would not store the key used to encrypt those crendentials. The password that the user uses to access your system should be used as the key, and it should not be stored anywhere. In this way, you have a chance of protecting your users privacy (depending on the design of the rest of the system, of course).

Since you are encrypting rather than hashing, and the encryption key would be differnet for each user, salting is not necessary.

Also, I would encrypt the full credentials, not just the passwords. Your users are showing an incredible amount of trust by giving you their credentials in the first place, so I would do everything possible to justify that trust!


Your approach is essentially to use AES as a hash function but this will not allow you to decrypt the passwords (short of brute force or some yet-to-be-discovered vulnerability).

You might want to consider asymetric key encryption instead (e.g. RSA). You'll need to encrypt the passwords with the public key of each person you expect would need to decrypt it (which would include the user).

0

精彩评论

暂无评论...
验证码 换一张
取 消