RFC 9106: Argon2 Memory-Hard Function for Password Hashing and Proof-of-Work Applications
- A. Biryukov,
- D. Dinu,
- D. Khovratovich,
- S. Josefsson
Abstract
This document describes the Argon2 memory-hard function for
password hashing and proof-of-work applications. We provide an
implementer
Status of This Memo
This document is not an Internet Standards Track specification; it is published for informational purposes.¶
This document is a product of the Internet Research Task Force
(IRTF). The IRTF publishes the results of Internet
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
https://
Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://
1. Introduction
This document describes the Argon2 [ARGON2ESP] memory-hard function for
password hashing and proof-of-work applications. We provide an
implementer
Argon2 is a memory-hard function [HARD]. It is a streamlined design.
It aims at the highest memory-filling rate and effective use of
multiple computing units, while still providing defense against
trade-off attacks. Argon2 is optimized for the x86 architecture
and exploits the cache and memory organization of the recent
Intel and AMD processors. Argon2 has one primary variant, Argon2id, and two supplementary variants, Argon2d and
Argon2i. Argon2d uses data-dependent memory
access, which makes it suitable for cryptocurrencie
Argon2id MUST be supported by any implementation of this document, whereas Argon2d and Argon2i MAY be supported.¶
Argon2 is also a mode of operation over a fixed
For further background and discussion, see the Argon2 paper [ARGON2].¶
This document represents the consensus of the Crypto Forum Research Group (CFRG).¶
1.1. Requirements Language
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
2. Notation and Conventions
- x^y
- integer x multiplied by itself integer y times¶
- a*b
- multiplication of integer a and integer b¶
- c-d
- subtraction of integer d from integer c¶
- E_f
- variable E with subscript index f¶
- g / h
- integer g divided by integer h. The result is a rational number.¶
- I(j)
- function I evaluated at j¶
- K || L
- string K concatenated with string L¶
- a XOR b
- bitwise exclusive-or between bitstrings a and b¶
- a mod b
- remainder of integer a modulo integer b, always in range [0, b-1]¶
- a >>> n
- rotation of 64-bit string a to the right by n bits¶
- trunc(a)
- the 64-bit value, truncated to the 32 least significant bits¶
- floor(a)
- the largest integer not bigger than a¶
- ceil(a)
- the smallest integer not smaller than a¶
- extract(a, i)
- the i-th set of 32 bits from bitstring a, starting from 0-th¶
- |A|
- the number of elements in set A¶
- LE32(a)
- 32-bit integer a converted to a byte string in little endian (for example, 123456 (decimal) is 40 E2 01 00)¶
- LE64(a)
- 64-bit integer a converted to a byte string in little endian (for example, 123456 (decimal) is 40 E2 01 00 00 00 00 00)¶
- int32(s)
- 32-bit string s is converted to a non-negative integer in little endian¶
- int64(s)
- 64-bit string s is converted to a non-negative integer in little endian¶
- length(P)
- the byte length of string P expressed as 32-bit integer¶
- ZERO(P)
- the P-byte zero string¶
3. Argon2 Algorithm
3.1. Argon2 Inputs and Outputs
Argon2 has the following input parameters:¶
The Argon2 output, or "tag", is a string T bytes long.¶
3.2. Argon2 Operation
Argon2 uses an internal compression function G with two
1024-byte inputs, a 1024-byte output, and an internal hash
function H^x(), with x being its output length in bytes. Here, H^x() applied to string A is the BLAKE2b ([BLAKE2], Section 3.3) function, which takes
The Argon2 operation is as follows.¶
3.3. Variable-Length Hash Function H'
Let V_i be a 64-byte block and W_i be its first 32 bytes. Then we define function H' as follows:¶
3.4. Indexing
To enable parallel block computation, we further partition the memory matrix into SL = 4 vertical slices. The intersection of a slice and a lane is called a segment, which has a length of q/SL. Segments of the same slice can be computed in parallel and do not reference blocks from each other. All other blocks can be referenced.¶
3.4.1. Computing the 32-Bit Values J_1 and J_2
3.4.1.1. Argon2d
J_1 is given by the first 32 bits of block B[i][j-1], while J_2 is given by the next 32 bits of block B[i][j-1]:¶
3.4.1.2. Argon2i
For each segment, we do the following. First, we compute the value Z as:¶
where¶
- r:
- the pass number¶
- l:
- the lane number¶
- sl:
- the slice number¶
- m':
- the total number of memory blocks¶
- t:
- the total number of passes¶
- y:
- the Argon2 type (0 for Argon2d, 1 for Argon2i, 2 for Argon2id)¶
Then we compute:¶
which are partitioned into q/(SL) 8-byte values X, which are viewed as X1||X2 and converted to J_1=int32(X1) and J_2=int32(X2).¶
The values r, l, sl, m', t, y, and i are represented as 8 bytes in little endian.¶
3.4.1.3. Argon2id
If the pass number is 0 and the slice number is 0 or 1, then compute J_1 and J_2 as for Argon2i, else compute J_1 and J_2 as for Argon2d.¶
3.4.2. Mapping J_1 and J_2 to Reference Block Index [l][z]
The value of l = J_2 mod p gives the index of the lane from which the block will be taken. For the first pass (r=0) and the first slice (sl=0), the block is taken from the current lane.¶
The set W contains the indices that are referenced according to the following rules:¶
Then take a block from W with a nonuniform distribution over [0, |W|) using the following mapping:¶
To avoid floating point computation, the following approximation is used:¶
Then take the zz-th index from W; it will be the z value for the reference block index [l][z].¶
3.5. Compression Function G
The compression function G is built upon the BLAKE2b-based transformation P. P operates on the 128-byte input, which can be viewed as eight 16-byte registers:¶
The compression function G(X, Y) operates on two 1024-byte blocks X and Y. It first computes R = X XOR Y. Then R is viewed as an 8x8 matrix of 16-byte registers R_0, R_1, ... , R_63. Then P is first applied to each row, and then to each column to get Z:¶
Finally, G outputs Z XOR R:¶
3.6. Permutation P
Permutation P is based on the round function of BLAKE2b. The eight 16-byte inputs S_0, S_1, ... , S_7 are viewed as a 4x4 matrix of 64-bit words, where S_i = (v_{2*i+1} || v_{2*i}):¶
It works as follows:¶
GB(a, b, c, d) is defined as follows:¶
The modular additions in GB are combined with 64-bit multiplications
4. Parameter Choice
Argon2d is optimized for settings where the adversary does not get regular access to system memory or CPU, i.e., they cannot run side-channel attacks based on the timing information, nor can they recover the password much faster using garbage collection. These settings are more typical for backend servers and cryptocurrency minings. For practice, we suggest the following settings:¶
Argon2id is optimized for more realistic settings, where the adversary can possibly access the same machine, use its CPU, or mount cold-boot attacks. We suggest the following settings:¶
We recommend the following procedure to select the type and the parameters for practical use of Argon2.¶
5. Test Vectors
This section contains test vectors for Argon2.¶
5.1. Argon2d Test Vectors
We provide test vectors with complete outputs (tags). For the convenience of developers, we also provide some interim variables -- concretely, the first and last memory blocks of each pass.¶
6. IANA Considerations
This document has no IANA actions.¶
7. Security Considerations
7.1. Security as a Hash Function and KDF
The collision and preimage resistance levels of Argon2 are equivalent to those of the underlying BLAKE2b hash function. To produce a collision, 2^(256) inputs are needed. To find a preimage, 2^(512) inputs must be tried.¶
The KDF security is determined by the key length
and the size of the internal state of hash function H'.
To distinguish the output of the keyed Argon2 from random, a minimum of
7.2. Security against Time-Space Trade-off Attacks
Time-space trade-offs allow computing a memory-hard function storing fewer memory blocks at the cost of more calls to the internal compression function. The advantage of trade-off attacks is measured in the reduction factor to the time-area product, where memory and extra compression function cores contribute to the area and time is increased to accommodate the recomputation of missed blocks. A high reduction factor may potentially speed up the preimage search.¶
The best-known attack on the 1-pass and 2-pass Argon2i is the low-storage attack described in [CBS16], which reduces the time-area product (using the peak memory value) by the factor of 5. The best attack on Argon2i with 3 passes or more is described in [AB16], with the reduction factor being a function of memory size and the number of passes (e.g., for 1 gibibyte of memory, a reduction factor of 3 for 3 passes, 2.5 for 4 passes, 2 for 6 passes). The reduction factor grows by about 0.5 with every doubling of the memory size. To completely prevent time-space trade-offs from [AB16], the number of passes MUST exceed the binary logarithm of memory minus 26. Asymptotically, the best attack on 1-pass Argon2i is given in [BZ17], with maximal advantage of the adversary upper bounded by O(m^(0.233)), where m is the number of blocks. This attack is also asymptotically optimal as [BZ17] also proves the upper bound on any attack is O(m^(0.25)).¶
The best trade-off attack on t-pass Argon2d is the ranking trade-off attack, which reduces the time-area product by the factor of 1.33.¶
The best attack on Argon2id can be obtained by complementing the best attack on the 1-pass Argon2i with the best attack on a multi-pass Argon2d. Thus, the best trade-off attack on 1-pass Argon2id is the combined low-storage attack (for the first half of the memory) and the ranking attack (for the second half), which generate the factor of about 2.1. The best trade-off attack on t-pass Argon2id is the ranking trade-off attack, which reduces the time-area product by the factor of 1.33.¶
7.3. Security for Time-Bounded Defenders
A bottleneck in a system employing the password hashing function is often the function latency rather than memory costs. A rational defender would then maximize the brute-force costs for the attacker equipped with a list of hashes, salts, and timing information for fixed computing time on the defender's machine. The attack cost estimates from [AB16] imply that for Argon2i, 3 passes is almost optimal for most reasonable memory sizes; for Argon2d and Argon2id, 1 pass maximizes the attack costs for the constant defender time.¶
7.4. Recommendations
The Argon2id variant with t=1 and 2 GiB memory is the FIRST RECOMMENDED option and is suggested
as a default setting for all environments. This setting is secure against side-channel attacks
and maximizes adversarial costs on dedicated brute-force hardware. The Argon2id variant with t=3 and 64 MiB memory is the SECOND RECOMMENDED option and is suggested
as a default setting for memory
8. References
8.1. Normative References
- [BLAKE2]
-
Saarinen, M-J., Ed. and J-P. Aumasson, "The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)", RFC 7693, DOI 10
.17487 , , <https:///RFC7693 www >..rfc -editor .org /info /rfc7693 - [RFC2119]
-
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10
.17487 , , <https:///RFC2119 www >..rfc -editor .org /info /rfc2119 - [RFC8174]
-
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10
.17487 , , <https:///RFC8174 www >..rfc -editor .org /info /rfc8174
8.2. Informative References
- [AB15]
-
Biryukov, A. and D. Khovratovich, "Tradeoff Cryptanalysis of Memory-Hard Functions", ASIACRYPT 2015, DOI 10
.1007 , , <https:///978 -3 -662 -48800 -3 _26 eprint >..iacr .org /2015 /227 .pdf - [AB16]
-
Alwen, J. and J. Blocki, "Efficiently Computing Data
-Independent , CRYPTO 2016, DOI 10Memory-Hard Functions" .1007 , , <https:///978 -3 -662 -53008 -5 _9 eprint >..iacr .org /2016 /115 .pdf - [ARGON2]
-
Biryukov, A., Dinu, D., and D. Khovratovich, "Argon2: the memory-hard function for password hashing and other applications", , <https://
www >..cryptolux .org /images /0 /0d /Argon2 .pdf - [ARGON2ESP]
-
Biryukov, A., Dinu, D., and D. Khovratovich, "Argon2: New Generation of Memory-Hard Functions for Password Hashing and Other Applications", Euro SnP 2016, DOI 10
.1109 , , <https:///Euro SP .2016 .31 www >..cryptolux .org /images /d /d0 /Argon2ESP .pdf - [BZ17]
-
Blocki, J. and S. Zhou, "On the Depth
-Robustness , TCC 2017, DOI 10and Cumulative Pebbling Cost of Argon2i" .1007 , , <https:///978 -3 -319 -70500 -2 _15 eprint >..iacr .org /2017 /442 .pdf - [CBS16]
-
Boneh, D., Corrigan-Gibbs, H., and S. Schechter, "Balloon Hashing: A Memory-Hard Function Providing Provable Protection Against Sequential Attacks", ASIACRYPT 2016, DOI 10
.1007 , , <https:///978 -3 -662 -53887 -6 _8 eprint >..iacr .org /2016 /027 .pdf - [HARD]
-
Alwen, J. and V. Serbinenko, "High Parallel Complexity Graphs and Memory-Hard Functions", STOC '15, DOI 10
.1145 , , <https:///2746539 .2746622 eprint >..iacr .org /2014 /238 .pdf
Acknowledgements
We greatly thank the following individuals who helped in preparing and reviewing this document: Jean-Philippe Aumasson, Samuel Neves, Joel Alwen, Jeremiah Blocki, Bill Cox, Arnold Reinhold, Solar Designer, Russ Housley, Stanislav Smyshlyaev, Kenny Paterson, Alexey Melnikov, and Gwynne Raskind.¶
The work described in this document was done before Daniel Dinu joined Intel, while he was at the University of Luxembourg.¶