A password database will eventually leak; the question is what an attacker can do with it afterwards. If the passwords are stored as fast hashes, a single graphics card can test billions of guesses per second against them. Password hashing functions exist to make each guess expensive, and Argon2, the winner of the Password Hashing Competition in 2015 and the subject of RFC 9106 (2021), makes it expensive in the resource that attackers find hardest to scale: memory.
This post explains how Argon2 works, what its three variants and three parameters do, how it compares with PBKDF2, bcrypt and scrypt, and how to configure it today. Where it gives concrete parameters, they come from RFC 9106 and the OWASP Password Storage Cheat Sheet, both linked at the end.
1. The Evolution of Hashing: Beyond CPU-Bound Math
General-purpose hash functions such as MD5 and the SHA family are designed to be fast, which is exactly wrong for passwords. The first answer was iteration: PBKDF2, published in PKCS #5 v2.0 (RFC 2898, 2000; now RFC 8018), applies an HMAC thousands or hundreds of thousands of times. It costs only CPU time, and GPUs and ASICs have far more of that per dollar than a server does.
bcrypt (Niels Provos and David Mazières, USENIX 1999) built a slow, adaptive hash on the Blowfish key schedule, with a tunable work factor. It uses about 4 KiB of state, which happened to make it awkward for GPUs, but that amount is fixed. scrypt (Colin Percival, 2009; RFC 7914) was the first widely used function designed to be memory-hard: its memory use is a parameter, so defenders can make each guess cost a chosen amount of RAM. Argon2 continues that line with a simpler design, a separate memory parameter, and variants for different threat models.
| Function | Year | Cost it imposes | Memory per hash |
|---|---|---|---|
| PBKDF2 | 2000 | Iterations (CPU) | Negligible |
| bcrypt | 1999 | Work factor (CPU) | About 4 KiB, fixed |
| scrypt | 2009 | CPU and memory | 128 × r × N bytes (16 MiB at N = 214, r = 8) |
| Argon2 | 2015 | CPU and memory, set separately | m KiB, chosen by the defender |
2. Memory-Hardness: Turning RAM into a Defensive Barrier
Argon2 fills a large array of 1 KiB blocks and then makes passes over it. Each new block is computed from the previous block and one earlier "reference" block, using a compression function built from the BLAKE2b round function. Because the reference block can be anywhere in the array, an attacker who wants to compute the hash quickly needs the whole array in memory; one who stores less has to recompute the missing blocks on demand, which costs time. With m = 64 MiB, the array holds 65,536 blocks.
That is what memory-hardness buys. Arithmetic is cheap to replicate on a chip; memory is not. An attacker running thousands of guesses in parallel needs thousands of copies of the array, and the cost of the attack grows with the memory each guess requires.
3. The Tuning Parameters: Time, Memory, and Parallelism
Argon2 takes three cost parameters. m is the total memory in KiB. t is the number of passes over that memory. p is the number of lanes, independent strips of the array that can be filled by separate threads. The memory is divided among the lanes, so raising p does not raise the total memory; it lets a defender with several cores finish the same work sooner.
RFC 9106 gives two recommended settings. The first, suggested as a default for all environments, is Argon2id with t = 1, p = 4 and m = 2 GiB. The second, for memory-constrained environments, is Argon2id with t = 3, p = 4 and m = 64 MiB. OWASP's minimum for web applications is lower: Argon2id with m = 19 MiB, t = 2 and p = 1. Both documents expect you to raise the cost as far as your login latency and server memory allow.
| Source | Variant | m | t | p |
|---|---|---|---|---|
| RFC 9106, first recommended option | Argon2id | 2 GiB | 1 | 4 |
| RFC 9106, second recommended option | Argon2id | 64 MiB | 3 | 4 |
| OWASP minimum | Argon2id | 19 MiB | 2 | 1 |
4. Argon2i, Argon2d, and Argon2id: Choosing the Right Variant
The variants differ only in how the reference block is chosen. In Argon2d it depends on the data being hashed, which makes the memory access pattern unpredictable and gives the strongest resistance to attackers who try to save memory. In Argon2i it depends only on the position in the array and the parameters, so the access pattern reveals nothing about the password. Argon2id uses Argon2i's addressing for the first half of the first pass and Argon2d's for the rest.
RFC 9106 makes Argon2id the variant that implementations must support and the one to use when in doubt. Argon2d suits settings where side channels are not a concern, such as proof-of-work. Argon2i has been shown to be more vulnerable to attacks that trade memory for extra computation, which is one reason the hybrid exists.
| Variant | Addressing | Strength | Weakness |
|---|---|---|---|
| Argon2d | Data-dependent | Best resistance to memory-saving attacks | Access pattern can leak through cache timing |
| Argon2i | Data-independent | No secret-dependent access pattern | More vulnerable to time-memory trade-offs |
| Argon2id | Independent, then dependent | Balanced; the recommended default | Small leakage window after the first half-pass |
5. The Side-Channel Threat: Mitigating Timing Attacks
A side-channel attacker does not steal the hash; they watch the machine computing it. With data-dependent addressing, which memory locations are read depends on the password, and an attacker who shares a CPU cache with the server could in principle learn something from that. Argon2i and the first half-pass of Argon2id avoid the problem by making the access pattern independent of the secret.
The more common timing mistake in practice is outside the hash entirely: comparing the computed hash with the stored one using an ordinary string comparison, which returns as soon as a byte differs. Use the verification function your library provides, which compares in constant time, rather than hashing and comparing yourself.
6. Hardware Resistance: Countering GPUs, FPGAs, and ASICs
GPUs and custom chips win against CPU-bound hashes by running many cheap copies of the computation at once. Memory-hardness attacks that advantage directly: each parallel guess needs its own copy of the array, and the speed of the attack is limited by how much memory and memory bandwidth the attacker can buy. A chip can add arithmetic units cheaply, but not gigabytes of fast memory.
This is a cost argument, not a guarantee. A determined attacker with dedicated hardware can still test guesses, and a weak password still falls quickly. What Argon2 changes is the price of each guess, which is why the memory parameter should be set as high as the defender can afford.
7. The Password Hashing Competition (PHC) and Where Bcrypt Stands
The Password Hashing Competition ran from 2013 to 2015 as an open call for new password hashing functions, modelled on the competitions that produced AES and SHA-3. Argon2, by Alex Biryukov, Daniel Dinu and Dmitry Khovratovich of the University of Luxembourg, was announced as the winner in July 2015, with special recognition given to Catena, Lyra2, Makwa and yescrypt.
The competition did not end bcrypt. OWASP still lists it as acceptable for legacy systems, with a work factor of at least 10, and notes its 72-byte limit on input length. The difference is that bcrypt's memory use cannot be raised, so its advantage against specialized hardware does not grow as hardware does. For new systems the recommendation is Argon2id.
8. The Economic Cost of Brute Force: Electricity and Hardware Overhead
An offline attack is an economic problem. The attacker's cost per guess is roughly the hardware needed to hold one guess's working memory for the duration of one hash, plus the electricity to run it. If a hash needs m bytes of memory for s seconds, a machine with M bytes of usable memory can test at most about M / m guesses every s seconds, regardless of how much arithmetic it has to spare.
That arithmetic is why the defender's two levers are memory and time. Doubling either roughly halves the guesses an attacker can afford per dollar. It is also why password strength still matters: no setting makes a password from the top of a leaked-password list safe, because the attacker will try it first.
9. Energy: Forcing the Attacker to Pay for Memory
Moving data to and from memory costs more energy than computing on it, so a function dominated by memory traffic is also dominated by memory's energy cost. An attacker cannot make Argon2's passes over the array cheaper by using faster logic; they have to move the same bytes.
The defender pays this cost too, once per login. That is the trade every password hash makes: the defender spends a fixed amount per legitimate attempt, and the attacker spends the same amount per guess, multiplied by the number of guesses needed.
10. Data-Dependent vs. Data-Independent Memory Access
Data-dependent addressing (Argon2d) means the next memory location to read is computed from the contents already written. An attacker cannot know in advance which blocks will be needed, so they cannot safely discard any of them. Data-independent addressing (Argon2i) fixes the access order in advance, which leaks nothing but lets a clever attacker plan which blocks to keep and which to recompute.
Argon2id takes the first property where it matters least and the second where it matters most. The early part of the computation, which a side-channel attacker would watch, uses independent addressing; the rest, which determines how much memory an attacker must keep, uses dependent addressing.
11. Parallelism and Concurrency in High-Performance Backends
On a server, p sets how many threads one hash may use. Higher p shortens the time per login for the same memory, but every login now occupies several cores. A busy authentication service usually gets better throughput from p = 1 and many logins in parallel than from a high p per login.
The more important limit is memory under load. If each hash uses 64 MiB and a hundred logins arrive at once, the service needs 6.4 GiB at that moment. Bound the number of concurrent hashes, rate-limit login attempts, and measure peak memory, not only the latency of a single hash.
12. The "Sandbag" Analogy: Calculating Computational Friction
Think of each password guess as carrying a sandbag. The defender chooses its weight once: the memory and time each hash requires. The legitimate user carries it once per login and barely notices; the attacker carries it once per guess, millions or billions of times.
A useful approximation of the weight is memory multiplied by time, since an attacker's hardware has to hold m bytes for the duration of each hash. The parallelism parameter does not add to it: it changes how quickly the defender can carry the bag, not how heavy it is.
13. Implementation Standards: Salt, Pepper, and Iteration Counts
A salt is a random value, unique per stored password, kept alongside the hash. It ensures that two users with the same password get different hashes and that precomputed tables are useless. RFC 9106 recommends 128 bits (16 bytes). Generate a new salt whenever a password is set or changed, not on every login.
A pepper is a secret shared by all passwords and stored outside the database, for example in a secrets manager or a hardware security module, so that a stolen database alone is not enough to start guessing. Argon2 has an optional secret-key input for exactly this purpose; OWASP also describes applying a pepper with an HMAC before hashing. Plan for rotating it, because changing a pepper invalidates every stored hash.
Store the parameters with the hash. The standard encoded form, for example $argon2id$v=19$m=19456,t=2,p=1$<salt>$<hash>, carries the variant, version, costs and salt, which lets you raise the costs later and rehash each password the next time its owner logs in.
- Use Argon2id.
- Use a random salt of at least 16 bytes per password.
- Start at or above the OWASP minimum and raise memory first.
- Verify with the library's constant-time verify function.
- Rehash on login when the stored parameters are below your current ones.
14. Argon2 in the Wild: From Rust Crates to Cloud Infrastructure
Argon2 is widely available. libsodium's crypto_pwhash uses Argon2id by default. In Rust, the RustCrypto argon2 crate defaults to Argon2id with m = 19 MiB, t = 2 and p = 1, the OWASP minimum. OpenSSL added an Argon2 key derivation function in version 3.2, and the reference implementation from the competition is maintained on GitHub.
Outside password storage, it is used to derive encryption keys from passphrases: LUKS2 disk encryption supports Argon2i and Argon2id, and KeePass's KDBX 4 format supports Argon2d and Argon2id. Where Argon2 is not available, usually because a system must use FIPS-approved algorithms, PBKDF2 with a high iteration count remains the standard choice; OWASP recommends 600,000 iterations of PBKDF2-HMAC-SHA256.
15. The Future of Memory-Bound Proof-of-Work
The same property that protects passwords has been used to keep cryptocurrency mining open to ordinary hardware. The Argon2 paper itself suggests Argon2d for proof-of-work. Monero's RandomX, a proof-of-work designed to favor general-purpose CPUs, uses Argon2d to initialize its cache. Earlier memory-hard designs such as Ethereum's Ethash eventually attracted dedicated mining hardware anyway, which shows the limit: memory-hardness raises the cost of specialization but does not forbid it.
16. Why Argon2 is the Modern "Gold Standard" for Credential Storage
Argon2id is the default recommendation of RFC 9106 and of OWASP, it is the default in libsodium and in the main Rust implementation, and its parameters let defenders raise the cost as hardware improves. That combination of open review, a published standard and broad library support is what earns it the label.
It is not universal. NIST's SP 800-63B requires a suitable key derivation function and says a memory-hard function should be used, but names PBKDF2 and Balloon as its examples rather than Argon2. Systems bound by FIPS validation therefore often still use PBKDF2. For everyone else, Argon2id is the sensible default.
Conclusion
Argon2's idea is simple: make every guess cost memory, because memory is what attackers find hardest to multiply. Its variants exist to manage one trade-off, between leaking an access pattern and letting attackers save memory, and Argon2id settles it well enough to be the recommended default. Its parameters are the part that needs care: choose Argon2id, start at the published minimums or above, store the parameters with each hash, and raise them over time.
References
- RFC 9106: Argon2 Memory-Hard Function for Password Hashing and Proof-of-Work Applications (2021)
- OWASP Password Storage Cheat Sheet
- NIST SP 800-63B, Digital Identity Guidelines: Authentication and Lifecycle Management
- Password Hashing Competition
- Argon2 reference implementation (PHC winner)
- libsodium documentation: Password hashing
- RustCrypto argon2 crate documentation
- RFC 7914: The scrypt Password-Based Key Derivation Function
- RFC 8018: PKCS #5: Password-Based Cryptography Specification Version 2.1
- Provos, N., & Mazières, D. (1999). A Future-Adaptable Password Scheme. USENIX Annual Technical Conference.
- RandomX proof-of-work algorithm