Platform

Platform overview How it works Authorization testing Evidence & reports Private scanning Integrations

Solutions

Security agencies Product teams Regulated industries Partner programme

Learn

Blog Knowledge hub Compare

Resources

Pricing Documentation Help centre FAQ Security & data What we haven’t proved

Company

About Contact Careers Sign in to the platform Start a $199 pilot →

Home / Knowledge hub / Key derivation function (KDF)

Knowledge hub

Key derivation function (KDF)

A function that turns a password or secret into a strong, fixed-size key.

Illustration explaining Key derivation function (KDF)

What it means

A key derivation function, or KDF, takes some input secret and produces one or more keys of a fixed size. The input may be a password, a shared secret from a key exchange, or another key. The output is suitable for use as an encryption key or as a stored password check.

There are two main families. Password-based KDFs, such as PBKDF2, scrypt and Argon2, are deliberately slow, because the input is a weak human-chosen secret. Others, such as HKDF, are fast and used to expand a secret that is already strong into several separate keys.

Why it matters

Passwords and keys are different things. A password is short and guessable, while an encryption key is a fixed-length random-looking value. A KDF bridges the gap, and a weak KDF makes the bridge easy to cross for an attacker who has stolen your data.

Choosing badly shows up after a leak. A fast general-purpose hash lets an attacker test billions of guesses per second. A slow, tuned KDF cuts that to a trickle, which is the difference between a breach that exposes a few weak accounts and one that exposes most of them.

How it shows up

You meet KDFs in password storage, in encrypted backups and disk encryption where a passphrase protects a key, and in protocols that expand a shared secret into session keys. In each case there are parameters: a unique salt, a cost setting, and the output length.

The mistakes repeat. Using a plain fast hash instead of a password KDF. Setting the cost low and never raising it. Reusing the same salt. Deriving keys from a password without any KDF. Pick a recommended algorithm such as Argon2, bcrypt or PBKDF2, follow current guidance on settings, and plan to raise cost over time.

Questions people ask

Key derivation function (KDF), answered

Is a KDF the same as a hash function?

Not exactly. A KDF is built from hash functions or similar parts, but adds salt, cost and a defined output length. A plain hash is fast by design, and that speed is a weakness for passwords.

Use a KDF for passwords.

Which KDF should I use for passwords?

OWASP recommends Argon2id first, with scrypt, bcrypt or PBKDF2 where it is not available or where compliance requires it. Follow the cost settings in the current guidance.

Avoid any plain fast hash.

What does the cost setting do?

It controls how much time or memory one derivation takes. Higher cost slows both your login check and an attacker’s guesses. Pick the highest value your servers can bear without hurting sign-in speed.

Revisit it every year or two.

What is HKDF used for?

HKDF derives several keys from a secret that is already strong, such as a key exchange result. It is fast and not intended for passwords, because it does nothing to slow guessing.

It is defined in RFC 5869.

Do I need to write my own KDF code?

No, and you should not. Use the well-tested implementation in your language or framework and let it generate the salt. Writing your own is a classic source of subtle errors.

Check the library is maintained.

Cyberlop mark

Would stolen hashes hold up?

How you derive and store keys is a code-level question. In white-box mode Cyberlop reads your code while testing the running app, so a finding can point to the file and line. Book a pilot on one app.

Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.