Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
A key derivation function turns a password or a shared secret into one or more cryptographic keys. Password-based variants are deliberately slow; protocol variants are deliberately fast.

What Is a Key Derivation Function?
Keys have to come from somewhere, and the two usual sources are both unsuitable on their own. A password chosen by a human has far too little entropy to use directly as an AES key. A shared secret from a Diffie-Hellman exchange has plenty of entropy but is not uniformly distributed, and a protocol usually needs several distinct keys from it rather than one. A key derivation function bridges both gaps, and the two cases call for opposite design goals.
When the input is a password, the attacker’s approach is to guess. A modern GPU rig tests billions of SHA-256 candidates per second, so the derivation function must be expensive enough to make that rate collapse, while staying fast enough that one legitimate login is imperceptible.
| Function | Resists | Current guidance |
|---|---|---|
| Argon2id | GPU and ASIC, through memory hardness | First choice; 19 MiB memory, 2 iterations, 1 degree of parallelism as a baseline |
| scrypt | GPU and ASIC, memory hard | Good alternative where Argon2 is unavailable |
| bcrypt | GPU, partially | Acceptable; work factor 10 or above, and mind the 72-byte input limit |
| PBKDF2 | Little beyond raw iteration count | Use only for FIPS compliance; at least 600,000 iterations with HMAC-SHA256 |
The crucial distinction is memory hardness. PBKDF2 simply repeats a hash, and repetition parallelises beautifully on a GPU, so an attacker gains far more from specialised hardware than a defender does. Argon2 and scrypt require a sizeable block of memory for each guess, which is expensive to replicate thousands of times in silicon. Argon2id, the hybrid variant, won the Password Hashing Competition in 2015 and is specified in RFC 9106; OWASP’s Password Storage Cheat Sheet lists it first.
Two inputs accompany the password. A salt, a unique random value per password, ensures identical passwords produce different outputs and makes precomputed tables useless; it is stored alongside the result. A pepper, a single secret held outside the database — ideally in a hardware security module — means a stolen database alone cannot be attacked offline.
The other family has a different job. Given a high-entropy secret, produce several independent keys with no useful relationship between them. HKDF, defined in RFC 5869, does this in two stages: extract condenses the input into a uniform pseudorandom key using HMAC, and expand stretches it into as much key material as needed, mixing in an info label that binds each output to a purpose.
That label is the point. TLS 1.3 derives separate client and server traffic keys, exporter secrets, and resumption secrets from one handshake secret, each with a distinct label, so a key compromised in one role cannot be substituted into another. The Signal double ratchet, Noise-based protocols including WireGuard, and most cloud key hierarchies use the same pattern. There is no need to make any of this slow: the input already has full entropy, so guessing is not the threat.
Calibrate password hashing against your own hardware, not against a blog post. Aim for roughly 250 to 500 milliseconds per derivation on the production machine, measure under realistic concurrency, and raise the cost as hardware improves. Store the parameters with the hash — the standard encoded formats such as $argon2id$v=19$m=19456,t=2,p=1$... do this automatically — so that you can upgrade users transparently at their next successful login.
Plan that upgrade path explicitly. A system that cannot increase its work factor without a password reset for every user will stay at its original setting indefinitely, which is the state we find most legacy applications in.
Password storage and key derivation are among the first things we examine when reviewing authentication code during our web application security services, because the cost of getting it wrong is only visible after a database is stolen — at which point it is the single factor deciding how many accounts are compromised.
Argon2id, with memory and iteration parameters tuned so a single derivation takes a few hundred milliseconds on your hardware. Use scrypt or bcrypt where your platform lacks Argon2 support, and PBKDF2-HMAC-SHA256 with at least 600,000 iterations only where FIPS validation requires it. Always use a unique random salt per password.
A plain hash is fast and designed for integrity checking. A key derivation function produces key material, and password-based variants add salting and deliberate cost to resist guessing. Storing passwords with SHA-256 treats a fast integrity primitive as if it were a slow protective one, which is why bulk cracking succeeds.
A salt is essential and non-negotiable. A pepper is a useful second layer: a secret value held outside the database, so an attacker with only the database cannot start cracking at all. It complicates key rotation and must be stored somewhere genuinely separate, so treat it as an enhancement rather than a substitute for strong parameters.
Store the algorithm and parameters alongside each hash. When a user authenticates successfully, verify against the stored format, then immediately re-derive with the current settings and replace the record. Over time most active accounts migrate on their own; force a reset for dormant accounts, or wrap old hashes inside the new function as an interim measure.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.