3 ms·
Thanks for the reply. I am building a web application, and I need to be able to store the passwords of its users securely on disk. I know hashing them with a s
by cryptonewbie 17y ago
Thanks for the reply.
I am building a web application, and I need to be able to store the passwords of its users securely on disk. I know hashing them with a salt and nonce is better than nothing, and that you should avoid older, broken hash functions like MD5 or SHA-1 and opt for something like SHA-256, but beyond that I am kind of at a loss.
- cperciva 17y agoI am building a web application, and I need to be able to store the passwords of its users securely on disk. Define "securely". What sort of attacks are you concerned with? Someone trying passwords via your web application? Someone breaking into your server and reading the hashed passwords from disk? Someone installing a rootkit and grabbing users' passwords as they log in?
- cryptonewbie 17y agoI would like the protocol to be secure to the point that an attacker possessing a stolen hard drive with the database containing users' passwords on it, would be unable to either a) figure out what the plaintext password of any user is, or b) generate a new password such that it, when put through the protocol, results in the same hashed/encrypted password of a user. If they can install a root kit, perform a cold boot attack or something similar (access the RAM), I'm willing to concede to them.
- cperciva 17y agoNow we're getting somewhere. :-) When a user's password is set, generate a random salt, compute K = scrypt(salt, password), and store (user, salt, K) in your database. To verify a password, look up the user's salt value, compute K' = scrypt(salt, password'), and compare K' to K. You don't need this much strength, but as a matter of course I would recommend using a 256-bit salt and a 256-bit output from scrypt -- the reasoning being that using 256 bits isn't going to be a performance-limiting factor, and that if you try to figure out exactly how many bits you need, there's a risk that you'll make a mistake. If you can't use scrypt, I'd recommend PBKDF2-SHA256; if that's also unavailable, use bcrypt.
- cryptonewbie 17y agoThanks!