||This article has an unclear citation style. (December 2012)|
||This article uses bare URLs for citations. (December 2012)|
PBKDF2 (Password-Based Key Derivation Function 2) is a key derivation function that is part of RSA Laboratories' Public-Key Cryptography Standards (PKCS) series, specifically PKCS #5 v2.0, also published as Internet Engineering Task Force's RFC 2898. It replaces an earlier standard, PBKDF1, which could only produce derived keys up to 160 bits long.
PBKDF2 applies a pseudorandom function, such as a cryptographic hash, cipher, or HMAC to the input password or passphrase along with a salt value and repeats the process many times to produce a derived key, which can then be used as a cryptographic key in subsequent operations. The added computational work makes password cracking much more difficult, and is known as key stretching. When the standard was written in 2000, the recommended minimum number of iterations was 1000, but the parameter is intended to be increased over time as CPU speeds increase. Having a salt added to the password reduces the ability to use precomputed hashes (rainbow tables) for attacks, and means that multiple passwords have to be tested individually, not all at once. The standard recommends a salt length of at least 64 bits.
Key derivation process 
The PBKDF2 key derivation function has five input parameters:
DK = PBKDF2(PRF, Password, Salt, c, dkLen)
- PRF is a pseudorandom function of two parameters with output length hLen (e.g. a keyed HMAC)
- Password is the master password from which a derived key is generated
- Salt is a cryptographic salt
- c is the number of iterations desired
- dkLen is the desired length of the derived key
- DK is the generated derived key
Each hLen-bit block Ti of derived key DK, is computed as follows:
DK = T1 || T2 || ... || Tdklen/hlen Ti = F(Password, Salt, Iterations, i)
The function F is the xor (^) of c iterations of chained PRFs. The first iteration of PRF uses Password as the PRF key and Salt concatenated to i encoded as a big-endian 32-bit integer. (Note that i is a 1-based index.) Subsequent iterations of PRF use Password as the PRF key and the output of the previous PRF computation as the salt:
F(Password, Salt, Iterations, i) = U1 ^ U2 ^ ... ^ Uc
U1 = PRF(Password, Salt || INT_msb(i)) U2 = PRF(Password, U1) ... Uc = PRF(Password, Uc-1)
For example, WPA2 uses:
DK = PBKDF2(HMAC−SHA1, passphrase, ssid, 4096, 256)
- openssl's C implementation
- OpenBSD's C implementation
- PolarSSL's C implementation
- CyaSSL's C implementation
- ActionScript 3.0 implementation
- .NET's built-in function
- C# implementation
- Go implementation
- Java implementation (PBKDF2WithHmacSHA1)
- Python implementation
- Perl implementation
- Ruby's standard library
- Ruby implementation
- REBOL2 implementation
- PHP implementations: native (added in v5.1.2), manual
- Scala implementation
Systems that use PBKDF2 
- Wi-Fi Protected Access (WPA and WPA2) used to secure Wi-Fi wireless networks
- Microsoft Windows Data Protection API (DPAPI)
- OpenDocument encryption used in OpenOffice.org
- WinZip's AES Encryption scheme.
- 1Password use PBKDF2 to protect encryption keys.
- LastPass for password hashing.
- SQLCipher for key derivation and strengthening.
- STRIP for key derivation and strengthening.
- Apple's iOS mobile operating system, for protecting user passcodes and passwords 
- Mac OS X Mountain Lion for user passwords 
- The Django web framework, as of release 1.4.
- The MODX content management framework, as of version 2.0.
- Filesystem encryption in the Android operating system, as of version 3.0.
- The encryption and decryption schema of Zend Framework, to generate encryption and authentication keys. 
- Cisco IOS and IOS XE Type 4 password hashes
- Dashlane uses PBKDF2 with over 10,000 iterations to compute the encryption key .
Disk encryption software 
- FileVault (Mac OS X) from Apple Computer
- FreeOTFE (Windows and Pocket PC PDAs); also supports mounting Linux (e.g. LUKS) volumes under Windows
- LUKS (Linux Unified Key Setup) (Linux)
- TrueCrypt (Windows, Linux, and Mac OS X)
- DiskCryptor (Windows)
- Cryptographic disk (NetBSD)
- GEOM ELI module for FreeBSD
- softraid crypto for OpenBSD
- EncFS (Linux, FreeBSD and Mac OS X) since v1.5.0
- GRUB2 (boot loader)
BlackBerry vulnerability 
In September 2010, ElcomSoft announced a password cracking utility for Research In Motion BlackBerry device backups that takes advantage of what Vladimir Katalov, ElcomSoft's CEO, described as the "very strange way, to say the least" in which the BlackBerry uses PBKDF2. BlackBerries encrypts backup files with AES-256. In turn, the AES key is derived from the user's password using PBKDF2. However the BlackBerry software uses only one PBKDF2 iteration, thus not taking advantage of the key security features of PBKDF2. By contrast, according to Katalov, Apple's iOS 3 uses 2,000 iterations and iOS 4 uses 10,000.
Alternatives to PBKDF2 
One weakness of PBKDF2 is that while its number of iterations can be adjusted to make it take an arbitrarily large amount of computing time, it can be implemented with a small circuit and very little RAM, which makes brute-force attacks using ASICs or GPUs relatively cheap. The bcrypt key derivation function requires a larger (but still fixed) amount of RAM and is slightly stronger against such attacks, while the more modern scrypt key derivation function can use arbitrarily large amounts of memory and is therefore more resistant to ASIC and GPU attacks.
- iOS security, May 2012, Apple inc.
- "How Django stores passwords". Django 1.4 documentation. 2012-03-23. Retrieved 31 July 2012.
- Notes on the implementation of encryption in Android 3.0, September 2012, Android Open Source Project.
- Encrypt/decrypt using block ciphers, Programmer’s Reference Guide of Zend Framework 2.
- Colin Percival. scrypt. As presented in "Stronger Key Derivation via Sequential Memory-Hard Functions". presented at BSDCan'09, May 2009.
- RSA PKCS #5 – RSA Laboratories PKCS #5 v2.0 - Multiple Formats, and test vectors.
- RFC 2898 – Specification of PKCS #5 v2.0.
- RFC 6070 – Test vectors for PBKDF2 with HMAC-SHA1.
- NIST Special Publication 800-132 Recommendation for Password-Based Key Derivation