I'm quite novice in security, and all examples I saw seem to salt the password by concatenating it, or by applying a simple binary OR or XOR. So the hash is based on "salt + password", "salt | password", etc.

If I'm right, a hacker should know how the password has been salted in order to retrieve a user password. So, can the complexity of the salting method improve the overall security?

  • 2
    $\begingroup$ If you read salt and password are combined by XOR, move to other readings. If that's OR, run. $\endgroup$
    – fgrieu
    Oct 29 '15 at 11:49
  • $\begingroup$ A longer and more complex salt makes the hash less vulnerable to a rainbow table attack $\endgroup$ Oct 31 '15 at 2:23

First, good password hashing functions like PBKDF2 and scrypt usually take the password and salt as separate parameters, meaning the user does not have to worry about this. However, with some algorithms they do and in any case the theoretical question is important.

Some of those methods you mention are clearly worse than others:

  • Binary OR would be particularly bad and I hope it is never used. Any position where the salt has a 1 bit would be 1 regardless of the password bit, so about half the entropy in the password would be lost. (AND would be the same, just with bits reversed.)
  • XOR is not as bad, but two different salt-password pairs can lead to the same password hash. That makes a parallel attack on many users' passwords easier than it has to be.
  • Some sort of addition (e.g. byte-wise) would have the same problem as XOR.

The normal method is to concatenate. It loses no entropy and produces a unique input into the hash function for every salt and password. There is really no advantage to doing anything more complex as the user, because that would effectively be just another part of the password hash.

  • $\begingroup$ And I guess that concatenating twice (like as prefix and suffix) could be bad, as it generates a redundant pattern? $\endgroup$ Oct 29 '15 at 11:01
  • $\begingroup$ @XavierPortebois, no it should not hurt, but neither should it help with a good password hash. $\endgroup$
    – otus
    Oct 29 '15 at 11:18

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.