2
$\begingroup$

I need a password hashing function that is deterministic. Correlation attacks are not a concern. The same password must produce the same hash. I just want to protect the password against dictionary and brute force attacks in the event that the hash is leaked.

Is there a well known way to do this? Would fixing the salt of bcrypt/PBKDF2/scrypt be enough?

$\endgroup$
2
$\begingroup$

Yes, this is thought to be so.

The point of PBKDF2 is to produce the same output on the same input, otherwise it would be useless as a key derivation function (KDF).

I personally prefer Argon2 since you can tweak it a bit more, it makes a better usage of RAM and computing time, etc. As explained on Wikipedia, PBKDF2 is not the best because it can be implemented on ASIC devices, which makes brute-force attacks using ASICs or even GPUs easier than for certain other KDFs.

Using a fixed salt for all entries just allows a dictionary attack against your specific application to be mounted, but I wouldn't worry too much about it, since this should still be hindered by the computational cost it would imply. That's true as long as you've generated the salt yourself and are not using a generic value (such as the empty one).

Note that the good practice would be either to derive the salt in a deterministic way (from the username, for example), or to store the salt in the database (so that each password has a different salt.)

$\endgroup$
  • $\begingroup$ Note that the good practice would be either to derive the salt in a deterministic way (from the username, for example) That is a brilliant idea. Thanks! $\endgroup$ – Daffy Jul 16 '17 at 16:15
  • $\begingroup$ If you are feeling paranoid you may also use an additional "pepper" as describe in that answer to have an extra layer of security. $\endgroup$ – Lery Jul 16 '17 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.