Key Stretching
Key stretching is a technique that makes weak or low-entropy secrets, such as passwords, harder to crack by deliberately making the process of testing each guess slow and computationally expensive. Rather than hashing a password once, the algorithm repeats the work many times so that an attacker attempting to guess the password must expend significantly more effort per attempt. This helps protect passwords even when the underlying secret has relatively little inherent randomness.
Key stretching is a cryptographic technique that strengthens weak or low-entropy secrets by repeatedly applying a computationally expensive hashing operation, intentionally increasing the work factor required to test each candidate guess. By iterating a secure hashing function (typically in conjunction with a per-secret salt to defeat precomputation), the technique raises the per-guess cost imposed on offline brute-force and dictionary attacks, thereby narrowing the advantage an attacker gains from cheap parallel hashing. The design goal is to make all bits of the derived key or hash dependent on the input secret while slowing the derivation enough to be tolerable for a single legitimate authentication but expensive at attacker scale. Note that key stretching addresses the cost of testing guesses and does not add entropy to an inherently weak password; the specific work factor, iteration count, and algorithm choice vary by deployment and configuration.
Why it matters
Passwords remain one of the weakest links in identity systems because users routinely choose low-entropy secrets that are vulnerable to dictionary and brute-force attacks. When a credential store is breached, attackers typically obtain hashed passwords and attempt to recover the plaintext offline, where they can test enormous numbers of guesses using cheap, highly parallel hardware. Key stretching directly targets this threat model by making each individual guess deliberately slow and computationally expensive, so that the attacker's advantage from mass parallel hashing is substantially narrowed.
The protection matters most precisely when a secret has little inherent randomness. A single fast hash of a weak password can be tested billions of times cheaply; by iterating an expensive hashing operation, key stretching raises the per-guess cost to a level that is tolerable for one legitimate authentication but punishing at attacker scale. It is important to understand the boundary of this benefit: key stretching increases the cost of testing guesses but does not add entropy to an inherently weak password. It buys time and raises attacker cost rather than making a poor password strong.
Who it's relevant to
Inside Key Stretching
Common questions
Answers to the questions practitioners most commonly ask about Key Stretching.
