> A new salt is randomly generated for each password. In a typical setting, the salt and the password are concatenated and processed with a cryptographic hash function, and the resulting output (but not the original password) is stored with the salt in a database.
Writing them is actually an excellent exercise, and humbling one too. Especially if you show your code to some skilled hacker / security expert.
Per-hash salts don't really slow that down at all, unfortunately.
Short-version: don't use the hash algorithms that are designed to be fast for protecting sensitive data; use something solid with a work factor instead.
For example, if the password is "a" and an unique salt is available in the database, it'll be trivial to brute force. If the password function is something like this, however: sha256("longsalt" + password + salt) the attacker will first have to figure out longsalt which can be slow if it's long.
Or am I completely mistaken?
In other words: there is a reason why security experts and cryptographers recommend the password storage mechanisms they do.
An identical password for two different accounts should never encrypt to the same string.
I'm not sure how you can keep the salt random and secret, and still use it when users log in?
I can't see why a user id could not be used as a salt though.
If this were common, someone constructing a lookup table for password hashes could include ones salted with the first N user ids. A N-times bigger table isn't something you'd be excited about as a cracker, but might still be practical.
If your user ids are randomly assigned this should be pretty much the same as generating a random salt. Still, the extra storage of a salt is going to be small compared to whatever else you're storing per-user, so better to do the safe thing and go with what's standard.
If Adobe has taken that approach, the intruders would have all the salts, but they would not be able to do this attack of seeing how many people use the same password.
However, Snowden's silly password hint would still have given the game away. If that is in fact him.
Exactly because you need it to calculate the hash and compare it.
If you want to get more security on top of that out of your salt, the only thing I can think is to add some security by obscurity on top: If it doesn't matter which field in the DB you use, just pick an unlikely one and keep secret which one it is. Might be id, email, favourite pet, or something else. Just don't forget to update the hash when the user changes that field.