| 1 |
Argon2: the memory-hard function for password hashing and other |
| 2 |
applications |
| 3 |
|
| 4 |
Designers: Alex Biryukov, Daniel Dinu, and Dmitry Khovratovich |
| 5 |
University of Luxembourg, Luxembourg |
| 6 |
|
| 7 |
[email protected], [email protected], [email protected] |
| 8 |
|
| 9 |
https://www.cryptolux.org/index.php/Argon2 |
| 10 |
https://github.com/P-H-C/phc-winner-argon2 |
| 11 |
|
| 12 |
https://github.com/khovratovich/Argon2 |
| 13 |
|
| 14 |
Version 1.3 of Argon2: PHC release |
| 15 |
March 24, 2017 |
| 16 |
|
| 17 |
Contents |
| 18 |
|
| 19 |
1 Introduction 2 |
| 20 |
|
| 21 |
2 Definitions 3 |
| 22 |
|
| 23 |
2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 |
| 24 |
|
| 25 |
2.2 Model for memory-hard functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 |
| 26 |
|
| 27 |
3 Specification of Argon2 4 |
| 28 |
|
| 29 |
3.1 Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 |
| 30 |
|
| 31 |
3.2 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 |
| 32 |
|
| 33 |
3.3 Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 |
| 34 |
|
| 35 |
3.4 Compression function G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 |
| 36 |
|
| 37 |
4 Features 8 |
| 38 |
|
| 39 |
4.1 Available features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 |
| 40 |
|
| 41 |
4.2 Possible future extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 |
| 42 |
|
| 43 |
5 Security analysis 9 |
| 44 |
|
| 45 |
5.1 Ranking tradeoff attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 |
| 46 |
|
| 47 |
5.2 Memory optimization attack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 |
| 48 |
|
| 49 |
5.3 Attack on iterative compression function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 |
| 50 |
|
| 51 |
5.4 Security of Argon2 to generic attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 |
| 52 |
|
| 53 |
5.5 Security of Argon2 to ranking tradeoff attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 |
| 54 |
|
| 55 |
5.6 Security of Argon2i to generic tradeoff attacks on random graphs . . . . . . . . . . . . . . . . . . 12 |
| 56 |
|
| 57 |
5.7 Summary of tradeoff attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 |
| 58 |
|
| 59 |
6 Design rationale 12 |
| 60 |
|
| 61 |
6.1 Indexing function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 |
| 62 |
|
| 63 |
6.2 Implementing parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 |
| 64 |
|
| 65 |
6.3 Compression function design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 |
| 66 |
|
| 67 |
6.3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 |
| 68 |
|
| 69 |
6.3.2 Design criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 |
| 70 |
|
| 71 |
6.4 User-controlled parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 |
| 72 |
|
| 73 |
7 Performance 16 |
| 74 |
|
| 75 |
7.1 x86 architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 |
| 76 |
|
| 77 |
8 Applications 16 |
| 78 |
|
| 79 |
1 |
| 80 |
9 Recommended parameters 17 |
| 81 |
|
| 82 |
10 Conclusion 17 |
| 83 |
|
| 84 |
A Permutation P 18 |
| 85 |
|
| 86 |
B Additional functionality 19 |
| 87 |
|
| 88 |
C Change log 20 |
| 89 |
|
| 90 |
C.1 v.1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 |
| 91 |
|
| 92 |
C.2 v1.2.1 – February 1st, 2016 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 |
| 93 |
|
| 94 |
C.3 v1.2 – 21th June, 2015 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 |
| 95 |
|
| 96 |
C.4 v1.1 – 6th February, 2015 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 |
| 97 |
|
| 98 |
1 Introduction |
| 99 |
|
| 100 |
Passwords, despite all their drawbacks, remain the primary form of authentication on various web-services. |
| 101 |
Passwords are usually stored in a hashed form in a server’s database. These databases are quite often captured |
| 102 |
by the adversaries, who then apply dictionary attacks since passwords tend to have low entropy. Protocol |
| 103 |
designers use a number of tricks to mitigate these issues. Starting from the late 70’s, a password is hashed |
| 104 |
together with a random salt value to prevent detection of identical passwords across different users and services. |
| 105 |
The hash function computations, which became faster and faster due to Moore’s law have been called multiple |
| 106 |
times to increase the cost of password trial for the attacker. |
| 107 |
|
| 108 |
In the meanwhile, the password crackers migrated to new architectures, such as FPGAs, multiple-core GPUs |
| 109 |
and dedicated ASIC modules, where the amortized cost of a multiple-iterated hash function is much lower. It |
| 110 |
was quickly noted that these new environments are great when the computation is almost memoryless, but they |
| 111 |
experience difficulties when operating on a large amount of memory. The defenders responded by designing |
| 112 |
memory-hard functions, which require a large amount of memory to be computed, and impose computational |
| 113 |
penalties if less memory is used. The password hashing scheme scrypt [15] is an instance of such function. |
| 114 |
|
| 115 |
Memory-hard schemes also have other applications. They can be used for key derivation from low-entropy |
| 116 |
sources. Memory-hard schemes are also welcome in cryptocurrency designs [13] if a creator wants to demotivate |
| 117 |
the use of GPUs and ASICs for mining and promote the use of standard desktops. |
| 118 |
|
| 119 |
Problems of existing schemes A trivial solution for password hashing is a keyed hash function such as |
| 120 |
HMAC. If the protocol designer prefers hashing without secret keys to avoid all the problems with key generation, |
| 121 |
storage, and update, then he has few alternatives: the generic mode PBKDF2, the Blowfish-based bcrypt, and |
| 122 |
scrypt. Among those, only scrypt aims for high memory, but the existence of a trivial time-memory tradeoff [8] |
| 123 |
allows compact implementations with the same energy cost. |
| 124 |
|
| 125 |
Design of a memory-hard function proved to be a tough problem. Since early 80’s it has been known |
| 126 |
that many cryptographic problems that seemingly require large memory actually allow for a time-memory |
| 127 |
tradeoff [11], where the adversary can trade memory for time and do his job on fast hardware with low memory. |
| 128 |
In application to password-hashing schemes, this means that the password crackers can still be implemented on |
| 129 |
a dedicated hardware even though at some additional cost. |
| 130 |
|
| 131 |
Another problem with the existing schemes is their complexity. The same scrypt calls a stack of subproce- |
| 132 |
dures, whose design rationale has not been fully motivated (e.g, scrypt calls SMix, which calls ROMix, which |
| 133 |
calls BlockMix, which calls Salsa20/8 etc.). It is hard to analyze and, moreover, hard to achieve confidence. |
| 134 |
Finally, it is not flexible in separating time and memory costs. At the same time, the story of cryptographic |
| 135 |
competitions [14, 17] has demonstrated that the most secure designs come with simplicity, where every element |
| 136 |
is well motivated and a cryptanalyst has as few entry points as possible. |
| 137 |
|
| 138 |
The Password Hashing Competition, which started in 2014, highlighted the following problems: |
| 139 |
|
| 140 |
• Should the memory addressing (indexing functions) be input-independent or input-dependent, or hybrid? |
| 141 |
The first type of schemes, where the memory read location are known in advance, is immediately vulnerable |
| 142 |
to time-space tradeoff attacks, since an adversary can precompute the missing block by the time it is |
| 143 |
needed [4]. In turn, the input-dependent schemes are vulnerable to side-channel attacks [16], as the |
| 144 |
timing information allows for much faster password search. |
| 145 |
|
| 146 |
• Is it better to fill more memory but suffer from time-space tradeoffs, or make more passes over the memory |
| 147 |
to be more robust? This question was quite difficult to answer due to absence of generic tradeoff tools, |
| 148 |
which would analyze the security against tradeoff attacks, and the absence of unified metric to measure |
| 149 |
adversary’s costs. |
| 150 |
|
| 151 |
2 |
| 152 |
• How should the input-independent addresses be computed? Several seemingly secure options have been |
| 153 |
attacked [4]. |
| 154 |
|
| 155 |
• How large a single memory block should be? Reading smaller random-placed blocks is slower (in cycles |
| 156 |
per byte) due to the spacial locality principle of the CPU cache. In turn, larger blocks are difficult to |
| 157 |
process due to the limited number of long registers. |
| 158 |
|
| 159 |
• If the block is large, how to choose the internal compression function? Should it be cryptographically |
| 160 |
secure or more lightweight, providing only basic mixing of the inputs? Many candidates simply proposed |
| 161 |
an iterative construction and argued against cryptographically strong transformations. |
| 162 |
|
| 163 |
• How to exploit multiple cores of modern CPUs, when they are available? Parallelizing calls to the hashing |
| 164 |
function without any interaction is subject to simple tradeoff attacks. |
| 165 |
|
| 166 |
Our solution We offer a hashing scheme called Argon2. Argon2 summarizes the state of the art in the design |
| 167 |
of memory-hard functions. It is a streamlined and simple design. It aims at the highest memory filling rate |
| 168 |
and effective use of multiple computing units, while still providing defense against tradeoff attacks. Argon2 |
| 169 |
is optimized for the x86 architecture and exploits the cache and memory organization of the recent Intel and |
| 170 |
AMD processors. Argon2 has two variants: Argon2d and Argon2i. Argon2d is faster and uses data-depending |
| 171 |
memory access, which makes it suitable for cryptocurrencies and applications with no threats from side-channel |
| 172 |
timing attacks. Argon2i uses data-independent memory access, which is preferred for password hashing and |
| 173 |
password-based key derivation. Argon2i is slower as it makes more passes over the memory to protect from |
| 174 |
tradeoff attacks. |
| 175 |
|
| 176 |
We recommend Argon2 for the applications that aim for high performance. Both versions of Argon2 allow |
| 177 |
to fill 1 GB of RAM in a fraction of second, and smaller amounts even faster. It scales easily to the arbitrary |
| 178 |
number of parallel computing units. Its design is also optimized for clarity to ease analysis and implementation. |
| 179 |
|
| 180 |
Our scheme provides more features and better tradeoff resilience than pre-PHC designs and equals in per- |
| 181 |
formance with the PHC finalists [5]. |
| 182 |
|
| 183 |
2 Definitions |
| 184 |
|
| 185 |
2.1 Motivation |
| 186 |
|
| 187 |
We aim to maximize the cost of password cracking on ASICs. There can be different approaches to measure |
| 188 |
this cost, but we turn to one of the most popular – the time-area product [3, 18]. We assume that the password |
| 189 |
P is hashed with salt S but without secret keys, and the hashes may leak to the adversaries together with salts: |
| 190 |
|
| 191 |
Tag ← H(P, S); |
| 192 |
Cracker ← {(Tagi, Si)}. |
| 193 |
|
| 194 |
In the case of the password hashing, we suppose that the defender allocates certain amount of time (e.g., 1 |
| 195 |
|
| 196 |
second) per password and a certain number of CPU cores (e.g., 4 cores). Then he hashes the password using the |
| 197 |
|
| 198 |
maximum amount M of memory. This memory size translates to certain ASIC area A. The running ASIC time |
| 199 |
|
| 200 |
T is determined by the length of the longest computational chain and by the ASIC memory latency. Therefore, |
| 201 |
|
| 202 |
we maximize the value AT . The other usecases follow a similar procedure. |
| 203 |
|
| 204 |
Suppose that an ASIC designer that wants to reduce the memory and thus the area wants to compute H |
| 205 |
|
| 206 |
using αM memory only for some α < 1. Using some tradeoff specific to H, he has to spend C(α) times as much |
| 207 |
|
| 208 |
computation and his running time increases by at least the factor D(α). Therefore, the maximum possible gain |
| 209 |
|
| 210 |
E in the time-area product is |
| 211 |
|
| 212 |
Emax = max 1 . |
| 213 |
αD(α) |
| 214 |
α |
| 215 |
|
| 216 |
The hash function is called memory-hard if D(α) > 1/α as α → 0. Clearly, in this case the time-area product |
| 217 |
does not decrease. Moreover, the following aspects may further increase it: |
| 218 |
|
| 219 |
• Computing cores needed to implement the C(α) penalty may occupy significant area. |
| 220 |
|
| 221 |
• If the tradeoff requires significant communication between the computing cores, the memory bandwidth |
| 222 |
limits may impose additional restrictions on the running time. |
| 223 |
|
| 224 |
In the following text, we will not attempt to estimate time and area with large precision. However, an |
| 225 |
interested reader may use the following implementations as reference: |
| 226 |
|
| 227 |
• The 50-nm DRAM implementation [9] takes 550 mm2 per GByte; |
| 228 |
|
| 229 |
3 |
| 230 |
• The Blake2b implementation in the 65-nm process should take about 0.1 mm2 (using Blake-512 imple- |
| 231 |
mentation in [10]); |
| 232 |
|
| 233 |
• The maximum memory bandwidth achieved by modern GPUs is around 400 GB/sec. |
| 234 |
|
| 235 |
2.2 Model for memory-hard functions |
| 236 |
|
| 237 |
The memory-hard functions that we explore use the following mode of operation. The memory array B[] is |
| 238 |
filled with the compression function G: |
| 239 |
|
| 240 |
B[0] = H(P, S); |
| 241 |
|
| 242 |
for j from 1 to t (1) |
| 243 |
|
| 244 |
B[j] = G B[φ1(j)], B[φ2(j)], · · · , B[φk(j)] , |
| 245 |
|
| 246 |
where φi() are some indexing functions. |
| 247 |
We distinguish two types of indexing functions: |
| 248 |
|
| 249 |
• Independent of the password and salt, but possibly dependent on other public parameters (thus called |
| 250 |
data-independent). The addresses can be calculated by the memory-saving adversaries. We suppose that |
| 251 |
the dedicated hardware can handle parallel memory access, so that the cracker can prefetch the data |
| 252 |
from the memory. Moreover, if she implements a time-space tradeoff, then the missing blocks can be also |
| 253 |
precomputed without losing time. Let the single G core occupy the area equivalent to the β of the entire |
| 254 |
memory. Then if we use αM memory, then the gain in the time-area product is |
| 255 |
|
| 256 |
E (α) = α + 1 . |
| 257 |
C (α)β |
| 258 |
|
| 259 |
• Dependent on the password (data-dependent), in our case: φ(j) = g(B[j − 1]). This choice prevents the |
| 260 |
adversary from prefetching and precomputing missing data. The adversary figures out what he has to |
| 261 |
recompute only at the time the element is needed. If an element is recomputed as a tree of F calls of |
| 262 |
average depth D, then the total processing time is multiplied by D. The gain in the time-area product is |
| 263 |
|
| 264 |
E (α) = (α + 1 . |
| 265 |
C (α)β )D(α) |
| 266 |
|
| 267 |
The maximum bandwidth Bwmax is a hypothetical upper bound on the memory bandwidth on the adver- |
| 268 |
sary’s architecture. Suppose that for each call to G an adversary has to load R(α) blocks from the memory on |
| 269 |
average. Therefore, the adversary can keep the execution time the same as long as |
| 270 |
|
| 271 |
R(α)Bw ≤ Bwmax, |
| 272 |
|
| 273 |
where Bw is the bandwidth achieved by a full-space implementation. In the tradeoff attacks that we apply the |
| 274 |
following holds: |
| 275 |
|
| 276 |
R(α) = C(α). |
| 277 |
|
| 278 |
3 Specification of Argon2 |
| 279 |
|
| 280 |
There are two flavors of Argon2 – Argon2d and Argon2i. The former one uses data-dependent memory access to |
| 281 |
thwart tradeoff attacks. However, this makes it vulnerable for side-channel attacks, so Argon2d is recommended |
| 282 |
primarily for cryptocurrencies and backend servers. Argon2i uses data-independent memory access, which is |
| 283 |
recommended for password hashing and password-based key derivation. |
| 284 |
|
| 285 |
3.1 Inputs |
| 286 |
|
| 287 |
Argon2 has two types of inputs: primary inputs and secondary inputs, or parameters. Primary inputs are |
| 288 |
message P and nonce S, which are password and salt, respectively, for the password hashing. Primary inputs |
| 289 |
must always be given by the user such that |
| 290 |
|
| 291 |
• Message P may have any length from 0 to 232 − 1 bytes; |
| 292 |
• Nonce S may have any length from 8 to 232 − 1 bytes (16 bytes is recommended for password hashing). |
| 293 |
|
| 294 |
Secondary inputs have the following restrictions: |
| 295 |
|
| 296 |
4 |
| 297 |
• Degree of parallelism p determines how many independent (but synchronizing) computational chains can |
| 298 |
be run. It may take any integer value from 1 to 224 − 1. |
| 299 |
|
| 300 |
• Tag length τ may be any integer number of bytes from 4 to 232 − 1. |
| 301 |
|
| 302 |
• Memory size m can be any integer number of kilobytes from 8p to 232 − 1. The actual number of blocks |
| 303 |
is m , which is m rounded down to the nearest multiple of 4p. |
| 304 |
|
| 305 |
• Number of iterations t (used to tune the running time independently of the memory size) can be any |
| 306 |
integer number from 1 to 232 − 1; |
| 307 |
|
| 308 |
• Version number v is one byte 0x13; |
| 309 |
|
| 310 |
• Secret value K (serves as key if necessary, but we do not assume any key use by default) may have any |
| 311 |
length from 0 to 232 − 1 bytes. |
| 312 |
|
| 313 |
• Associated data X may have any length from 0 to 232 − 1 bytes. |
| 314 |
|
| 315 |
• Type y of Argon2: 0 for Argon2d, 1 for Argon2i, 2 for Argon2id. |
| 316 |
|
| 317 |
Argon2 uses internal compression function G with two 1024-byte inputs and a 1024-byte output, and internal |
| 318 |
hash function H. Here H is the Blake2b hash function, and G is based on its internal permutation. The mode |
| 319 |
of operation of Argon2 is quite simple when no parallelism is used: function G is iterated m times. At step i a |
| 320 |
block with index φ(i) < i is taken from the memory (Figure 1), where φ(i) is either determined by the previous |
| 321 |
block in Argon2d, or is a fixed value in Argon2i. |
| 322 |
|
| 323 |
G G G |
| 324 |
|
| 325 |
φ(i) φ(i + 1) i−1 i i+1 |
| 326 |
|
| 327 |
Figure 1: Argon2 mode of operation with no parallelism. |
| 328 |
|
| 329 |
3.2 Operation |
| 330 |
|
| 331 |
Argon2 follows the extract-then-expand concept. First, it extracts entropy from message and nonce by hashing |
| 332 |
it. All the other parameters are also added to the input. The variable length inputs P, S, K, X are prepended |
| 333 |
with their lengths: |
| 334 |
|
| 335 |
H0 = H(p, τ, m, t, v, y, P , P, S , S, K , K, X , X). |
| 336 |
|
| 337 |
Here H0 is 64-byte value, and the parameters p, τ, m, t, v, y, P , S , K , X are treated as little-endian 32-bit |
| 338 |
|
| 339 |
integers. |
| 340 |
|
| 341 |
Argon2 then fills the memory with m = m · 4p 1024-byte blocks. For tunable parallelism with p threads, |
| 342 |
4p |
| 343 |
|
| 344 |
the memory is organized in a matrix B[i][j] of blocks with p rows (lanes) and q = m /p columns. We denote |
| 345 |
|
| 346 |
the block produced in pass t by Bt[i][j], t > 0. Blocks are computed as follows: |
| 347 |
|
| 348 |
B1[i][0] = H (H0|| 0 || i ), 0 ≤ i < p; |
| 349 |
|
| 350 |
4 bytes 4 bytes |
| 351 |
|
| 352 |
B1[i][1] = H (H0|| 1 || i ), 0 ≤ i < p; |
| 353 |
|
| 354 |
4 bytes 4 bytes |
| 355 |
|
| 356 |
B1[i][j] = G(B1[i][j − 1], B1[i ][j ]), 0 ≤ i < p, 2 ≤ j < q. |
| 357 |
|
| 358 |
where block index [i ][j ] is determined differently for Argon2d/2ds and Argon2i, G is the compression function, |
| 359 |
and H is a variable-length hash function built upon H. Both G and H will be fully defined in the further text. |
| 360 |
|
| 361 |
5 |
| 362 |
If t > 1, we repeat the procedure, but we XOR the new blocks to the old ones instead of overwriting them. |
| 363 |
|
| 364 |
Bt[i][0] = G(Bt−1[i][q − 1], B[i ][j ]) ⊕ Bt−1[i][0]; |
| 365 |
Bt[i][j] = G(Bt[i][j − 1], B[i ][j ]) ⊕ Bt−1[i][j]. |
| 366 |
|
| 367 |
Here the block B[i ][j ] may be either Bt[i ][j ] for j < j or Bt−1[i ][j ] for j > j . |
| 368 |
After we have done T iterations over the memory, we compute the final block Bfinal as the XOR of the last |
| 369 |
|
| 370 |
column: |
| 371 |
Bfinal = BT [0][q − 1] ⊕ BT [1][q − 1] ⊕ · · · ⊕ BT [p − 1][q − 1]. |
| 372 |
|
| 373 |
Then we apply H to Bfinal to get the output tag. |
| 374 |
|
| 375 |
Tag ← H (Bfinal). |
| 376 |
|
| 377 |
Variable-length hash function. Let Hx be a hash function with x-byte output (in our case Hx is Blake2b, |
| 378 |
|
| 379 |
which supports 1 ≤ x ≤ 64). We define H as follows. Let Vi be a 64-byte block, and Ai be its first 32 bytes, |
| 380 |
and τ < 232 be the 32-bit tag length (viewed little-endian) in bytes. Then we define |
| 381 |
|
| 382 |
if τ ≤ 64 H (X) d=ef Hτ (τ ||X). |
| 383 |
else |
| 384 |
r = τ /32 − 2; |
| 385 |
V1 ← H64(τ ||X); |
| 386 |
V2 ← H64(V1); |
| 387 |
··· |
| 388 |
Vr ← H64(Vr−1), |
| 389 |
Vr+1 ← Hτ−32r(Vr). |
| 390 |
H (X) d=ef A1||A2|| . . . Ar||Vr+1. |
| 391 |
|
| 392 |
4 slices |
| 393 |
|
| 394 |
B[0][0] p lanes |
| 395 |
H |
| 396 |
message |
| 397 |
nonce |
| 398 |
|
| 399 |
parameters |
| 400 |
|
| 401 |
B[p − 1][0] |
| 402 |
|
| 403 |
H H H |
| 404 |
|
| 405 |
Tag |
| 406 |
|
| 407 |
Figure 2: Single-pass Argon2 with p lanes and 4 slices. |
| 408 |
|
| 409 |
3.3 Indexing |
| 410 |
|
| 411 |
To enable parallel block computation, we further partition the memory matrix into S = 4 vertical slices. The |
| 412 |
intersection of a slice and a lane is a segment of length q/S. Segments of the same slice are computed in |
| 413 |
parallel, and may not reference blocks from each other. All other blocks can be referenced, and now we explain |
| 414 |
the procedure in detail. |
| 415 |
|
| 416 |
Getting two 32-bit values. In Argon2d we select the first 32 bits of block B[i][j − 1] and denote this value |
| 417 |
by J1. Then we take the next 32 bits of B[i][j − 1] and denote this value by J2. In Argon2i we run G2 — the |
| 418 |
2-round compression function G — in the counter mode, where the first input is all-zero block, and the second |
| 419 |
input is constructed as |
| 420 |
|
| 421 |
( r || l || s || m || t || x || i || 0 ), |
| 422 |
|
| 423 |
8 bytes 8 bytes 8 bytes 8 bytes 8 bytes 8 bytes 8 bytes 968 bytes |
| 424 |
|
| 425 |
where |
| 426 |
|
| 427 |
6 |
| 428 |
• r is the pass number; |
| 429 |
• l is the lane number; |
| 430 |
• s is the slice number; |
| 431 |
• m is the total number of memory blocks; |
| 432 |
• t is the total number of passes; |
| 433 |
• x is the type of the Argon function (equals 1 for Argon2i); |
| 434 |
• i is the counter starting in each segment from 1. |
| 435 |
All the numbers are put as little-endian. We increase the counter so that each application of G2 gives 128 64-bit |
| 436 |
values J1||J2. |
| 437 |
|
| 438 |
Mapping J1, J2 to the reference block index The value l = J2 mod p determines the index of the lane |
| 439 |
from which the block will be taken. If we work with the first slice and the first pass (r = s = 0), then l is set |
| 440 |
to the current lane index. |
| 441 |
|
| 442 |
Then we determine the set of indices R that can be referenced for given [i][j] according to the following |
| 443 |
rules: |
| 444 |
|
| 445 |
1. If l is the current lane, then R includes all blocks computed in this lane, that are not overwritten yet, |
| 446 |
excluding B[i][j − 1]. |
| 447 |
|
| 448 |
2. If l is not the current lane, then R includes all blocks in the last S − 1 = 3 segments computed and finished |
| 449 |
in lane l. If B[i][j] is the first block of a segment, then the very last block from R is excluded. |
| 450 |
|
| 451 |
We are going to take a block from R with a non-uniform distribution over [0..|R|): |
| 452 |
|
| 453 |
J1 ∈ [0..232) → |R| 1 − (J1)2 . |
| 454 |
264 |
| 455 |
|
| 456 |
To avoid floating-point computation, we use the following integer approximation: |
| 457 |
|
| 458 |
x = (J1)2/232; |
| 459 |
y = (|R| ∗ x)/232; |
| 460 |
z = |R| − 1 − y. |
| 461 |
|
| 462 |
Then we enumerate the blocks in R in the order of construction and select z-th block from it as the reference |
| 463 |
block. |
| 464 |
|
| 465 |
3.4 Compression function G |
| 466 |
|
| 467 |
Compression function G is built upon the Blake2b round function P (fully defined in Section A). P operates |
| 468 |
on the 128-byte input, which can be viewed as 8 16-byte registers (see details below): |
| 469 |
|
| 470 |
P(A0, A1, . . . , A7) = (B0, B1, . . . , B7). |
| 471 |
|
| 472 |
Compression function G(X, Y ) operates on two 1024-byte blocks X and Y . It first computes R = X ⊕ Y . |
| 473 |
Then R is viewed as a 8 × 8-matrix of 16-byte registers R0, R1, . . . , R63. Then P is first applied rowwise, and |
| 474 |
then columnwise to get Z: |
| 475 |
|
| 476 |
(Q0, Q1, . . . , Q7) ← P(R0, R1, . . . , R7); |
| 477 |
(Q8, Q9, . . . , Q15) ← P(R8, R9, . . . , R15); |
| 478 |
|
| 479 |
... |
| 480 |
(Q56, Q57, . . . , Q63) ← P(R56, R57, . . . , R63); |
| 481 |
|
| 482 |
(Z0, Z8, Z16, . . . , Z56) ← P(Q0, Q8, Q16, . . . , Q56); |
| 483 |
(Z1, Z9, Z17, . . . , Z57) ← P(Q1, Q9, Q17, . . . , Q57); |
| 484 |
|
| 485 |
... |
| 486 |
(Z7, Z15, Z23, . . . , Z63) ← P(Q7, Q15, Q23, . . . , Q63). |
| 487 |
|
| 488 |
Finally, G outputs Z ⊕ R: |
| 489 |
|
| 490 |
G : (X, Y ) → R = X ⊕ Y −P→ Q −P→ Z → Z ⊕ R. |
| 491 |
|
| 492 |
7 |
| 493 |
X Y |
| 494 |
|
| 495 |
R |
| 496 |
|
| 497 |
P Blake2b |
| 498 |
round |
| 499 |
|
| 500 |
P |
| 501 |
|
| 502 |
P |
| 503 |
|
| 504 |
Q |
| 505 |
|
| 506 |
PP P |
| 507 |
|
| 508 |
Z |
| 509 |
|
| 510 |
Figure 3: Argon2 compression function G. |
| 511 |
|
| 512 |
4 Features |
| 513 |
|
| 514 |
Argon2 is a multi-purpose family of hashing schemes, which is suitable for password hashing, key derivation, |
| 515 |
cryptocurrencies and other applications that require provably high memory use. Argon2 is optimized for the x86 |
| 516 |
architecture, but it does not slow much on older processors. The key feature of Argon2 is its performance and |
| 517 |
the ability to use multiple computational cores in a way that prohibits time-memory tradeoffs. Several features |
| 518 |
are not included into this version, but can be easily added later. |
| 519 |
|
| 520 |
4.1 Available features |
| 521 |
|
| 522 |
Now we provide an extensive list of features of Argon2. |
| 523 |
Performance. Argon2 fills memory very fast, thus increasing the area multiplier in the time-area product |
| 524 |
|
| 525 |
for ASIC-equipped adversaries. Data-independent version Argon2i securely fills the memory spending about 2 |
| 526 |
CPU cycles per byte, and Argon2d is three times as fast. This makes it suitable for applications that need |
| 527 |
memory-hardness but can not allow much CPU time, like cryptocurrency peer software. |
| 528 |
|
| 529 |
Tradeoff resilience. Despite high performance, Argon2 provides reasonable level of tradeoff resilience. Our |
| 530 |
tradeoff attacks previously applied to Catena and Lyra2 show the following. With default number of passes over |
| 531 |
memory (1 for Argon2d, 3 for Argon2i, an ASIC-equipped adversary can not decrease the time-area product if |
| 532 |
the memory is reduced by the factor of 4 or more. Much higher penalties apply if more passes over the memory |
| 533 |
are made. |
| 534 |
|
| 535 |
Scalability. Argon2 is scalable both in time and memory dimensions. Both parameters can be changed |
| 536 |
independently provided that a certain amount of time is always needed to fill the memory. |
| 537 |
|
| 538 |
Parallelism. Argon2 may use up to 224 threads in parallel, although in our experiments 8 threads already |
| 539 |
exhaust the available bandwidth and computing power of the machine. |
| 540 |
|
| 541 |
GPU/FPGA/ASIC-unfriendly. Argon2 is heavily optimized for the x86 architecture, so that imple- |
| 542 |
menting it on dedicated cracking hardware should be neither cheaper nor faster. Even specialized ASICs would |
| 543 |
require significant area and would not allow reduction in the time-area product. |
| 544 |
|
| 545 |
Additional input support. Argon2 supports additional input, which is syntactically separated from the |
| 546 |
message and nonce, such as secret key, environment parameters, user data, etc.. |
| 547 |
|
| 548 |
8 |
| 549 |
4.2 Possible future extensions |
| 550 |
|
| 551 |
Argon2 can be rather easily tuned to support other compression functions, hash functions and block sizes. ROM |
| 552 |
can be easily integrated into Argon2 by simply including it into the area where the blocks are referenced from. |
| 553 |
|
| 554 |
5 Security analysis |
| 555 |
|
| 556 |
All the attacks detailed below apply to one-lane version of Argon2, but can be carried to the multi-lane version |
| 557 |
with the same efficiency. |
| 558 |
|
| 559 |
5.1 Ranking tradeoff attack |
| 560 |
|
| 561 |
To figure out the costs of the ASIC-equipped adversary, we first need to calculate the time-space tradeoffs for |
| 562 |
Argon2. To the best of our knowledge, the first generic tradeoffs attacks were reported in [4], and they apply to |
| 563 |
both data-dependent and data-independent schemes. The idea of the ranking method [4] is as follows. When |
| 564 |
we generate a memory block B[l], we make a decision, to store it or not. If we do not store it, we calculate the |
| 565 |
access complexity of this block — the number of calls to F needed to compute the block, which is based on the |
| 566 |
access complexity of B[l − 1] and B[φ(l)]. The detailed strategy is as follows: |
| 567 |
|
| 568 |
1. Select an integer q (for the sake of simplicity let q divide T ). |
| 569 |
|
| 570 |
2. Store B[kq] for all k; |
| 571 |
|
| 572 |
3. Store all ri and all access complexities; |
| 573 |
|
| 574 |
4. Store the T /q highest access complexities. If B[i] refers to a vertex from this top, we store B[i]. |
| 575 |
|
| 576 |
The memory reduction is a probabilistic function of q. We applied the algorithm to the indexing function of |
| 577 |
Argon2 and obtained the results in Table 1. Each recomputation is a tree of certain depth, also given in the |
| 578 |
table. |
| 579 |
|
| 580 |
We conclude that for data-dependent one-pass schemes the adversary is always able to reduce the memory |
| 581 |
by the factor of 3 and still keep the time-area product the same. |
| 582 |
|
| 583 |
α 1 1 1 1 1 1 |
| 584 |
C (α) |
| 585 |
D(α) 2 3 4 5 6 7 |
| 586 |
|
| 587 |
1.5 4 20.2 344 4660 218 |
| 588 |
|
| 589 |
1.5 2.8 5.5 10.3 17 27 |
| 590 |
|
| 591 |
Table 1: Time and computation penalties for the ranking tradeoff attack for the Argon2 indexing function. |
| 592 |
|
| 593 |
5.2 Memory optimization attack |
| 594 |
|
| 595 |
As reported in [6], it is possible to optimize the memory use in the earlier version 1.2.1 of Argon2, concretely for |
| 596 |
|
| 597 |
Argon2i. The memory blocks produced in the version 1.2.1 at second and later passes replaced, not overwrote |
| 598 |
the blocks at earlier passes. Therefore, for each block B[i] there is a time gap (let us call it a no-use gap) |
| 599 |
between the moment the block is used for the last time (as a reference or as a fresh new block) and the moment |
| 600 |
it is overwritten. We formalize this issue as follows. Let us denote by φr(i) the reference block index for block |
| 601 |
B r [i]. |
| 602 |
|
| 603 |
• For t-pass Argon2i the block Br[i], r < t is not used between step lir = max i, maxφ(jr)=i j and step i of |
| 604 |
pass r + 1, where it is overwritten. |
| 605 |
|
| 606 |
• For t-pass Argon2i the block Bt[i] is not used between step lit = max i, maxφ(jr)=i j and step m of pass |
| 607 |
t, where it is discarded. |
| 608 |
|
| 609 |
Since addresses li can be precomputed, an attacker can figure out for each block Br[i] when it can be |
| 610 |
discarded. A separate data structure will be needed though to keep the address of newly produced blocks as |
| 611 |
they land up at pseudo-random locations at the memory. |
| 612 |
|
| 613 |
This saving strategy uses the fraction |
| 614 |
|
| 615 |
Lt = 1 − lit |
| 616 |
m |
| 617 |
i |
| 618 |
|
| 619 |
9 |
| 620 |
of memory for the last pass, and |
| 621 |
|
| 622 |
Lr = m + i − lir |
| 623 |
m |
| 624 |
i |
| 625 |
|
| 626 |
for the previous passes. Our experiments show that in 1-pass Argon2i L1 ≈ 0.15, i.e. on average 1/7-th of |
| 627 |
memory is used. Since in the straightforward application on average 1/2 of memory is used, the advantage in |
| 628 |
the time-area product is about 3.5. For t > 1 this strategy uses 0.25 of memory on average, so the time-area |
| 629 |
product advantage is close to 4. If we use the peak memory amount in the time-area calculations, then the |
| 630 |
advantage would be 5 and 2.7, respectively. |
| 631 |
|
| 632 |
The version 1.3 of Argon2 replaces overwriting operation with the XOR. This gives minimal overhead on the |
| 633 |
performance: for memory requirements of 8 MB and higher the performance difference is between 5% and 15% |
| 634 |
depending on the operating system and hardware. For instance, the highest speed of 3-pass Argon2d v.1.2.1 on |
| 635 |
1.8 GHz CPU with Ubuntu is 1.61 cycles per byte, whereas for v.1.3 it is 1.7 cpb (both measured for 2 GB of |
| 636 |
RAM, 4 threads). |
| 637 |
|
| 638 |
In the version 1.3 this saving strategy applies to the one-pass Argon2i only, where it brings the same time- |
| 639 |
area product advantage. The multi-pass versions are safe as all the blocks have to be kept in memory till the |
| 640 |
overwrite. |
| 641 |
|
| 642 |
5.3 Attack on iterative compression function |
| 643 |
|
| 644 |
Let us consider the following structure of the compression function F (X, Y ), where X and Y are input blocks: |
| 645 |
|
| 646 |
• The input blocks of size t are divided into shorter subblocks of length t (for instance, 128 bits) X0, X1, |
| 647 |
X2, . . . and Y0, Y1, Y2, . . .. |
| 648 |
|
| 649 |
• The output block Z is computed subblockwise: |
| 650 |
|
| 651 |
Z0 = G(X0, Y0); |
| 652 |
Zi = G(Xi, Yi, Zi−1), i > 0. |
| 653 |
|
| 654 |
This scheme resembles the duplex authenticated encryption mode, which is secure under certain assumptions |
| 655 |
|
| 656 |
on G. However, it is totally insecure against tradeoff adversaries, as shown below. |
| 657 |
Suppose that an adversary computes Z = F (X, Y ) but Y is not stored. Suppose that Y is a tree function |
| 658 |
|
| 659 |
of stored elements of depth D. The adversary starts with computing Z0, which requires only Y0. In turn, |
| 660 |
Y0 = G(X0, Y0 ) for some X , Y . Therefore, the adversary computes the tree of the same depth D, but with |
| 661 |
the function G instead of F . Z1 is then a tree function of depth D + 1, Z2 of depth D + 2, etc. In total, |
| 662 |
the recomputation takes (D + s)LG time, where s is the number of subblocks and LG is the latency of G. |
| 663 |
This should be compared to the full-space implementation, which takes time sLG. Therefore, if the memory is |
| 664 |
reduced by the factor q, then the time-area product is changed as |
| 665 |
|
| 666 |
ATnew = D(q) + s AT. |
| 667 |
sq |
| 668 |
|
| 669 |
Therefore, if |
| 670 |
|
| 671 |
D(q) ≤ s(q − 1), (2) |
| 672 |
|
| 673 |
the adversary wins. |
| 674 |
One may think of using the Zm−1[l−1] as input to computing Z0[l]. Clearly, this changes little in adversary’s |
| 675 |
|
| 676 |
strategy, who could simply store all Zm−1, which is feasible for large m. In concrete proposals, s can be 64, |
| 677 |
128, 256 and even larger. |
| 678 |
|
| 679 |
We conclude that F with an iterative structure is insecure. We note that this attack applies also to other |
| 680 |
PHC candidates with iterative compression function. |
| 681 |
|
| 682 |
5.4 Security of Argon2 to generic attacks |
| 683 |
|
| 684 |
Now we consider preimage and collision resistance of both versions of Argon2. Variable-length inputs are |
| 685 |
prepended with their lengths, which shall ensure the absence of equal input strings. Inputs are processed by a |
| 686 |
cryptographic hash function, so no collisions should occur at this stage. |
| 687 |
|
| 688 |
10 |
| 689 |
Internal collision resistance. The compression function G is not claimed to be collision resistant, so it may |
| 690 |
happen that distinct inputs produce identical outputs. Recall that G works as follows: |
| 691 |
|
| 692 |
G(X, Y ) = P (Z) ⊕ (Z), Z = X ⊕ Y. |
| 693 |
|
| 694 |
where P is a permutation based on the 2-round Blake2b permutation. Let us prove that all Z are different |
| 695 |
under certain assumptions. |
| 696 |
|
| 697 |
Theorem 1. Let Π be Argon2d or Argon2i with d lanes, s slices, and t passes over memory. Assume that |
| 698 |
|
| 699 |
• P (Z) ⊕ Z is collision-resistant, i.e. it is hard to find a, b such that P (a) ⊕ a = P (b) ⊕ b. |
| 700 |
|
| 701 |
• P (Z) ⊕ Z is 4-generalized-birthday-resistant, i.e. it is hard to find distinct a, b, c, d such that P (a) ⊕ P (b) ⊕ |
| 702 |
P (c) ⊕ P (d) = a ⊕ b ⊕ c ⊕ d. |
| 703 |
|
| 704 |
Then all the blocks B[i] generated in those t passes are different. |
| 705 |
|
| 706 |
Proof. By specification, the value of Z is different for the first two blocks of each segment in the first slice in |
| 707 |
the first pass. Consider the other blocks. |
| 708 |
|
| 709 |
Let us enumerate the blocks according to the moment they are computed. Within a slice, where segments |
| 710 |
can be computed in parallel, we enumerate lane 0 fully first, then lane 1, etc.. Slices are then computed and |
| 711 |
enumerated sequentially. Suppose the proposition is wrong, and let (B[x], B[y]) be a block collision such that |
| 712 |
x < y and y is the smallest among all such collisions. As F (Z) ⊕ Z is collision resistant, the collision occurs in |
| 713 |
Z, i.e. |
| 714 |
|
| 715 |
Zx = Zy. |
| 716 |
Let rx, ry be reference block indices for B[x] and B[y], respectively, and let px, py be previous block indices for |
| 717 |
B[x], B[y]. Then we get |
| 718 |
|
| 719 |
B[rx] ⊕ B[px] = B[ry] ⊕ B[py]. |
| 720 |
|
| 721 |
As we assume 4-generalized-birthday-resistance, some arguments are equal. Consider three cases: |
| 722 |
|
| 723 |
• rx = px. This is forbidden by the rule 3 in Section 3.3. |
| 724 |
|
| 725 |
• rx = ry. We get B[px] = B[py]. As px, py < y, and y is the smallest yielding such a collision, we get |
| 726 |
px = py. However, by construction px = py for x = y. |
| 727 |
|
| 728 |
• rx = py. Then we get B[ry] = B[px]. As ry < y and px < x < y, we obtain ry = px. Since py = rx < x < y, |
| 729 |
we get that x and y are in the same slice, we have two options: |
| 730 |
|
| 731 |
– py is the last block of a segment. Then y is the first block of a segment in the next slice. Since rx |
| 732 |
is the last block of a segment, and x < y, x must be in the same slice as y, and x can not be the |
| 733 |
first block in a segment by the rule 4 in Section 3.3. Therefore, ry = px = x − 1. However, this is |
| 734 |
impossible, as ry can not belong to the same slice as y. |
| 735 |
|
| 736 |
– py is not the last block of a segment. Then rx = py = y − 1, which implies that rx ≥ x. The latter |
| 737 |
is forbidden. |
| 738 |
|
| 739 |
Thus we get a contradiction in all cases. This ends the proof. |
| 740 |
|
| 741 |
The compression function G is not claimed to be collision resistant nor preimage-resistant. However, as the |
| 742 |
attacker has no control over its input, the collisions are highly unlikely. We only take care that the starting |
| 743 |
blocks are not identical by producing the first two blocks with a counter and forbidding to reference from the |
| 744 |
memory the last block as (pseudo)random. |
| 745 |
|
| 746 |
Argon2d does not overwrite the memory, hence it is vulnerable to garbage-collector attacks and similar ones, |
| 747 |
and is not recommended to use in the setting where these threats are possible. Argon2i with 3 passes overwrites |
| 748 |
the memory twice, thus thwarting the memory-leak attacks. Even if the entire working memory of Argon2i is |
| 749 |
leaked after the hash is computed, the adversary would have to compute two passes over the memory to try the |
| 750 |
password. |
| 751 |
|
| 752 |
5.5 Security of Argon2 to ranking tradeoff attacks |
| 753 |
|
| 754 |
Time and computational penalties for 1-pass Argon2d are given in Table 1. It suggests that the adversary can |
| 755 |
reduce memory by the factor of 3 at most while keeping the time-area product the same. |
| 756 |
|
| 757 |
Argon2i is more vulnerable to tradeoff attacks due to its data-independent addressing scheme. We applied |
| 758 |
the ranking algorithm to 3-pass Argon2i to calculate time and computational penalties. We found out that the |
| 759 |
memory reduction by the factor of 3 already gives the computational penalty of around 214. The 214 Blake2b |
| 760 |
cores would take more area than 1 GB of RAM (Section 2.1), thus prohibiting the adversary to further reduce |
| 761 |
the time-area product. We conclude that the time-area product cost for Argon2i can be reduced by 3 at best. |
| 762 |
|
| 763 |
11 |
| 764 |
5.6 Security of Argon2i to generic tradeoff attacks on random graphs |
| 765 |
|
| 766 |
The recent paper by Alwen and Blocki [1] reports an improved attack on Argon2i (all versions) as an instance |
| 767 |
of hash functions based on random graphs. |
| 768 |
|
| 769 |
For t-pass Argon2i, Alwen and Blocki explicitly construct a set of O(T 3/4) nodes so that removing these |
| 770 |
nodes from the computation graph yields the so called sandwich graph with O(T 1/4) layers and O(T 1/2) depth |
| 771 |
and size. The computation proceeds as follows: |
| 772 |
|
| 773 |
• Mark certain v = O(T 3/4) blocks as to be stored. |
| 774 |
|
| 775 |
• For every segment of length T 3/4: |
| 776 |
|
| 777 |
– Compute the reference blocks of the segment blocks in parallel. |
| 778 |
|
| 779 |
– Compute the segment blocks consecutively, store blocks that needs storing. |
| 780 |
|
| 781 |
Using O(T 1/2) cores, the segment computation takes time O(T 3/4) and the total time is O(T ). The cores are |
| 782 |
used only for O(T 1/2) time, so it is possible to amortize costs computing O(T 1/4) instances using these cores |
| 783 |
in the round-robin fashion. The memory complexity of each step is about to T log T . |
| 784 |
|
| 785 |
A precise formula for the time-area complexity using this tradeoff strategy is given in Corollary1 5.6 of [1]: |
| 786 |
|
| 787 |
ATnew = 2T 7/4 5 + t + ln T , |
| 788 |
8 |
| 789 |
|
| 790 |
Since the memory consumption in the standard implementation is M = T /t, the standard AT value is T 2/t and |
| 791 |
the time-area advantage of the Alwen-Blocki attack is |
| 792 |
|
| 793 |
E = AT = T 1/4 ln T ) ≤ 2t3/4(5 + M 1/4 + 0.125 ln M ) . |
| 794 |
ATnew 2t(5 + (ln t)/2 + 8 0.625 ln t |
| 795 |
|
| 796 |
For t ≥ 3 we get that E ≤ M 1/4/36. Therefore, for M up to 220 (1 GB) the advantage is smaller than 1 (i.e. the |
| 797 |
attack is not beneficial to the adversary at all), and for M up to 224 (16 GB) it is smaller than 2. Therefore, |
| 798 |
this approach is not better than the ranking attack. However, it is a subject of active research and we’ll update |
| 799 |
|
| 800 |
this documents if improvements appear. |
| 801 |
|
| 802 |
5.7 Summary of tradeoff attacks |
| 803 |
|
| 804 |
The best attack on the 1- and 2-pass Argon2i (v.1.3) is the low-storage attack from [6], which reduces the |
| 805 |
time-area product (using the peak memory value) by the factor of 5. |
| 806 |
|
| 807 |
The best attack for t-pass (t > 2) Argon2i is the ranking tradeoff attack, which reduces the time-area product |
| 808 |
by the factor of 3. |
| 809 |
|
| 810 |
The best attack on the t-pass Argon2d is the ranking tradeoff attack, which reduces the time-area product |
| 811 |
by the factor 1.33. |
| 812 |
|
| 813 |
6 Design rationale |
| 814 |
|
| 815 |
Argon2 was designed with the following primary goal: to maximize the cost of exhaustive search on non-x86 |
| 816 |
architectures, so that the switch even to dedicated ASICs would not give significant advantage over doing the |
| 817 |
exhaustive search on defender’s machine. |
| 818 |
|
| 819 |
6.1 Indexing function |
| 820 |
|
| 821 |
The basic scheme (1) was extended to implement: |
| 822 |
|
| 823 |
• Tunable parallelism; |
| 824 |
|
| 825 |
• Several passes over memory. |
| 826 |
|
| 827 |
For the data-dependent addressing we set φ(l) = g(B[l]), where g simply truncates the block and takes the |
| 828 |
result modulo l − 1. We considered taking the address not from the block B[l − 1] but from the block B[l − 2], |
| 829 |
which should have allowed to prefetch the block earlier. However, not only the gain in our implementations is |
| 830 |
limited, but also this benefit can be exploited by the adversary. Indeed, the efficient depth D(q) is now reduced |
| 831 |
to D(q) − 1, since the adversary has one extra timeslot. Table 1 implies that then the adversary would be able |
| 832 |
|
| 833 |
1the authors denote the total number of blocks by n and the number of passes by k. |
| 834 |
|
| 835 |
12 |
| 836 |
to reduce the memory by the factor of 5 without increasing the time-area product (which is a 25% increase in |
| 837 |
the reduction factor compared to the standard approach). |
| 838 |
|
| 839 |
For the data-independent addressing we use a simple PRNG, in particular the compression function G in the |
| 840 |
counter mode. Due to its long output, one call (or two consecutive calls) would produce hundreds of addresses, |
| 841 |
thus minimizing the overhead. This approach does not give provable tradeoff bounds, but instead allows the |
| 842 |
analysis with the tradeoff algorithms suited for data-dependent addressing. |
| 843 |
|
| 844 |
Motivation for our indexing functions Initially, we considered uniform selection of referenced blocks, but |
| 845 |
then we considered a more generic case: |
| 846 |
|
| 847 |
φ ← (264 − (J1)γ ) · |Rl|/264 |
| 848 |
|
| 849 |
We tried to choose the γ which would maximize the adversary’s costs if he applies the tradeoff based on |
| 850 |
the ranking method. We also attempted to make the reference block distribution close to uniform, so that each |
| 851 |
memory block is referenced similar number of times. |
| 852 |
|
| 853 |
For each 1 ≤ γ ≤ 5 with step 0.1 we applied the ranking method with sliding window and selected the |
| 854 |
best available tradeoffs. We obtained a set of time penalties {Dγ(α)} and computational penalties {Cγ(α)} for |
| 855 |
0.01 < α < 1. We also calculated the reference block distribution for all possible γ. We considered two possible |
| 856 |
metrics: |
| 857 |
|
| 858 |
1. Minimum time-area product |
| 859 |
|
| 860 |
ATγ = min{α · Dγ (α)}. |
| 861 |
|
| 862 |
α |
| 863 |
|
| 864 |
2. Maximum memory reduction which reduces the time-area product compared to the original: |
| 865 |
|
| 866 |
αγ = min{α | Dγ(α) < α}. |
| 867 |
|
| 868 |
α |
| 869 |
|
| 870 |
3. The goodness-of-fit value of the reference block distribution w.r.t. the uniform distribution with n bins: |
| 871 |
|
| 872 |
χ2 = (pi − 1 )2 , |
| 873 |
n |
| 874 |
1 |
| 875 |
|
| 876 |
i n |
| 877 |
|
| 878 |
where pi is the average probability of the block from i-th bin to be referenced. For example, if p3 = |
| 879 |
0.2, n = 10 and there are 1000 blocks, then blocks from 201 to 300 are referenced 1000 · 0.2 = 200 times |
| 880 |
|
| 881 |
throughout the computation. |
| 882 |
|
| 883 |
We got the following results for n = 10: |
| 884 |
|
| 885 |
γ ATγ αγ χ2 |
| 886 |
1 0.78 3.95 0.89 |
| 887 |
2 0.72 3.2 0.35 |
| 888 |
3 0.67 3.48 0.2 |
| 889 |
4 0.63 3.9 0.13 |
| 890 |
5 0.59 4.38 0.09 |
| 891 |
|
| 892 |
We conclude that the time-area product achievable by the attacker slowly decreases as γ grows. However, the |
| 893 |
difference between γ = 1 and γ = 5 is only the factor of 1.3. We also see that the time-area product can be |
| 894 |
kept below the original up to q = 3.2 for γ = 2, whereas for γ = 4 and γ = 1 such q is close to 4. To avoid |
| 895 |
floating-point computations, we restrict to integer γ. Thus the optimal values are γ = 2 and γ = 3, where the |
| 896 |
|
| 897 |
former is slightly better in the first two metrics. |
| 898 |
|
| 899 |
However, if we consider the reference block uniformity, the situation favors larger γ considerably. We see |
| 900 |
that the χ2 value is decreased by the factor of 2.5 when going from γ = 1 to γ = 2, and by the factor of 1.8 |
| 901 |
further to γ = 3. In concrete probabilities (see also Figure 4), the first 20% of blocks accumulate 40% of all |
| 902 |
reference hits for γ = 2 and 32% for γ = 3 (23.8% vs 19.3% hit for the first 10% of blocks). |
| 903 |
|
| 904 |
To summarize, γ = 2 and γ = 3 both are better against one specific attacker and slightly worse against the |
| 905 |
other. We take γ = 2 as the value that minimizes the AT gain, as we consider this metric more important. |
| 906 |
|
| 907 |
6.2 Implementing parallelism |
| 908 |
|
| 909 |
As modern CPUs have several cores possibly available for hashing, it is tempting to use these cores to increase |
| 910 |
the bandwidth, the amount of filled memory, and the CPU load. The cores of the recent Intel CPU share |
| 911 |
the L3 cache and the entire memory, which both have large latencies (100 cycles and more). Therefore, the |
| 912 |
inter-processor communication should be minimal to avoid delays. |
| 913 |
|
| 914 |
13 |
| 915 |
Memory fraction (1/q) 1 1 1 1 1 |
| 916 |
γ=1 |
| 917 |
γ=2 2 3 4 5 6 |
| 918 |
γ=3 |
| 919 |
1.6 2.9 7.3 16.4 59 |
| 920 |
|
| 921 |
1.5 4 20.2 344 4700 |
| 922 |
|
| 923 |
1.4 4.3 28.1 1040 217 |
| 924 |
|
| 925 |
Table 2: Computational penalties for the ranking tradeoff attack with a sliding window, 1 pass. |
| 926 |
|
| 927 |
Memory fraction (1/q) 1 1 1 1 1 |
| 928 |
γ=1 |
| 929 |
γ=2 2 3 4 5 6 |
| 930 |
γ=3 |
| 931 |
1.6 2.5 4 5.8 8.7 |
| 932 |
|
| 933 |
1.5 2.6 5.4 10.7 17 |
| 934 |
|
| 935 |
1.3 2.5 5.3 10.1 18 |
| 936 |
|
| 937 |
Table 3: Depth penalties for the ranking tradeoff attack with a sliding window, 1 pass. |
| 938 |
|
| 939 |
The simplest way to use p parallel cores is to compute and XOR p independent calls to H: |
| 940 |
|
| 941 |
H (P, S) = H(P, S, 0) ⊕ H(P, S, 1) ⊕ · · · ⊕ H(P, S, p − 1). |
| 942 |
|
| 943 |
If a single call uses m memory units, then p calls use pm units. However, this method admits a trivial tradeoff: |
| 944 |
an adversary just makes p sequential calls to H using only m memory in total, which keeps the time-area |
| 945 |
product constant. |
| 946 |
|
| 947 |
We suggest the following solution for p cores: the entire memory is split into p lanes of l equal slices each, |
| 948 |
which can be viewed as elements of a (p × l)-matrix Q[i][j]. Consider the class of schemes given by Equation (1). |
| 949 |
We modify it as follows: |
| 950 |
|
| 951 |
• p invocations to H run in parallel on the first column Q[∗][0] of the memory matrix. Their indexing |
| 952 |
functions refer to their own slices only; |
| 953 |
|
| 954 |
• For each column j > 0, l invocations to H continue to run in parallel, but the indexing functions now may |
| 955 |
refer not only to their own slice, but also to all jp slices of previous columns Q[∗][0], Q[∗][1], . . . , Q[∗][j −1]. |
| 956 |
|
| 957 |
• The last blocks produced in each slice of the last column are XORed. |
| 958 |
|
| 959 |
This idea is easily implemented in software with p threads and l joining points. It is easy to see that the adversary |
| 960 |
|
| 961 |
can use less memory when computing the last column, for instance by computing the slices sequentially and |
| 962 |
|
| 963 |
storing only the slice which is currently computed. Then his time is multiplied by (1 + p−1 ), whereas the |
| 964 |
l |
| 965 |
p−1 |
| 966 |
memory use is multiplied by (1 − pl ), so the time-area product is modified as |
| 967 |
|
| 968 |
ATnew = AT 1 − p − 1 p−1 . |
| 969 |
pl 1+ l |
| 970 |
|
| 971 |
For 2 ≤ p, l ≤ 10 this value is always between 1.05 and 3. We have selected l = 4 as this value gives low |
| 972 |
synchronisation overhead while imposing time-area penalties on the adversary who reduces the memory even |
| 973 |
by the factor 3/4. We note that values l = 8 or l = 16 could be chosen. |
| 974 |
|
| 975 |
If the compression function is collision-resistant, then one may easily prove that block collisions are highly |
| 976 |
unlikely. However, we employ a weaker compression function, for which the following holds: |
| 977 |
|
| 978 |
G(X, Y ) = F (X ⊕ Y ), |
| 979 |
|
| 980 |
Figure 4: Access frequency for different memory segments (10%-buckets) and different exponents (from γ = 1 |
| 981 |
to γ = 5) in the indexing functions. |
| 982 |
|
| 983 |
14 |
| 984 |
which is invariant to swap of inputs and is not collision-free. We take special care to ensure that the mode of |
| 985 |
operation does not allow such collisions by introducing additional rule: |
| 986 |
|
| 987 |
• First block of a segment can not refer to the last block of any segment in the previous slice. |
| 988 |
We prove that block collisions are unlikely under reasonable conditions on F in Section 5.4. |
| 989 |
|
| 990 |
6.3 Compression function design |
| 991 |
|
| 992 |
6.3.1 Overview |
| 993 |
|
| 994 |
In contrast to attacks on regular hash functions, the adversary does not control inputs to the compression |
| 995 |
function G in our scheme. Intuitively, this should relax the cryptographic properties required from the compres- |
| 996 |
sion function and allow for a faster primitive. To avoid being the bottleneck, the compression function ideally |
| 997 |
should be on par with the performance of memcpy() or similar function, which may run at 0.1 cycle per byte |
| 998 |
or even faster. This much faster than ordinary stream ciphers or hash functions, but we might not need strong |
| 999 |
properties of those primitives. |
| 1000 |
|
| 1001 |
However, we first have to determine the optimal block size. When we request a block from a random location |
| 1002 |
in the memory, we most likely get a cache miss. The first bytes would arrive at the CPU from RAM within |
| 1003 |
at best 10 ns, which accounts for 30 cycles. In practice, the latency of a single load instruction may reach 100 |
| 1004 |
cycles and more. However, this number can be amortized if we request a large block of sequentially stored bytes. |
| 1005 |
When the first bytes are requested, the CPU stores the next ones in the L1 cache, automatically or using the |
| 1006 |
prefetch instruction. The data from the L1 cache can be loaded as fast as 64 bytes per cycle on the Haswell |
| 1007 |
architecture, though we did not manage to reach this speed in our application. |
| 1008 |
|
| 1009 |
Therefore, the larger the block is, the higher the throughput is. We have made a series of experiments with |
| 1010 |
a non-cryptographic compression function, which does little beyond simple XOR of its inputs, and achieved the |
| 1011 |
performance of around 0.7 cycles per byte per core with block sizes of 1024 bits and larger. |
| 1012 |
|
| 1013 |
6.3.2 Design criteria |
| 1014 |
|
| 1015 |
It was demonstrated that a compression function with a large block size may be vulnerable to tradeoff attacks |
| 1016 |
if it has a simple iterative structure, like modes of operation for a blockcipher [4] (some details in Section 5.3). |
| 1017 |
|
| 1018 |
Thus we formulate the following design criteria: |
| 1019 |
|
| 1020 |
• The compression function must require about t bits of storage (excluding inputs) to compute any output |
| 1021 |
bit. |
| 1022 |
|
| 1023 |
• Each output byte of F must be a nonlinear function of all input bytes, so that the function has differential |
| 1024 |
|
| 1025 |
probability below certain level, for example 1 . |
| 1026 |
4 |
| 1027 |
|
| 1028 |
These criteria ensure that the attacker is unable to compute an output bit using only a few input bits or a few |
| 1029 |
|
| 1030 |
stored bits. Moreover, the output bits should not be (almost) linear functions of input bits, as otherwise the |
| 1031 |
|
| 1032 |
function tree would collapse. |
| 1033 |
|
| 1034 |
We have not found any generic design strategy for such large-block compression functions. It is difficult to |
| 1035 |
|
| 1036 |
maintain diffusion on large memory blocks due to the lack of CPU instructions that interleave many registers |
| 1037 |
|
| 1038 |
at once. A naive approach would be to apply a linear transformation with certain branch number. However, |
| 1039 |
even if we operate on 16-byte registers, a 1024-byte block would consist of 64 elements. A 64 × 64-matrix would |
| 1040 |
|
| 1041 |
require 32 XORs per register to implement, which gives a penalty about 2 cycles per byte. |
| 1042 |
|
| 1043 |
Instead, we propose to build the compression function on the top of a transformation P that already mixes |
| 1044 |
|
| 1045 |
several registers. We apply P in parallel (having a P-box), then shuffle the output registers and apply it again. |
| 1046 |
If P handles p registers, then the compression function may transform a block of p2 registers with 2 rounds of |
| 1047 |
|
| 1048 |
P-boxes. We do not have to manually shuffle the data, we just change the inputs to P-boxes. As an example, |
| 1049 |
|
| 1050 |
an implementation of the Blake2b [2] permutation processes 8 128-bit registers, so with 2 rounds of Blake2b we |
| 1051 |
|
| 1052 |
can design a compression function that mixes the 8192-bit block. We stress that this approach is not possible |
| 1053 |
|
| 1054 |
with dedicated AES instructions. Even though they are very fast, they apply only to the 128-bit block, and we |
| 1055 |
|
| 1056 |
still have to diffuse its content across other blocks. |
| 1057 |
|
| 1058 |
We replace the original Blake2b round function with its modification BlaMka [12], where the modular |
| 1059 |
|
| 1060 |
additions in G are combined with 32-bit multiplications. Our motivation was to increase the circuit depth (and |
| 1061 |
|
| 1062 |
thus the running time) of a potential ASIC implementation while having roughly the same running time on CPU |
| 1063 |
|
| 1064 |
thanks to parallelism and pipelining. Extra multiplications in the scheme serve well, as the best addition-based |
| 1065 |
|
| 1066 |
circuits for multiplication have latency about 4-5 times the addition latency for 32-bit multiplication (or roughly |
| 1067 |
|
| 1068 |
logn for n-bit multiplication). |
| 1069 |
As a result, any output 64-bit word of P is implemented by a chain of additions, multiplications, XORs, and |
| 1070 |
|
| 1071 |
rotations. The shortest possible chain for the 1 KB-block (e.g, from v0 to v0) consists of 12 MULs, 12 XORs, |
| 1072 |
and 12 rotations. |
| 1073 |
|
| 1074 |
15 |
| 1075 |
Argon2d (1 pass) Argon2i (3 passes) |
| 1076 |
|
| 1077 |
Processor Threads Cycles/Byte Bandwidth Cycles/Byte Bandwidth |
| 1078 |
|
| 1079 |
(GB/s) (GB/s) |
| 1080 |
|
| 1081 |
i7-4500U 1 1.3 2.5 4.7 2.6 |
| 1082 |
|
| 1083 |
i7-4500U 2 0.9 3.8 2.8 4.5 |
| 1084 |
|
| 1085 |
i7-4500U 4 0.6 5.4 2 5.4 |
| 1086 |
|
| 1087 |
i7-4500U 8 0.6 5.4 1.9 5.8 |
| 1088 |
|
| 1089 |
Table 4: Speed and memory bandwidth of Argon2(d/i) measured on 1 GB memory filled. Core i7-4500U — |
| 1090 |
Intel Haswell 1.8 GHz, 4 cores |
| 1091 |
|
| 1092 |
6.4 User-controlled parameters |
| 1093 |
|
| 1094 |
We have made a number of design choices, which we consider optimal for a wide range of applications. Some |
| 1095 |
parameters can be altered, some should be kept as is. We give a user full control over: |
| 1096 |
|
| 1097 |
• Amount M of memory filled by algorithm. This value, evidently, depends on the application and the |
| 1098 |
environment. There is no ”insecure” value for this parameter, though clearly the more memory the |
| 1099 |
better. |
| 1100 |
|
| 1101 |
• Number T of passes over the memory. The running time depends linearly on this parameter. We expect |
| 1102 |
that the user chooses this number according to the time constraints on the application. Again, there is |
| 1103 |
no ”insecure value” for T . |
| 1104 |
|
| 1105 |
• Degree d of parallelism. This number determines the number of threads used by an optimized implemen- |
| 1106 |
tation of Argon2. We expect that the user is restricted by a number of CPU cores (or half-cores) that can |
| 1107 |
be devoted to the hash function, and chooses d accordingly (double the number of cores). |
| 1108 |
|
| 1109 |
• Length of password/message, salt/nonce, and tag (except for some low, insecure values for salt and tag |
| 1110 |
lengths). |
| 1111 |
|
| 1112 |
We allow to choose another compression function G, hash function H, block size b, and number of slices l. |
| 1113 |
However, we do not provide this flexibility in a reference implementation as we guess that the vast majority of |
| 1114 |
the users would prefer as few parameters as possible. |
| 1115 |
|
| 1116 |
7 Performance |
| 1117 |
|
| 1118 |
7.1 x86 architecture |
| 1119 |
|
| 1120 |
To optimize the data load and store from/to memory, the memory that will be processed has to be alligned on |
| 1121 |
16-byte boundary when loaded/stored into/from 128-bit registers and on 32-byte boundary when loaded/stored |
| 1122 |
into/from 256-bit registers. If the memory is not aligned on the specified boundaries, then each memory |
| 1123 |
operation may take one extra CPU cycle, which may cause consistent penalties for many memory accesses. |
| 1124 |
|
| 1125 |
The results presented are obtained using the gcc 4.8.2 compiler with the following options: -m64 -mavx |
| 1126 |
-std=c++11 -pthread -O3. The cycle count value was measured using the rdtscp Intel intrinsics C function |
| 1127 |
which inlines the RDTSCP assembly instruction that returns the 64-bit Time Stamp Counter (TSC) value. The |
| 1128 |
instruction waits for prevoius instruction to finish and then is executed, but meanwhile the next instructions may |
| 1129 |
begin before the value is read. Although this shortcoming, we used this method because it is the most realiable |
| 1130 |
handy method to measure the execution time and also it is widely used in other cryptographic operations |
| 1131 |
benchmarking. |
| 1132 |
|
| 1133 |
8 Applications |
| 1134 |
|
| 1135 |
Argon2d is optimized for settings where the adversary does not get regular access to system memory or CPU, |
| 1136 |
i.e. he can not run side-channel attacks based on the timing information, nor he can recover the password much |
| 1137 |
faster using garbage collection [7]. These settings are more typical for backend servers and cryptocurrency |
| 1138 |
minings. For practice we suggest the following settings: |
| 1139 |
|
| 1140 |
• Cryptocurrency mining, that takes 0.1 seconds on a 2 Ghz CPU using 1 core — Argon2d with 2 lanes and |
| 1141 |
250 MB of RAM; |
| 1142 |
|
| 1143 |
16 |
| 1144 |
• Backend server authentication, that takes 0.5 seconds on a 2 GHz CPU using 4 cores — Argon2d with 8 |
| 1145 |
lanes and 4 GB of RAM. |
| 1146 |
|
| 1147 |
Argon2i is optimized for more dangerous settings, where the adversary possibly can access the same machine, |
| 1148 |
use its CPU or mount cold-boot attacks. We use three passes to get rid entirely of the password in the memory. |
| 1149 |
We suggest the following settings: |
| 1150 |
|
| 1151 |
• Key derivation for hard-drive encryption, that takes 3 seconds on a 2 GHz CPU using 2 cores — Argon2i |
| 1152 |
with 4 lanes and 6 GB of RAM; |
| 1153 |
|
| 1154 |
• Frontend server authentication, that takes 0.5 seconds on a 2 GHz CPU using 2 cores — Argon2i with 4 |
| 1155 |
lanes and 1 GB of RAM. |
| 1156 |
|
| 1157 |
9 Recommended parameters |
| 1158 |
|
| 1159 |
We recommend the following procedure to select the type and the parameters for practical use of Argon2: |
| 1160 |
1. Select the type y. If you do not know the difference between them or you consider side-channel attacks |
| 1161 |
as viable threat, choose Argon2i. Otherwise any choice is fine, including optional types. |
| 1162 |
2. Figure out the maximum number h of threads that can be initiated by each call to Argon2. |
| 1163 |
3. Figure out the maximum amount m of memory that each call can afford. |
| 1164 |
4. Figure out the maximum amount x of time (in seconds) that each call can afford. |
| 1165 |
|
| 1166 |
5. Select the salt length. 128 bits is sufficient for all applications, but can be reduced to 64 bits in the case |
| 1167 |
of space constraints. |
| 1168 |
|
| 1169 |
6. Select the tag length. 128 bits is sufficient for most applications, including key derivation. If longer keys |
| 1170 |
are needed, select longer tags. |
| 1171 |
|
| 1172 |
7. If side-channel attacks is a viable threat, enable the memory wiping option in the library call. |
| 1173 |
8. Run the scheme of type y, memory m and h lanes and threads, using different number of passes t. Figure |
| 1174 |
|
| 1175 |
out the maximum t such that the running time does not exceed x. If it exceeds x even for t = 1, reduce |
| 1176 |
m accordingly. |
| 1177 |
9. Hash all the passwords with the just determined values m, h, and t. |
| 1178 |
|
| 1179 |
10 Conclusion |
| 1180 |
|
| 1181 |
We presented the memory-hard function Argon2, which maximizes the ASIC implementation costs for given |
| 1182 |
CPU computing time. We aimed to make the design clear and compact, so that any feature and operation has |
| 1183 |
certain rationale. The clarity and brevity of the Argon2 design has been confirmed by its eventual selection as |
| 1184 |
the PHC winner. |
| 1185 |
|
| 1186 |
Further development of tradeoff attacks with dedication to Argon2 is the subject of future work. It also |
| 1187 |
remains to be seen how Argon2 withstands GPU cracking with low memory requirements. |
| 1188 |
|
| 1189 |
References |
| 1190 |
|
| 1191 |
[1] J. Alwen and J. Blocki, “Efficiently computing data-independent memory-hard functions,” IACR Cryptol- |
| 1192 |
ogy ePrint Archive, vol. 2016, p. 115, 2016. |
| 1193 |
|
| 1194 |
[2] J. Aumasson, S. Neves, Z. Wilcox-O’Hearn, and C. Winnerlein, “BLAKE2: simpler, smaller, fast as MD5,” |
| 1195 |
in ACNS’13, ser. Lecture Notes in Computer Science, vol. 7954. Springer, 2013, pp. 119–135. |
| 1196 |
|
| 1197 |
[3] D. J. Bernstein and T. Lange, “Non-uniform cracks in the concrete: The power of free precomputation,” |
| 1198 |
in ASIACRYPT’13, ser. Lecture Notes in Computer Science, vol. 8270. Springer, 2013, pp. 321–340. |
| 1199 |
|
| 1200 |
[4] A. Biryukov and D. Khovratovich, “Tradeoff cryptanalysis of memory-hard functions,” in Advances in |
| 1201 |
Cryptology - ASIACRYPT 2015, ser. Lecture Notes in Computer Science, T. Iwata and J. H. Cheon, Eds., |
| 1202 |
vol. 9453. Springer, 2015, pp. 633–657. |
| 1203 |
|
| 1204 |
17 |
| 1205 |
[5] M. Broz, “Phc benchmarks,” 2015, https://github.com/mbroz/PHCtest/blob/master/output/phc round2. |
| 1206 |
pdf . |
| 1207 |
|
| 1208 |
[6] H. Corrigan-Gibbs, D. Boneh, and S. E. Schechter, “Balloon hashing: Provably space-hard hash functions |
| 1209 |
with data-independent access patterns,” IACR Cryptology ePrint Archive, vol. 2016, p. 27, 2016. |
| 1210 |
|
| 1211 |
[7] C. Forler, E. List, S. Lucks, and J. Wenzel, “Overview of the candidates for the password hashing competi- |
| 1212 |
tion - and their resistance against garbage-collector attacks,” Cryptology ePrint Archive, Report 2014/881, |
| 1213 |
2014, http://eprint.iacr.org/. |
| 1214 |
|
| 1215 |
[8] C. Forler, S. Lucks, and J. Wenzel, “Memory-demanding password scrambling,” in ASIACRYPT’14, ser. |
| 1216 |
Lecture Notes in Computer Science, vol. 8874. Springer, 2014, pp. 289–305, tweaked version of [?]. |
| 1217 |
|
| 1218 |
[9] B. Giridhar, M. Cieslak, D. Duggal, R. G. Dreslinski, H. M. Chen, R. Patti, B. Hold, C. Chakrabarti, T. N. |
| 1219 |
Mudge, and D. Blaauw, “Exploring DRAM organizations for energy-efficient and resilient exascale mem- |
| 1220 |
ories,” in International Conference for High Performance Computing, Networking, Storage and Analysis |
| 1221 |
(SC 2013). ACM, 2013, pp. 23–35. |
| 1222 |
|
| 1223 |
[10] F. Gu¨rkaynak, K. Gaj, B. Muheim, E. Homsirikamol, C. Keller, M. Rogawski, H. Kaeslin, and J.-P. Kaps, |
| 1224 |
“Lessons learned from designing a 65nm ASIC for evaluating third round SHA-3 candidates,” in Third |
| 1225 |
SHA-3 Candidate Conference, Mar. 2012. |
| 1226 |
|
| 1227 |
[11] M. E. Hellman, “A cryptanalytic time-memory trade-off,” Information Theory, IEEE Transactions on, |
| 1228 |
vol. 26, no. 4, pp. 401–406, 1980. |
| 1229 |
|
| 1230 |
[12] M. A. S. Jr., L. C. Almeida, E. R. Andrade, P. C. F. dos Santos, and P. S. L. M. Barreto, “Lyra2: |
| 1231 |
Password hashing scheme with improved security against time-memory trade-offs,” Cryptology ePrint |
| 1232 |
Archive, Report 2015/136, 2015, http://eprint.iacr.org/. |
| 1233 |
|
| 1234 |
[13] C. Lee, “Litecoin - open source p2p digital currency,” https://bitcointalk.org/index.php?topic=47417.0, |
| 1235 |
2011, https://litecoin.org/. |
| 1236 |
|
| 1237 |
[14] NIST, SHA-3 competition, 2007, http://csrc.nist.gov/groups/ST/hash/sha-3/index.html. |
| 1238 |
|
| 1239 |
[15] C. Percival, “Stronger key derivation via sequential memory-hard functions,” 2009, http://www.tarsnap. |
| 1240 |
com/scrypt/scrypt.pdf . |
| 1241 |
|
| 1242 |
[16] T. Ristenpart, E. Tromer, H. Shacham, and S. Savage, “Hey, you, get off of my cloud: exploring information |
| 1243 |
leakage in third-party compute clouds,” in ACM CCS’09, 2009, pp. 199–212. |
| 1244 |
|
| 1245 |
[17] M. Robshaw and O. Billet, New stream cipher designs: the eSTREAM finalists. Springer, 2008, vol. 4986. |
| 1246 |
|
| 1247 |
[18] C. D. Thompson, “Area-time complexity for VLSI,” in STOC’79. ACM, 1979, pp. 81–88. |
| 1248 |
|
| 1249 |
A Permutation P |
| 1250 |
|
| 1251 |
Permutation P is based on the round function of Blake2b and works as follows. Its 8 16-byte inputs S0, S1, . . . , S7 |
| 1252 |
are viewed as a 4 × 4-matrix of 64-bit words, where Si = (v2i+1||v2i): |
| 1253 |
|
| 1254 |
v0 v1 v2 v3 |
| 1255 |
|
| 1256 |
v4 v5 v6 v7 |
| 1257 |
|
| 1258 |
v8 v9 v10 v11 |
| 1259 |
|
| 1260 |
|
| 1261 |
v12 v13 v14 v15 |
| 1262 |
|
| 1263 |
Then we do |
| 1264 |
|
| 1265 |
G(v0, v4, v8, v12) G(v1, v5, v9, v13) |
| 1266 |
G(v2, v6, v10, v14) G(v3, v7, v11, v15) |
| 1267 |
G(v0, v5, v10, v15) G(v1, v6, v11, v12) |
| 1268 |
|
| 1269 |
G(v2, v7, v8, v13) G(v3, v4, v9, v14), |
| 1270 |
|
| 1271 |
18 |
| 1272 |
where G applies to (a, b, c, d) as follows: |
| 1273 |
|
| 1274 |
a ← a + b + 2 ∗ aL ∗ bL; |
| 1275 |
d ← (d ⊕ a) ≫ 32; |
| 1276 |
c ← c + d + 2 ∗ cL ∗ dL; |
| 1277 |
b ← (b ⊕ c) ≫ 24; |
| 1278 |
|
| 1279 |
(3) |
| 1280 |
a ← a + b + 2 ∗ aL ∗ bL; |
| 1281 |
d ← (d ⊕ a) ≫ 16; |
| 1282 |
c ← c + d + 2 ∗ cL ∗ dL; |
| 1283 |
b ← (b ⊕ c) ≫ 63; |
| 1284 |
|
| 1285 |
Here + are additions modulo 264 and ≫ are 64-bit rotations to the right. xL is the 64-bit integer x truncated |
| 1286 |
to the 32 least significant bits. The modular additions in G are combined with 64-bit multiplications (that is |
| 1287 |
the only difference to the original Blake2 design). |
| 1288 |
|
| 1289 |
Our motivation in adding multiplications is to increase the circuit depth (and thus the running time) of |
| 1290 |
a potential ASIC implementation while having roughly the same running time on CPU thanks to parallelism |
| 1291 |
and pipelining. Extra multiplications in the scheme serve well, as the best addition-based circuits for multi- |
| 1292 |
plication have latency about 4-5 times the addition latency for 32-bit multiplication (or roughly logn for n-bit |
| 1293 |
multiplication). |
| 1294 |
|
| 1295 |
As a result, any output 64-bit word of P is implemented by a chain of additions, multiplications, XORs, and |
| 1296 |
rotations. The shortest possible chain for the 1 KB-block (e.g, from v0 to v0) consists of 12 MULs, 12 XORs, |
| 1297 |
and 12 rotations. |
| 1298 |
|
| 1299 |
B Additional functionality |
| 1300 |
|
| 1301 |
The following functionality is enabled in the extended implementation2 but is not officially included in the PHC |
| 1302 |
release3: |
| 1303 |
|
| 1304 |
• Hybrid construction Argon2id, which has type y = 2 (used in the pre-hashing and address generation). |
| 1305 |
In the first two slices of the first pass it generates reference addresses data-independently as in Argon2i, |
| 1306 |
whereas in later slices and next passes it generates them data-dependently as in Argon2d. |
| 1307 |
|
| 1308 |
• Sbox-hardened version Argon2ds, which has type y = 4. In this version the compression function G |
| 1309 |
includes the 64-bit transformation T , which is a chain of S-boxes, multiplications, and additions. In terms |
| 1310 |
of Section 3.4, we additionally compute |
| 1311 |
|
| 1312 |
W = LSB64(R0 ⊕ R63); |
| 1313 |
Z0+ = T (W ); |
| 1314 |
Z63+ = T (W ) 32. |
| 1315 |
|
| 1316 |
The transformation T , on the 64-bit word W is defined as follows: |
| 1317 |
|
| 1318 |
– Repeat 96 times: |
| 1319 |
1. y ← S[W [8 : 0]]; |
| 1320 |
2. z ← S[512 + W [40 : 32]]; |
| 1321 |
3. W ← ((W [31 : 0] ◦ W [63 : 32]) + y) ⊕ z. |
| 1322 |
|
| 1323 |
– T (W ) ← W . |
| 1324 |
|
| 1325 |
All the operations are performed modulo 264. ◦ is the 64-bit multiplication, S[] is the Sbox (lookup table) |
| 1326 |
that maps 10-bit indices to 64-bit values. W [i : j] is the subset of bits of W from i to j inclusive. |
| 1327 |
The S-box is generated in the start of every pass in the following procedure. In total we specify 210 · 8 |
| 1328 |
bytes, or 8 KBytes. We take block B[0][0] and apply F (the core of G) to it 16 times. After each two |
| 1329 |
iterations we use the entire 1024-byte value and initialize 128 lookup values. |
| 1330 |
The properties of T and its initialization procedure is subject to change. |
| 1331 |
|
| 1332 |
2https://github.com/khovratovich/Argon2 |
| 1333 |
3https://github.com/P-H-C/phc-winner-argon2 |
| 1334 |
|
| 1335 |
19 |
| 1336 |
C Change log |
| 1337 |
|
| 1338 |
C.1 v.1.3 |
| 1339 |
|
| 1340 |
• The blocks are XORed with, not overwritten in the second pass and later; |
| 1341 |
• The version number byte is now 0x13. |
| 1342 |
|
| 1343 |
C.2 v1.2.1 – February 1st, 2016 |
| 1344 |
|
| 1345 |
• The total number of blocks can reach 232 − 1; |
| 1346 |
• The reference block index now requires 64 bits; the lane number is computed separately. |
| 1347 |
• New modes Argon2id and Argon2ds are added as optional. |
| 1348 |
The specification of v1.2.1 released on 26th August, 2015, had incorrect description of the first block generation. |
| 1349 |
The version released on 2d September, 2015, had incorrect description of the counter used in generating addresses |
| 1350 |
for Argon2i. The version released on September 8th, 2015, lacked the ”Recommended parameters” section. The |
| 1351 |
version released on October 1st, 2015, had the maximal parallelism level of 255 lanes. The version released on |
| 1352 |
November 3d, 2015, had a typo. The versions released on November 5th and December 26th, had incorrect |
| 1353 |
description of the first block generation and the variable-length hash function. |
| 1354 |
|
| 1355 |
C.3 v1.2 – 21th June, 2015 |
| 1356 |
|
| 1357 |
Non-uniform indexing rule, the compression function gets multiplications. |
| 1358 |
|
| 1359 |
C.4 v1.1 – 6th February, 2015 |
| 1360 |
|
| 1361 |
• New indexing rule added to avoid collision with a proof. |
| 1362 |
• New rule to generate first two blocks in each lane. |
| 1363 |
• Non-zero constant added to the input block used to generate addresses in Argon2i. |
| 1364 |
|
| 1365 |
20 |
| 1366 |
|