Using random salt in password encryption?

I saw several other topics on this topic, but I can not find several answers to some questions related to the use of random salt in password encryption. As far as I understand, the steps go something like this:

  • Create a random salt for the user.
  • Add salt to your password.
  • Use something like SHA-2 for the hash result.
  • Store both the salt and the hashed password in the database.

How does this method work when receiving a user password and confirming login? One answer says that the user salt should be extracted, added to their entered password, hashed, and then compared with the stored hash, but does this not cause some problems? Namely:

  • How do you get salt without prejudice to this user? If someone wants to reset the password for a specific account, can they not get the salt that was sent from the server to hash the password entered, thereby eliminating the security that adds salt?
  • If we avoid the previous problem by running the salt search server, will we not send the password to a user who was unencrypted at some point (so that he could later be added to the received salt)?
+4
source share
6 answers

Salt should never be exposed to the outside - your instinct is right that it will expose the salt and introduce risk.

Any connection between your client and server must take place via an SSL connection - or at least using some kind of interaction encryption.

Keep in mind the purpose of the salt: to make it more difficult for someone to pre-compute the hash codes and, therefore, could look for passwords in the event of a database hack. An 8-bit salt makes the hash space 256 times larger, making it much more complicated to pre-compute. Salt is not connected with communication - there are other solutions for this.

+4
source

You should use random salt, as the purpose of its use protects against some types of attacks, such as dictionary attack, brute force attack and rainbow attack. therefore, it is important to generate a random salt for each password and store the hashed password and salt in the user table or attach to the user profile. If you want to check the user's password, just enter the hash in the password with the saved salt and compare it with the saved hash value. I donโ€™t think that @cherouvim advises because it seems like he does not care about the above attacks. For more information, I suggest an amazing, simple and straightforward Defuse Security article .

Good luck.

+2
source

I use a fixed salt (for all passwords), which is hard-coded in the application code. Assuming that the salt cannot be opened (for example, through the user interface of the application), it looks simple and good enough.

+1
source

The security introduced by salt is that you get a hash for something much larger and non-standard than a simple password. It does not matter if its algorithm is closed, since it protects the hash stored in a simple database from rainbow or dictionary attacks.

It is also recommended that you take the hash several times recursively, perhaps by reading the salt at each iteration, so that brute force will take much longer.

EDIT: to what Bevan said about the connection: usually uses the โ€œnumber used onceโ€ (NONCE) to transmit passwords over insecure channels. The server gives a random string that was never used before the client, it attaches it to a simple password, calculates the hash and sends it. This protects you from eavesdropping attacks.

+1
source

The only way to not send an unencrypted value that can be used to log in is to use SSL. If the hash is sent to the server, the hash itself can be sniffed and used to enter. Do it server side.

+1 to what the channel said about salt. This prevents dictionary / rainbow attacks. The rainbow table for the average password + a few bytes of random binary data will be astronomically huge.

+1
source

Hashed passwords protect against clearly visible passwords and force them to protect against dictionary attacks. Regarding password protection during transport, I would recommend SSL / TLS.

0
source

All Articles