I'm asking this question to have a professional opinion about this, and to check if my assumptions are correct. The question derives from few comments I exchanged on SO: Problem with login I can login with any username and password
Take these three different methods to 'secure' a password in your DB (pseudocode):
One:
global_salt = 'a salt string shared by your system and persistent in time'
hashed_password = hash( global_salt + password )
save(username, hashed_password)
Two:
salt = generate_random_salt()
hashed_password = hash( salt + password )
save(username, salt, hashed_password)
Three:
global_salt = 'a salt string shared by your system and persistent in time'
hashed_password = hash( global_salt + username + password )
save(username, hashed_password)
Now it is clear that using a salt
in the first place is wise to prevent weak password reconstruction by the aid of a hash lookup table.
But let's assume that we have picked a random global_salt
that has never changed and a reasonably strong hash function. And now an attacker has gained access to our user table. My assumptions are:
To an attacker trying to obtain the password of a specific user, none of the above techniques will give a significant advantage compared to the others; all passwords are hashed by the same algorithm and with a random salt.
In the case, the attacker will be trying to obtain passwords for all the users the first technique will give him the advantage that all the passwords share the same salt and hence reduce the computational complexity of the entire task. But from my point of view, the second and the third techniques make no substantial difference even in this case.
So what is the advantage of generating random salts and storing them despite the additional overhead of the system?
While asking this question I was prompted to this question: Use of salt to hash a password which partially confirms my assumptions. Please do not take it personally if I don't confirm an answer immediately, I would like to see if there are different opinions out there, before confirming.