Modern KDFs: scrypt, Argon2, and HKDF
What you'll learn: How modern key derivation functions defend against GPU and hardware-based cracking attacks, and how to properly derive keys from other keys.
The Evolution of KDFs
You already know PBKDF2 from the previous lesson, but attackers got smarter. They started using GPUs and specialized hardware (ASICs) to crack passwords millions of times faster than CPUs. PBKDF2 only requires CPU time and minimal memory, making it vulnerable to these parallel attacks.
Modern KDFs fight back differently.
Memory-Hard KDFs: scrypt and Argon2
scrypt (2009) and Argon2 (2015) are "memory-hard" functions. They intentionally require large amounts of RAM to compute, not just CPU cycles.
The analogy: Imagine a puzzle that requires spreading out papers across a huge desk. You can't solve it faster by hiring more people if you don't have more desks. Similarly, attackers can't easily parallelize these KDFs because each computation needs its own large memory space—expensive and difficult to scale.
scrypt lets you tune memory usage and CPU cost. Argon2 is newer and comes in three variants: Argon2d (resistant to GPU attacks), Argon2i (resistant to side-channel attacks), and Argon2id (hybrid, recommended for password hashing).
Both make brute-force attacks economically infeasible by forcing attackers to invest in expensive RAM, not just processing power.
HKDF: Key Expansion and Derivation
HKDF (HMAC-based Key Derivation Function) serves a different purpose: deriving multiple keys from one shared secret, or "stretching" existing key material.
Unlike password-based KDFs, HKDF assumes you already have reasonably strong input key material. It's perfect for deriving session keys, encryption keys, and MAC keys from a single master secret in protocols like TLS.
Key Takeaway: Use Argon2id for password hashing (it's memory-hard and GPU-resistant), and HKDF when you need to derive multiple cryptographic keys from existing strong key material—not passwords.