PBKDF2-HMAC-SHA-1
The iterated-HMAC password-based key derivation function from PKCS #5 and NIST SP 800-132
Old but not broken. Kept for interoperability; root API only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.
About PBKDF2-HMAC-SHA-1
PBKDF2-HMAC-SHA-1 is one of 4 PBKDF2 variants in the NextSSL registry, a password hashing function. It uses a 16–1,024-byte output and a 4–64-byte salt. It takes the parameters iterations (default 1300000) and out_len (default 20). Its registry entry cites RFC 8018, RFC 6070 and NIST SP 800-132. NextSSL lists it in the legacy tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).
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–2017PBKDF2 published in PKCS #5 v2.0 (RFC 2898)
Recommended in NIST SP 800-132
Specified in RFC 7914 section 11
RFC 8018 updates PKCS #5
How it works
- Compute U1 = HMAC(password, salt ‖ block index)
- Iterate Uj = HMAC(password, Uj−1) c times
- XOR all Uj into the output block
- 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
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| out | 16 – 1,024 | Output |
| salt | 4 – 64 | Salt |
Parameters
| Name | Type | Range | Default | Required |
|---|---|---|---|---|
| iterations | u32 | 1 – 16777216 | 1300000 | no |
| out_len | u32 | 16 – 1024 | 20 | no |
Parameters are passed as a string, for example nextssl_mac("hmac", "hash=sha512", …). Omitted parameters take their declared default.
Use it
from nextssl_demo import NextSSL
root = NextSSL(root=True) # tier 'legacy' is reachable from the root API only
phc = root.call("pwhash", "pbkdf2-hmac-sha1", None, b"correct horse")[0] # PHC string, fresh salt
ok = root.check("pwhash_verify", "pbkdf2-hmac-sha1", None, b"correct horse", phc)
nextssl_root_pwhash("pbkdf2-hmac-sha1", NULL, password, out);
nextssl_root_pwhash_verify("pbkdf2-hmac-sha1", NULL, password, phc);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_pwhash_in(reg::all(), Policy::Any, "pbkdf2-hmac-sha1", &Params::new())?;
let phc = alg.hash(b"correct horse")?; // PHC string
let ok = alg.verify(b"correct horse", &phc)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other PBKDF2 variants
3Similar names
Looking for something else?More password hashing
All 30Frequently asked questions
What is PBKDF2-HMAC-SHA-1?
PBKDF2-HMAC-SHA-1 is a password hash in the PBKDF2 family. PBKDF2 is a password-based key derivation function defined in PKCS #5 (now RFC 8018).
What are the PBKDF2-HMAC-SHA-1 sizes?
In NextSSL, PBKDF2-HMAC-SHA-1 uses: output 16 to 1,024 bytes.
Who designed PBKDF2-HMAC-SHA-1 and when?
PBKDF2-HMAC-SHA-1 belongs to the PBKDF2 family, first published in 2000. Its origin: PKCS #5 v2.0; RFC 8018; NIST SP 800-132.
Which standards define PBKDF2-HMAC-SHA-1?
PBKDF2-HMAC-SHA-1 is referenced by RFC 8018, RFC 6070, NIST SP 800-132. It is specified in a FIPS standard.
Is PBKDF2-HMAC-SHA-1 safe to use?
PBKDF2-HMAC-SHA-1 is in the legacy tier. Old but not broken. Kept for interoperability; root API only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).
What other PBKDF2 variants are there?
NextSSL also registers pbkdf2, pbkdf2-hmac-sha256, pbkdf2-hmac-sha512 in the PBKDF2 family.
Related families
NIST SP 800-90A deterministic random bit generator built on HMAC
HKDFHMAC-based extract-and-expand key derivation function (RFC 5869)
HMACThe standard way to build a MAC from a cryptographic hash (RFC 2104, FIPS 198-1)
Argon2The Password Hashing Competition winner: memory-hard hashing standardised in RFC 9106
scryptColin Percival's memory-hard key derivation function, standardised in RFC 7914