Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is a Key Derivation Function?

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.

Illustration for the cybersecurity term Key Derivation Function
Home / Blog / Cybersecurity Terms / What Is a Key Derivation Function?
17 November 2026

What Is a Key Derivation Function?

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.

Password-Based Derivation: Slow on Purpose

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.

FunctionResistsCurrent guidance
Argon2idGPU and ASIC, through memory hardnessFirst choice; 19 MiB memory, 2 iterations, 1 degree of parallelism as a baseline
scryptGPU and ASIC, memory hardGood alternative where Argon2 is unavailable
bcryptGPU, partiallyAcceptable; work factor 10 or above, and mind the 72-byte input limit
PBKDF2Little beyond raw iteration countUse 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.

Protocol Derivation: Fast and Separated

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.

Choosing Parameters

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.

Common Errors

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.

FAQ – Frequently Asked Questions

Which Algorithm Should I Use for Password Storage?

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.

What Is the Difference Between Hashing and Key Derivation?

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.

Do I Need Both a Salt and a Pepper?

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.

How Do I Upgrade Existing Password Hashes?

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.

Related Terms

You May Be Interested In These

What Is Breach Notification?

Cybersecurity Terms

17 November 2026

What Is Breach Notification?

Read More
What Is Cloud Logging and Monitoring?

Cybersecurity Terms

17 November 2026

What Is Cloud Logging and Monitoring?

Read More
What Is an IMDS Attack?

Cybersecurity Terms

17 November 2026

What Is an IMDS Attack?

Read More