Cyberstudy
1.4 In progress

Salting and Key Stretching

8 flashcards

Summary

Passwords are short and guessable, so storing even a hash of them is risky. Salting adds a unique random value to each password before hashing so identical passwords look different and precomputed tables don't work. Key stretching makes each guess slow so offline cracking takes far longer.

In plain words

A salt is random data added to each password before hashing, so two people with the same password get different hashes and precomputed tables stop working. Key stretching hashes thousands of times to make every guess slow.

Detailed explanation

  • Salt: A random value, unique to each password, combined with the password before hashing and stored alongside the hash.
    • Protects against: Rainbow tables and spotting users who share the same password.
    • Doesn't protect against: Guessing one stolen hash at a time; that needs key stretching.
  • Rainbow table: A precomputed table of hashes for many possible passwords.
  • Key stretching: Running a hash or key-derivation function many times, or with large memory, to make each guess expensive.
    • Algorithms: PBKDF2, bcrypt, scrypt and Argon2.
  • Pepper: A secret value added to all passwords and stored separately from the database, such as in an HSM.

Important terms

taken from the text above
Salt
A random value, unique to each password, combined with the password before hashing and stored alongside the hash.
Rainbow table
A precomputed table of hashes for many possible passwords.
Key stretching
Running a hash or key-derivation function many times, or with large memory, to make each guess expensive.
Pepper
A secret value added to all passwords and stored separately from the database, such as in an HSM.

Examples & real-world scenarios

  • A unique random salt stored next to each password hash.
  • PBKDF2 running many rounds of hashing (used in WPA).
  • The same password giving different stored hashes for different users.

Scenario

Two websites lose their password databases. One stored fast unsalted hashes; the other used salted PBKDF2 with many iterations. The second site's users are far safer, because each guess is slow and must be made separately for every salt.

Common mistakes

  • Reading '(salt + password) * SHA' literally. It means hash(salt + password), not multiplication.
  • Thinking the salt must be secret. It's stored openly; its job is uniqueness.

Practical skills

  • Explain how salting defeats rainbow tables.

What I should remember

  • Salt: Unique random value per password; defeats rainbow tables.
  • Key stretching: Slows each guess; examples include PBKDF2, bcrypt and Argon2.
  • Rainbow table: Precomputed hashes that salting makes useless.
  • Exam tip: Use a slow, salted password hashing function, never a single fast hash such as plain SHA-256.