Cryptography - Salt (init vector)

1 - About

A salt is a text added to the password to make difficult an attack.

See also: Crypto - initialization vector (IV) or starting variable (SV)

The salt value is public (not secret) and should be generated at random for each new encryption stored with the password hash.

This means that two users with the same password will have different password hashes (assuming different salts are used).

Salts are closely related to the concept of nonce.

Both the salt value and the hashed password value are stored.

3 - Characteristics

3.1 - Random

A salt must not be:

  • the same for each user
  • hard coded (ie must be stored along the password and not in the code)

If the salt is:

  • unique, every user who inputs the same password will have the same hash.
  • unique and hard coded into the code, it can be extracted and a new rainbow table can be generated using that salt.

3.2 - Large

A large salt value prevents precomputation attacks, including rainbow tables, by ensuring that each user's password is hashed uniquely.

The SHA2-crypt and bcrypt methods—used in Linux, BSD Unixes, and Solaris—have salts of 128 bits

4 - Example

saltedhash(password) = hash(password || salt)


saltedhash(password) = hash(hash(password) || salt)

5 - Documentation / Reference

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap