views:

140

answers:

2

Hi guys I have read about password salting, but this might sound a little odd. But how do I store and secure the salt. For example in a multi tire architecture say I use the client machine’s GUID to generate my salt then the user gets restricted to a single machine but if I use random salt it has to be stored somewhere. Few days back I saw an sample application where the hash and the salt was generated on the client system whenever a new user was created and then the salted password and the hash is transmitted to the server where they are stored in SQL server. But if I follow this method and the database is compromised the passwords and the salt values for each password will be available to the X person. So, should I again salt/encrypt the passwords and received salt on server side? What is the best practice of salting?

+12  A: 

Storing the salt unencrypted in the database next to the hashed passwords is not a problem.

The purpose of the salt is not to be secret. It's purpose is to be different for each hash (i.e. random), and long enough to defeat the use of rainbow tables when an attacker gets his hands on the database.

See this excellent post on the subject by Thomas Ptacek.

edit @ZJR: even if the salts were completely public, they would still defeat the benefit of rainbow tables. When you have a salt and hashed data, the best you can do to reverse it is brute force (provided that the hash function is cryptographically secure)

edit @n10i: See the wikipedia article for secure hash function. As for the salt size, the popular bcrypt.gensalt() implementation uses 128 bit.

Wim Coenen
I'd say the purpose of the salt is not to be **public**, either.
ZJR
can u please explain "hash function is cryptographically secure". sorry i am new to cryptography. also in your reply u mentioned "long enough to defeat the use of rainbow tables" how long should the salt be, to be long enough?
Neel
+3  A: 

Please take a moment to read this very good description of salts and hashing

http://stackoverflow.com/questions/1645161/salt-generation-and-open-source-software/1645190#1645190

Jeremy Powell