Password hash family

PBKDF2

The iterated-HMAC password-based key derivation function from PKCS #5 and NIST SP 800-132

standard 4 variants PKCS #5 v2.0; RFC 8018; NIST SP 800-132

Overview

PBKDF2 is a password-based key derivation function defined in PKCS #5 (now RFC 8018). It applies a pseudo-random function, usually HMAC, many times to slow down brute-force guessing, and is approved by NIST in SP 800-132 and widely required in FIPS environments.

For each output block i, PBKDF2 computes U1 = PRF(password, salt ‖ i), then U2 = PRF(password, U1), and so on for c iterations, XORing all Uj together to form the block. Blocks are concatenated to the requested key length. The iteration count c is the only cost parameter; memory use is negligible.

NextSSL includes a generic PBKDF2 and PBKDF2-HMAC-SHA1, PBKDF2-HMAC-SHA256 and PBKDF2-HMAC-SHA512 instances, matching test vectors from RFC 6070 and RFC 7914. PBKDF2 is used in WPA2 Wi-Fi keys, many disk-encryption formats, password managers and Django's default password hasher. Its simplicity has made it the most portable choice. Salts should be at least 16 bytes.

History

2000–2017
  1. PBKDF2 published in PKCS #5 v2.0 (RFC 2898)

  2. Recommended in NIST SP 800-132

  3. Specified in RFC 7914 section 11

  4. RFC 8018 updates PKCS #5

How it works

  1. Compute U1 = HMAC(password, salt ‖ block index)
  2. Iterate Uj = HMAC(password, Uj−1) c times
  3. XOR all Uj into the output block
  4. Concatenate blocks to the requested length

Security notes

PBKDF2 is not broken, but because it needs almost no memory it is far cheaper to attack with GPUs and ASICs than memory-hard functions. Iteration counts must be high: OWASP currently suggests hundreds of thousands of iterations for HMAC-SHA256. Requesting more output than the PRF's length multiplies the defender's cost but not the attacker's.

Typical uses

Password storage in FIPS-constrained environmentsWPA2 and disk-encryption key derivationLegacy format compatibility

Variants in NextSSL

4
AlgorithmTierSizes (bytes)StandardsAPI
PBKDF2
pbkdf2
standard FIPS out 16–1024 · salt 4–64 RFC 8018, NIST SP 800-132, RFC 7914 section 11 safe
PBKDF2-HMAC-SHA-256
pbkdf2-hmac-sha256
standard FIPS out 16–1024 · salt 4–64 RFC 8018, NIST SP 800-132, RFC 7914 section 11 safe
PBKDF2-HMAC-SHA-512
pbkdf2-hmac-sha512
standard FIPS out 16–1024 · salt 4–64 RFC 8018, NIST SP 800-132 safe
PBKDF2-HMAC-SHA-1
pbkdf2-hmac-sha1
legacy FIPS out 16–1024 · salt 4–64 RFC 8018, RFC 6070, NIST SP 800-132 root

Frequently asked questions

Which PBKDF2 variants does NextSSL include?

NextSSL registers 4 PBKDF2 variants: pbkdf2, pbkdf2-hmac-sha256, pbkdf2-hmac-sha512, pbkdf2-hmac-sha1.