PBKDF2 slows each guess down by repeating a hash many times, but it needs almost no memory, so graphics cards and custom chips can run huge numbers of guesses side by side. Argon2id makes every guess also fill and revisit a large block of memory, and memory is exactly what that parallel hardware is short of. For passwords people choose, that makes Argon2id the better default. For very short secrets like a pattern or a PIN, neither function is enough on its own: guessing also has to be pinned to the device with a secret held in hardware.
This post covers the economics, the current recommendations from RFC 9106, OWASP and NIST, how a phone shapes the parameters, and where PBKDF2 remains a perfectly good choice.
What a key derivation function is for
A key derivation function, or KDF, turns a secret a person can remember into key material. For human secrets it has a second job: making each guess expensive. The threat it's built for is offline guessing, where someone has copied the encrypted data or a password database and tries candidates on their own hardware, as fast as that hardware allows, with no lockout and nobody watching.
Three terms carry the rest of this post:
- A salt is a random value stored next to the result. It isn't secret. It makes each derivation unique, so one precomputed table can't attack everyone at once.
- A work factor is the cost you choose per derivation: iterations for PBKDF2, and memory, passes and lanes for Argon2id.
- Entropy measures how unpredictable a secret is, in bits. Every extra bit doubles the guesses needed.
A KDF multiplies the cost of each guess. It can't add entropy. That one fact explains most of what follows.
PBKDF2: costly in time, cheap in memory
PBKDF2, short for Password-Based Key Derivation Function 2, runs a keyed hash, usually HMAC-SHA256, in a long loop. NIST's SP 800-132, published in 2010, specifies how to use it and recommended "a minimum iteration count of 1,000", adding that 10,000,000 "may be appropriate" for especially critical keys. NIST has said it plans to revise that document.
As of November 2026, the OWASP Password Storage Cheat Sheet asks for far more:
| PBKDF2 variant | OWASP iterations |
|---|---|
| PBKDF2-HMAC-SHA256 | 600,000, the recommended choice |
| PBKDF2-HMAC-SHA512 | 220,000 |
| PBKDF2-HMAC-SHA1 | 1,400,000, legacy systems only |
The weakness isn't the count. A PBKDF2 computation needs only a few hundred bytes of working memory, so the attacker's cost per guess is pure computation, and computation is what graphics cards and purpose-built chips do best, thousands of copies at once. OWASP's cheat sheet is direct about it: "with high speed hardware (such as GPUs) and cloud services with many servers for rent, the cost to an attacker is relatively small" when hashing best practices aren't followed. More iterations slow the defender and the attacker by the same factor. They don't change who has the better hardware.
Argon2id: memory as the price of a guess
The fix came from asking what parallel hardware lacks. In his 2009 scrypt paper, presented at BSDCan, Colin Percival introduced memory-hard functions and argued that a KDF meant to resist custom hardware should need a lot of memory to compute. He measured an attacker's cost as the price of the hardware times how long it's needed. Memory takes up chip area, so a function that needs 128 MiB per guess forces every parallel guessing unit to carry its own 128 MiB.
Argon2 won the Password Hashing Competition in July 2015 and became RFC 9106 in September 2021. It comes in variants. Argon2i reads memory in an order that doesn't depend on the secret, which resists side-channel attacks, though the RFC notes it "makes more passes over the memory to protect from trade-off attacks", attacks that use less memory in exchange for more computation. Argon2d reads memory in a secret-dependent order. The primary variant, Argon2id, "works as Argon2i for the first half of the first pass over the memory and as Argon2d for the rest," to get some of each.
You set three costs:
- m, the memory, in kibibytes.
- t, the number of passes over that memory.
- p, the lanes: "independent (but synchronizing) computational chains" that can run in parallel.
RFC 9106 gives two default recommendations, both with a 128-bit salt: 2 GiB, 1 pass and 4 lanes, or, "if much less memory is available," 64 MiB, 3 passes and 4 lanes. OWASP sets a lower floor for password storage on servers: at least 19 MiB, 2 iterations and a parallelism of 1, with equivalent trade-offs such as 46 MiB with 1 iteration or 12 MiB with 3. It recommends Argon2id because it "provides a balanced approach to resisting both side-channel and GPU-based attacks."
Attacker economics, side by side
| PBKDF2 | Argon2id | |
|---|---|---|
| What a guess costs | Computation | Computation plus a block of memory |
| Memory per guess | A few hundred bytes | What you set; OWASP's floor is 19 MiB |
| Parallel hardware | Thousands of cheap guessers per chip | Limited by memory capacity and bandwidth |
| Standards | NIST SP 800-132; FIPS-140 validated implementations | RFC 9106; OWASP's first choice |
| On Android | Built in from API level 26 (PBKDF2withHmacSHA256) | Needs a separate library |
How big is the difference? Percival's paper estimated that, at settings for interactive logins, scrypt, his memory-hard design, cost an attacker with custom hardware about 260 times more than PBKDF2. He cautioned that the figures were very approximate and based on circa 2002 technology, so read them as a direction, not a measurement. The direction is the lasting point: once memory is part of the price, the attacker's hardware advantage shrinks, and the defender's ordinary processor looks a lot better.
Why short secrets need a hardware secret too
Now the uncomfortable arithmetic. A 4-digit PIN has 10,000 possible values, and Android's 3×3 unlock pattern has 389,112. Suppose a KDF were so heavy that one guess took a full second on the attacker's machine, an assumption that flatters the defender. One machine would still try every 3×3 pattern in about four and a half days, and copied data can be spread across as many machines as a budget allows. People don't choose evenly either: Aviv, Budzitowski and Kuber found that guessing the first 20% of human-chosen patterns "can be done as efficiently as guessing a random 2-digit PIN." The math of pattern locks has the full numbers.
No work factor fixes this, because a KDF multiplies the cost of each guess but can't multiply the number of possible answers. The fix is to make offline guessing impossible, by mixing in a secret the attacker can't copy.
That secret is called a pepper, and current guidance asks for one. NIST's SP 800-63B-4, final since July 2025, says verifiers "SHOULD perform an additional iteration of a keyed hashing or encryption operation using a secret key known only to the verifier." The key must be stored apart from the hashes, and should be kept "within a hardware-protected area, such as a hardware security module or trusted execution environment (TEE)." OWASP describes the same post-hashing approach, where the password hash "is then hashed again using an HMAC" keyed with the pepper.
Phones have long done this for their own lock screens. Apple's platform security guide says the iPhone passcode "is entangled with the device's UID", so "brute-force attempts need to be performed on the device under attack," with each attempt calibrated to take about 80 milliseconds. Android's Gatekeeper "enrolls and verifies passwords using a hardware-backed secret key" inside the TEE, and throttles repeated failures.
Cachette applies the same idea to its vault key: Argon2id with 128 MiB, 3 passes and 4 lanes, then HMAC-SHA256 keyed with a pepper in the Android Keystore, held by StrongBox where the phone has one and otherwise by the TEE. (On a phone with neither, the pepper is in software.) The pepper can't be exported, so the vault's files, copied off the phone, can't be attacked on another computer: every guess against them has to run on the phone and pay for a full Argon2id. How a pattern becomes a key walks through it step by step, and inside Cachette's encryption covers the rest of the design.
Choosing parameters on a phone
RFC 9106's procedure is short: choose Argon2id, set the lanes, take as much memory as each call can afford, then find "the maximum t such that the running time does not exceed the affordable time." On a phone, afford has three parts.
- Time. OWASP's rule of thumb is that a hash "should take less than one second." In Cachette, the whole unlock, from lifting your finger to the vault's first frame, is fixed at 1,000 ms. Deriving the key and trying it on every stored record both have to fit inside that second, on older supported phones as well as new ones.
- Memory. RFC 9106's first recommendation, 2 GiB for each derivation, isn't realistic for an app on a phone that shares its memory with everything else running. Cachette uses 128 MiB, twice the RFC's lower-memory option.
- Parallelism. Four lanes match the RFC's default and let the work spread across a phone's cores, so more memory fits into the same time.
The pepper also changes what these numbers defend against. On a server, Argon2id's settings decide how fast someone with a stolen database can guess. With a pepper in hardware there's no offline attack to slow down, so the settings set the price of each guess for someone who has your phone and a way to run guesses on it. That's a far smaller arena, and 128 MiB per guess shrinks it further.
Where a pepper can't follow the data, the settings are the defence again. A Cachette backup has to restore on a new phone, so it can't use the old phone's pepper: each backup file carries a check value for its vault's pattern, made with the same Argon2id settings and no pepper, and someone with a copy of the file can test guesses against it offline. The backup's contents stay sealed under its own random 24-word phrase, but the pattern is guarded by what's left: 128 MiB per guess, and your choice of a pattern that isn't a common shape. That's memory-hardness doing exactly the job this post describes.
When PBKDF2 is still a fine choice
None of this makes PBKDF2 a mistake. It's the right tool in several places.
- Compliance. OWASP notes that PBKDF2 "is permitted by NIST SP 800-63B-4 and has FIPS-140 validated implementations," and recommends it when FIPS-140 compliance is required, at 600,000 iterations or more with HMAC-SHA-256.
- High-entropy inputs. When the input is already a random key or a long random phrase, the KDF isn't what stops guessing. BIP-39, the recovery phrase standard, turns a phrase into a seed with PBKDF2-HMAC-SHA512 and just 2,048 iterations. A randomly generated 24-word phrase carries 256 bits of entropy, far beyond any search, so the light setting isn't a weakness there.
- Platform support. Android's SecretKeyFactory offers PBKDF2 with HMAC-SHA256 from API level 26, while Argon2 means shipping and maintaining a separate library.
- Tiny devices. SP 800-132 notes that capability varies "from a smart card to high-end workstations or servers." PBKDF2 runs where a large block of memory simply doesn't exist.
The rule that ties it together is to match the function to the secret. For a long random secret, almost any sound KDF will do. For a password, prefer Argon2id with as much memory as your time budget allows. For something as short as a pattern or a PIN, use a memory-hard function and a secret held in hardware, so the only place anyone can guess is the device in your hand.