Skip to content
CoreSource checked

PBKDF2

Derives keys from passwords by iterating a pseudorandom function with a salt.

Quick Facts

Compact metadata for implementation and discovery.

Category
Cryptography
Difficulty
Intermediate
Family
Key Derivation
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
6
Code example
Ready
Visualization
Ready

Overview

PBKDF2 makes password guessing more expensive by applying many HMAC-like rounds to a password and salt before producing key material.

Core Concepts

saltiteration countpseudorandom functionkey stretchingmisuse resistanceparameter validation

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(iterations)

Average

O(iterations)

Worst

O(iterations)

Space

O(1)

When to Use

  • Use when protecting messages needs salt.
  • Use when the input matches the assumptions behind key Derivation.

When Not to Use

  • Avoid when a well-reviewed library already provides the primitive for production use.
  • Avoid when a simpler algorithm gives the required result with less setup.

What It Does

  • Derives keys from passwords by iterating a pseudorandom function with a salt
  • Uses salt and iteration count to guide the work.
  • Produces ciphertext, digest, proof, or derived key.

Use Cases

  • Protecting messages
  • Authenticating data
  • Deriving or managing cryptographic material

Inputs

  • Secret key or public parameters
  • Message or secret data
  • Nonce, salt, or context where needed

Outputs

  • Ciphertext, digest, proof, or derived key

Key Formulas (1)

PBKDF2 block

Ti = U1 xor U2 xor … xor Uc
T_i = U_1 xor U_2 xor ... xor U_c

Combines repeated PRF outputs for one derived-key block.

Pseudocode

  1. 1.Validate keys, nonces, salts, group parameters, and input ranges
  2. 2.Apply the primitive's block, hash, group, or reduction operation
  3. 3.Combine intermediate values exactly as the construction specifies
  4. 4.Return the protected value, proof, signature, derived key, or verification result

Canonical Example

Input
message = 'pay 10' with configured keys, nonces, or public parameters
Output
Ciphertext, digest, proof, or derived key
Explanation
PBKDF2 applies salt to produce ciphertext, digest, proof, or derived key.

Implementation Notes

  • Use constant-time library implementations for real systems instead of hand-written primitives.
  • Keep the salt step separate enough to test independently.
  • Use reviewed libraries and protocol specifications for production security-sensitive code.

Common Pitfalls

  • Reusing nonces, salts, pads, or domain parameters can destroy the intended security property.
  • Test edge cases, not only clean examples.
  • Treating educational pseudocode as production crypto can hide nonce, parameter, and side-channel requirements.

Interactive Mechanism Walkthrough

Graph Frontier & Edge Relaxation

Show the major cryptographic rounds or data dependencies without exposing secrets.

PBKDF2 mechanism walkthrough step 1 of 4suvwxt
Step 1 of 4: Validate keys, nonces, salts, group parameters, and input ranges
cryptography-mechanism

Notes

PBKDF2 depends heavily on salt quality, pseudorandom function choice, and an iteration count appropriate for the deployment environment.

Sources (1)

What each reference supports for this entry.

RFC 8018

Documentation

IETF PKCS #5 reference for PBKDF2 password-based key derivation.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Alternative toArgon2

Both derive keys from passwords with different resistance properties.

UsesHMAC

PBKDF2 is commonly instantiated with HMAC as its pseudorandom function.

Alternative toScrypt

Both are password-based key derivation functions.

Related Algorithms

Tags

CryptographyKey DerivationPassword HashingMessage Authentication