Go Back

Integrity: Pseudorandom Functions & Key Derivation

Pseudorandom Generators (PRG)

Definition: A PRG is a deterministic function that expands a short uniform random seed k ∈ {0,1}^λ into a longer pseudorandom output PRG(k) ∈ {0,1}^ℓ.

Pseudorandom Functions (PRF)

Definition: A PRF is a deterministic function F(k, x) that maps a key and input label x ∈ {0,1}^∗ to output F : {0,1}^λ × {0,1}^∗ → {0,1}^ℓ which is indistinguishable from random to adversaries without knowing k.

Key Derivation Functions (KDF)

Definition: A KDF is similar to a PRF but allows non-uniform keys as long as they have high entropy: KDF(k, x) should still output pseudorandom-looking bits.

HMAC as PRG, PRF, and KDF

Password-Based Key Derivation (PBKDF2)

Definition: k = PBKDF2(F, p, s, c, ℓ)

Each output block Ti = Ui,1 ⊕ Ui,2 ⊕ ... ⊕ Ui,c with:

Ui,1 = F(p, s || i)
Ui,2 = F(p, Ui,1)
...
Ui,c = F(p, Ui,c−1)

PBKDF2 is used in WPA2, iOS, and password managers like LastPass.

Modern alternatives: bcrypt, scrypt, Argon2 (preferred for password hashing)

Things to Remember