Course contentsShow
← Security
Lesson 140 of 3,0523. Symmetric Cryptography Deep DiveFree lesson

Salts in Key Derivation

Understand the role of salts in preventing rainbow table attacks and ensuring unique derived keys from identical passwords.

Salts in Key Derivation

What You'll Learn

You'll learn how salts prevent attackers from pre-computing massive tables of passwords and ensure that identical passwords produce different encryption keys.

The Problem: Rainbow Tables

Imagine two users choose the same password: "Summer2024!". Without salts, running that password through a KDF (like PBKDF2 or Argon2) would produce identical derived keys for both users. Attackers exploit this by pre-computing rainbow tables—massive databases mapping common passwords to their derived keys. They compute billions of passwords once, then instantly crack any matching hash.

How Salts Solve This

A salt is a unique, random value added to each password before derivation. Even if two users have identical passwords, different salts ensure completely different derived keys:

User A: DeriveKey("Summer2024!" + salt_A) → key_A
User B: DeriveKey("Summer2024!" + salt_B) → key_B

The keys are totally different, even though the passwords match.

Salt Properties

  • Random: Generated using a cryptographically secure random number generator
  • Unique: Different for every password (or every user/system)
  • Non-secret: Salts can be stored alongside the derived key—they're not passwords themselves
  • Sufficient length: Typically 128 bits (16 bytes) minimum

Why Salts Work

Salts force attackers to compute rainbow tables separately for every single salt value. With a 128-bit salt, that's 2^128 possible tables—computationally infeasible. Attackers must resort to attacking passwords one-by-one, which slow KDFs like Argon2 make prohibitively expensive.

Analogy

Think of salts like adding a random spice blend to each dish. Even if two chefs use the same base recipe (password), the unique spice mix (salt) makes each dish taste completely different.

Key Takeaway: Salts are random values added to passwords during key derivation that prevent rainbow table attacks and ensure identical passwords produce unique keys—they must be unique, sufficiently long, and cryptographically random.