Storing password in an AES container

107 Views Asked by At

I know about storing passwords as salted hashes and I know it is even safe enough for Linux. But even before I knew this, I was wondering if it is safe to store a password in an AES container encrypted with the password itself.

In case my question got incomprehensible, some pythonish pseudo code:

AES(data=password, key=password)
1

There are 1 best solutions below

2
On

No, that is not as safe as using a Password Based Key Derivation Function. The most important issue with passwords are dictionary and brute force attacks - trying passwords, in other words. Now the outcome of AES(data=password, key=password) is always the same value (as the calculation does not contain any salt). This means that building a rainbow table is possible. Furthermore, AES is a very fast, so it is very easy for attackers to check many passwords.

So you are much better off using a PBKDF such as PBKDF2, bcrypt or scrypt, with a high iteration count and at least 64 bits of random salt.