Skip to content
LearnKey derivation

What is key derivation (PBKDF2)?

Also known asPBKDF2password-based key derivationKDF
Example. Kiteline is a fictional company.
On this page

Key derivation is the process of turning an input that is not a usable key on its own, such as a password, into a fixed-length cryptographic key, in a way that is repeatable for the right input and expensive to guess for the wrong one.

Why passwords need a derivation step

Encryption algorithms expect keys of an exact size made of evenly random bits. A password is short, uneven and drawn from a small set of likely choices. Using it directly would make every guess cheap to test. A key derivation function (KDF) fixes the shape and adds deliberate cost.

How PBKDF2 works

PBKDF2 is defined in RFC 8018. It takes a password, a salt, an iteration count and an output length, and applies a pseudorandom function such as HMAC-SHA256 over and over:

  • Salt. A random value stored next to the result. It makes the same password produce different keys for different accounts, so an attacker cannot precompute one table for everyone. The salt does not need to be secret.
  • Iterations. Each guess must repeat the inner function many times. For PBKDF2-HMAC-SHA256, the OWASP Password Storage Cheat Sheet recommends at least 600,000 iterations.

Other functions serve a different job. HKDF, defined in RFC 5869, is meant for input that is already high in entropy, such as a shared secret from a key exchange. It extracts a uniform key and expands it into as many subkeys as needed, quickly and with no added cost.

How Crunu derives the account key

Crunu derives each account key from two inputs:

  1. your password, stretched with PBKDF2-SHA256 at 1,000,000 iterations;
  2. your Secret Key, a random value of about 128 bits generated on your device.

Neither the password nor the Secret Key is sent to the server in any form. Because the Secret Key is random and never stored on the server, a full copy of the server's database is useless for offline guessing: an attacker would have to guess the Secret Key as well as the password. Inside the protocol, Crunu uses HKDF-SHA256 to derive separate keys for separate purposes.

The same two-secret idea is behind 1Password's Secret Key, which also works together with the account password. See Secret Key for the second half, and the Emergency Kit and Secret Key concept page.

Sources

From the blog

  • Security

    Why a vault vendor can’t reset your password

    With a password and a Secret Key, nobody at the vendor can open your account, or reset it. How the Emergency Kit works, and what to do when something is lost.

  • Security

    What “the server can’t read it” actually means

    A blind server is a precise claim with precise limits. What Crunu's server stores, what it cannot do even if compromised, and what it still sees.

  • Self-hosting

    Self-hosting a secrets vault: choosing a platform

    Docker on a VPS, Cloudflare Workers, Vercel or Cloud Run? What changes between platforms for a blind-server vault, and the two decisions you make only once.