Initial commit
[hashcat.git] / nv / m11400_a3.cu
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW2
16 #define VECT_SIZE1
17 #endif
18
19 #define DGST_R0 0
20 #define DGST_R1 3
21 #define DGST_R2 2
22 #define DGST_R3 1
23
24 #include "include/kernel_functions.c"
25 #include "types_nv.c"
26 #include "common_nv.c"
27
28 #ifdef  VECT_SIZE1
29 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
30 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
31 #endif
32
33 #ifdef  VECT_SIZE2
34 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
35 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
36 #endif
37
38 #ifdef  VECT_SIZE4
39 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
40 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
41 #endif
42
43 #ifdef VECT_SIZE1
44 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
45 #endif
46
47 #ifdef VECT_SIZE2
48 #define uint_to_hex_lower8(i) u32x (l_bin2asc[(i).x], l_bin2asc[(i).y])
49 #endif
50
51 #ifdef VECT_SIZE4
52 #define uint_to_hex_lower8(i) u32x (l_bin2asc[(i).x], l_bin2asc[(i).y], l_bin2asc[(i).z], l_bin2asc[(i).w])
53 #endif
54
55 __device__ static u32 memcat32 (u32x block0[16], u32x block1[16], const u32 block_len, const u32x append0[4], const u32x append1[4], const u32x append2[4], const u32x append3[4], const u32 append_len)
56 {
57   const u32 mod = block_len & 3;
58   const u32 div = block_len / 4;
59
60   const int offset_minus_4 = 4 - mod;
61
62   const int selector = (0x76543210 >> (offset_minus_4 * 4)) & 0xffff;
63
64   u32x append0_t[4];
65
66   append0_t[0] = __byte_perm (         0, append0[0], selector);
67   append0_t[1] = __byte_perm (append0[0], append0[1], selector);
68   append0_t[2] = __byte_perm (append0[1], append0[2], selector);
69   append0_t[3] = __byte_perm (append0[2], append0[3], selector);
70
71   u32x append1_t[4];
72
73   append1_t[0] = __byte_perm (append0[3], append1[0], selector);
74   append1_t[1] = __byte_perm (append1[0], append1[1], selector);
75   append1_t[2] = __byte_perm (append1[1], append1[2], selector);
76   append1_t[3] = __byte_perm (append1[2], append1[3], selector);
77
78   u32x append2_t[4];
79
80   append2_t[0] = __byte_perm (append1[3], append2[0], selector);
81   append2_t[1] = __byte_perm (append2[0], append2[1], selector);
82   append2_t[2] = __byte_perm (append2[1], append2[2], selector);
83   append2_t[3] = __byte_perm (append2[2], append2[3], selector);
84
85   u32x append3_t[4];
86
87   append3_t[0] = __byte_perm (append2[3], append3[0], selector);
88   append3_t[1] = __byte_perm (append3[0], append3[1], selector);
89   append3_t[2] = __byte_perm (append3[1], append3[2], selector);
90   append3_t[3] = __byte_perm (append3[2], append3[3], selector);
91
92   u32x append4_t[4];
93
94   append4_t[0] = __byte_perm (append3[3],          0, selector);
95   append4_t[1] = 0;
96   append4_t[2] = 0;
97   append4_t[3] = 0;
98
99   switch (div)
100   {
101     case  0:  block0[ 0] |= append0_t[0];
102               block0[ 1]  = append0_t[1];
103               block0[ 2]  = append0_t[2];
104               block0[ 3]  = append0_t[3];
105
106               block0[ 4]  = append1_t[0];
107               block0[ 5]  = append1_t[1];
108               block0[ 6]  = append1_t[2];
109               block0[ 7]  = append1_t[3];
110
111               block0[ 8]  = append2_t[0];
112               block0[ 9]  = append2_t[1];
113               block0[10]  = append2_t[2];
114               block0[11]  = append2_t[3];
115
116               block0[12]  = append3_t[0];
117               block0[13]  = append3_t[1];
118               block0[14]  = append3_t[2];
119               block0[15]  = append3_t[3];
120
121               block1[ 0]  = append4_t[0];
122               block1[ 1]  = append4_t[1];
123               block1[ 2]  = append4_t[2];
124               block1[ 3]  = append4_t[3];
125               break;
126
127     case  1:  block0[ 1] |= append0_t[0];
128               block0[ 2]  = append0_t[1];
129               block0[ 3]  = append0_t[2];
130               block0[ 4]  = append0_t[3];
131
132               block0[ 5]  = append1_t[0];
133               block0[ 6]  = append1_t[1];
134               block0[ 7]  = append1_t[2];
135               block0[ 8]  = append1_t[3];
136
137               block0[ 9]  = append2_t[0];
138               block0[10]  = append2_t[1];
139               block0[11]  = append2_t[2];
140               block0[12]  = append2_t[3];
141
142               block0[13]  = append3_t[0];
143               block0[14]  = append3_t[1];
144               block0[15]  = append3_t[2];
145               block1[ 0]  = append3_t[3];
146
147               block1[ 1]  = append4_t[0];
148               block1[ 2]  = append4_t[1];
149               block1[ 3]  = append4_t[2];
150               block1[ 4]  = append4_t[3];
151               break;
152
153     case  2:  block0[ 2] |= append0_t[0];
154               block0[ 3]  = append0_t[1];
155               block0[ 4]  = append0_t[2];
156               block0[ 5]  = append0_t[3];
157
158               block0[ 6]  = append1_t[0];
159               block0[ 7]  = append1_t[1];
160               block0[ 8]  = append1_t[2];
161               block0[ 9]  = append1_t[3];
162
163               block0[10]  = append2_t[0];
164               block0[11]  = append2_t[1];
165               block0[12]  = append2_t[2];
166               block0[13]  = append2_t[3];
167
168               block0[14]  = append3_t[0];
169               block0[15]  = append3_t[1];
170               block1[ 0]  = append3_t[2];
171               block1[ 1]  = append3_t[3];
172
173               block1[ 2]  = append4_t[0];
174               block1[ 3]  = append4_t[1];
175               block1[ 4]  = append4_t[2];
176               block1[ 5]  = append4_t[3];
177               break;
178
179     case  3:  block0[ 3] |= append0_t[0];
180               block0[ 4]  = append0_t[1];
181               block0[ 5]  = append0_t[2];
182               block0[ 6]  = append0_t[3];
183
184               block0[ 7]  = append1_t[0];
185               block0[ 8]  = append1_t[1];
186               block0[ 9]  = append1_t[2];
187               block0[10]  = append1_t[3];
188
189               block0[11]  = append2_t[0];
190               block0[12]  = append2_t[1];
191               block0[13]  = append2_t[2];
192               block0[14]  = append2_t[3];
193
194               block0[15]  = append3_t[0];
195               block1[ 0]  = append3_t[1];
196               block1[ 1]  = append3_t[2];
197               block1[ 2]  = append3_t[3];
198
199               block1[ 3]  = append4_t[0];
200               block1[ 4]  = append4_t[1];
201               block1[ 5]  = append4_t[2];
202               block1[ 6]  = append4_t[3];
203               break;
204
205     case  4:  block0[ 4] |= append0_t[0];
206               block0[ 5]  = append0_t[1];
207               block0[ 6]  = append0_t[2];
208               block0[ 7]  = append0_t[3];
209
210               block0[ 8]  = append1_t[0];
211               block0[ 9]  = append1_t[1];
212               block0[10]  = append1_t[2];
213               block0[11]  = append1_t[3];
214
215               block0[12]  = append2_t[0];
216               block0[13]  = append2_t[1];
217               block0[14]  = append2_t[2];
218               block0[15]  = append2_t[3];
219
220               block1[ 0]  = append3_t[0];
221               block1[ 1]  = append3_t[1];
222               block1[ 2]  = append3_t[2];
223               block1[ 3]  = append3_t[3];
224
225               block1[ 4]  = append4_t[0];
226               block1[ 5]  = append4_t[1];
227               block1[ 6]  = append4_t[2];
228               block1[ 7]  = append4_t[3];
229               break;
230
231     case  5:  block0[ 5] |= append0_t[0];
232               block0[ 6]  = append0_t[1];
233               block0[ 7]  = append0_t[2];
234               block0[ 8]  = append0_t[3];
235
236               block0[ 9]  = append1_t[0];
237               block0[10]  = append1_t[1];
238               block0[11]  = append1_t[2];
239               block0[12]  = append1_t[3];
240
241               block0[13]  = append2_t[0];
242               block0[14]  = append2_t[1];
243               block0[15]  = append2_t[2];
244               block1[ 0]  = append2_t[3];
245
246               block1[ 1]  = append3_t[0];
247               block1[ 2]  = append3_t[1];
248               block1[ 3]  = append3_t[2];
249               block1[ 4]  = append3_t[3];
250
251               block1[ 5]  = append4_t[0];
252               block1[ 6]  = append4_t[1];
253               block1[ 7]  = append4_t[2];
254               block1[ 8]  = append4_t[3];
255               break;
256
257     case  6:  block0[ 6] |= append0_t[0];
258               block0[ 7]  = append0_t[1];
259               block0[ 8]  = append0_t[2];
260               block0[ 9]  = append0_t[3];
261
262               block0[10]  = append1_t[0];
263               block0[11]  = append1_t[1];
264               block0[12]  = append1_t[2];
265               block0[13]  = append1_t[3];
266
267               block0[14]  = append2_t[0];
268               block0[15]  = append2_t[1];
269               block1[ 0]  = append2_t[2];
270               block1[ 1]  = append2_t[3];
271
272               block1[ 2]  = append3_t[0];
273               block1[ 3]  = append3_t[1];
274               block1[ 4]  = append3_t[2];
275               block1[ 5]  = append3_t[3];
276
277               block1[ 6]  = append4_t[0];
278               block1[ 7]  = append4_t[1];
279               block1[ 8]  = append4_t[2];
280               block1[ 9]  = append4_t[3];
281               break;
282
283     case  7:  block0[ 7] |= append0_t[0];
284               block0[ 8]  = append0_t[1];
285               block0[ 9]  = append0_t[2];
286               block0[10]  = append0_t[3];
287
288               block0[11]  = append1_t[0];
289               block0[12]  = append1_t[1];
290               block0[13]  = append1_t[2];
291               block0[14]  = append1_t[3];
292
293               block0[15]  = append2_t[0];
294               block1[ 0]  = append2_t[1];
295               block1[ 1]  = append2_t[2];
296               block1[ 2]  = append2_t[3];
297
298               block1[ 3]  = append3_t[0];
299               block1[ 4]  = append3_t[1];
300               block1[ 5]  = append3_t[2];
301               block1[ 6]  = append3_t[3];
302
303               block1[ 7]  = append4_t[0];
304               block1[ 8]  = append4_t[1];
305               block1[ 9]  = append4_t[2];
306               block1[10]  = append4_t[3];
307               break;
308
309     case  8:  block0[ 8] |= append0_t[0];
310               block0[ 9]  = append0_t[1];
311               block0[10]  = append0_t[2];
312               block0[11]  = append0_t[3];
313
314               block0[12]  = append1_t[0];
315               block0[13]  = append1_t[1];
316               block0[14]  = append1_t[2];
317               block0[15]  = append1_t[3];
318
319               block1[ 0]  = append2_t[0];
320               block1[ 1]  = append2_t[1];
321               block1[ 2]  = append2_t[2];
322               block1[ 3]  = append2_t[3];
323
324               block1[ 4]  = append3_t[0];
325               block1[ 5]  = append3_t[1];
326               block1[ 6]  = append3_t[2];
327               block1[ 7]  = append3_t[3];
328
329               block1[ 8]  = append4_t[0];
330               block1[ 9]  = append4_t[1];
331               block1[10]  = append4_t[2];
332               block1[11]  = append4_t[3];
333               break;
334
335     case  9:  block0[ 9] |= append0_t[0];
336               block0[10]  = append0_t[1];
337               block0[11]  = append0_t[2];
338               block0[12]  = append0_t[3];
339
340               block0[13]  = append1_t[0];
341               block0[14]  = append1_t[1];
342               block0[15]  = append1_t[2];
343               block1[ 0]  = append1_t[3];
344
345               block1[ 1]  = append2_t[0];
346               block1[ 2]  = append2_t[1];
347               block1[ 3]  = append2_t[2];
348               block1[ 4]  = append2_t[3];
349
350               block1[ 5]  = append3_t[0];
351               block1[ 6]  = append3_t[1];
352               block1[ 7]  = append3_t[2];
353               block1[ 8]  = append3_t[3];
354
355               block1[ 9]  = append4_t[0];
356               block1[10]  = append4_t[1];
357               block1[11]  = append4_t[2];
358               block1[12]  = append4_t[3];
359               break;
360
361     case 10:  block0[10] |= append0_t[0];
362               block0[11]  = append0_t[1];
363               block0[12]  = append0_t[2];
364               block0[13]  = append0_t[3];
365
366               block0[14]  = append1_t[0];
367               block0[15]  = append1_t[1];
368               block1[ 0]  = append1_t[2];
369               block1[ 1]  = append1_t[3];
370
371               block1[ 2]  = append2_t[0];
372               block1[ 3]  = append2_t[1];
373               block1[ 4]  = append2_t[2];
374               block1[ 5]  = append2_t[3];
375
376               block1[ 6]  = append3_t[0];
377               block1[ 7]  = append3_t[1];
378               block1[ 8]  = append3_t[2];
379               block1[ 9]  = append3_t[3];
380
381               block1[10]  = append4_t[0];
382               block1[11]  = append4_t[1];
383               block1[12]  = append4_t[2];
384               block1[13]  = append4_t[3];
385               break;
386
387     case 11:  block0[11] |= append0_t[0];
388               block0[12]  = append0_t[1];
389               block0[13]  = append0_t[2];
390               block0[14]  = append0_t[3];
391
392               block0[15]  = append1_t[0];
393               block1[ 0]  = append1_t[1];
394               block1[ 1]  = append1_t[2];
395               block1[ 2]  = append1_t[3];
396
397               block1[ 3]  = append2_t[0];
398               block1[ 4]  = append2_t[1];
399               block1[ 5]  = append2_t[2];
400               block1[ 6]  = append2_t[3];
401
402               block1[ 7]  = append3_t[0];
403               block1[ 8]  = append3_t[1];
404               block1[ 9]  = append3_t[2];
405               block1[10]  = append3_t[3];
406
407               block1[11]  = append4_t[0];
408               block1[12]  = append4_t[1];
409               block1[13]  = append4_t[2];
410               block1[14]  = append4_t[3];
411               break;
412
413     case 12:  block0[12] |= append0_t[0];
414               block0[13]  = append0_t[1];
415               block0[14]  = append0_t[2];
416               block0[15]  = append0_t[3];
417
418               block1[ 0]  = append1_t[0];
419               block1[ 1]  = append1_t[1];
420               block1[ 2]  = append1_t[2];
421               block1[ 3]  = append1_t[3];
422
423               block1[ 4]  = append2_t[0];
424               block1[ 5]  = append2_t[1];
425               block1[ 6]  = append2_t[2];
426               block1[ 7]  = append2_t[3];
427
428               block1[ 8]  = append3_t[0];
429               block1[ 9]  = append3_t[1];
430               block1[10]  = append3_t[2];
431               block1[11]  = append3_t[3];
432
433               block1[12]  = append4_t[0];
434               block1[13]  = append4_t[1];
435               block1[14]  = append4_t[2];
436               block1[15]  = append4_t[3];
437               break;
438
439     case 13:  block0[13] |= append0_t[0];
440               block0[14]  = append0_t[1];
441               block0[15]  = append0_t[2];
442               block1[ 0]  = append0_t[3];
443
444               block1[ 1]  = append1_t[0];
445               block1[ 2]  = append1_t[1];
446               block1[ 3]  = append1_t[2];
447               block1[ 4]  = append1_t[3];
448
449               block1[ 5]  = append2_t[0];
450               block1[ 6]  = append2_t[1];
451               block1[ 7]  = append2_t[2];
452               block1[ 8]  = append2_t[3];
453
454               block1[ 9]  = append3_t[0];
455               block1[10]  = append3_t[1];
456               block1[11]  = append3_t[2];
457               block1[12]  = append3_t[3];
458
459               block1[13]  = append4_t[0];
460               block1[14]  = append4_t[1];
461               block1[15]  = append4_t[2];
462               break;
463
464     case 14:  block0[14] |= append0_t[0];
465               block0[15]  = append0_t[1];
466               block1[ 0]  = append0_t[2];
467               block1[ 1]  = append0_t[3];
468
469               block1[ 2]  = append1_t[0];
470               block1[ 3]  = append1_t[1];
471               block1[ 4]  = append1_t[2];
472               block1[ 5]  = append1_t[3];
473
474               block1[ 6]  = append2_t[0];
475               block1[ 7]  = append2_t[1];
476               block1[ 8]  = append2_t[2];
477               block1[ 9]  = append2_t[3];
478
479               block1[10]  = append3_t[0];
480               block1[11]  = append3_t[1];
481               block1[12]  = append3_t[2];
482               block1[13]  = append3_t[3];
483
484               block1[14]  = append4_t[0];
485               block1[15]  = append4_t[1];
486               break;
487
488     case 15:  block0[15] |= append0_t[0];
489               block1[ 0]  = append0_t[1];
490               block1[ 1]  = append0_t[2];
491               block1[ 2]  = append0_t[3];
492
493               block1[ 3]  = append1_t[1];
494               block1[ 4]  = append1_t[2];
495               block1[ 5]  = append1_t[3];
496               block1[ 6]  = append1_t[0];
497
498               block1[ 7]  = append2_t[0];
499               block1[ 8]  = append2_t[1];
500               block1[ 9]  = append2_t[2];
501               block1[10]  = append2_t[3];
502
503               block1[11]  = append3_t[0];
504               block1[12]  = append3_t[1];
505               block1[13]  = append3_t[2];
506               block1[14]  = append3_t[3];
507
508               block1[15]  = append4_t[0];
509               break;
510
511     case 16:  block1[ 0] |= append0_t[0];
512               block1[ 1]  = append0_t[1];
513               block1[ 2]  = append0_t[2];
514               block1[ 3]  = append0_t[3];
515
516               block1[ 4]  = append1_t[0];
517               block1[ 5]  = append1_t[1];
518               block1[ 6]  = append1_t[2];
519               block1[ 7]  = append1_t[3];
520
521               block1[ 8]  = append2_t[0];
522               block1[ 9]  = append2_t[1];
523               block1[10]  = append2_t[2];
524               block1[11]  = append2_t[3];
525
526               block1[12]  = append3_t[0];
527               block1[13]  = append3_t[1];
528               block1[14]  = append3_t[2];
529               block1[15]  = append3_t[3];
530               break;
531
532     case 17:  block1[ 1] |= append0_t[0];
533               block1[ 2]  = append0_t[1];
534               block1[ 3]  = append0_t[2];
535               block1[ 4]  = append0_t[3];
536
537               block1[ 5]  = append1_t[0];
538               block1[ 6]  = append1_t[1];
539               block1[ 7]  = append1_t[2];
540               block1[ 8]  = append1_t[3];
541
542               block1[ 9]  = append2_t[0];
543               block1[10]  = append2_t[1];
544               block1[11]  = append2_t[2];
545               block1[12]  = append2_t[3];
546
547               block1[13]  = append3_t[0];
548               block1[14]  = append3_t[1];
549               block1[15]  = append3_t[2];
550               break;
551
552     case 18:  block1[ 2] |= append0_t[0];
553               block1[ 3]  = append0_t[1];
554               block1[ 4]  = append0_t[2];
555               block1[ 5]  = append0_t[3];
556
557               block1[ 6]  = append1_t[0];
558               block1[ 7]  = append1_t[1];
559               block1[ 8]  = append1_t[2];
560               block1[ 9]  = append1_t[3];
561
562               block1[10]  = append2_t[0];
563               block1[11]  = append2_t[1];
564               block1[12]  = append2_t[2];
565               block1[13]  = append2_t[3];
566
567               block1[14]  = append3_t[0];
568               block1[15]  = append3_t[1];
569               break;
570
571     case 19:  block1[ 3] |= append0_t[0];
572               block1[ 4]  = append0_t[1];
573               block1[ 5]  = append0_t[2];
574               block1[ 6]  = append0_t[3];
575
576               block1[ 7]  = append1_t[0];
577               block1[ 8]  = append1_t[1];
578               block1[ 9]  = append1_t[2];
579               block1[10]  = append1_t[3];
580
581               block1[11]  = append2_t[0];
582               block1[12]  = append2_t[1];
583               block1[13]  = append2_t[2];
584               block1[14]  = append2_t[3];
585
586               block1[15]  = append3_t[0];
587               break;
588
589     case 20:  block1[ 4] |= append0_t[0];
590               block1[ 5]  = append0_t[1];
591               block1[ 6]  = append0_t[2];
592               block1[ 7]  = append0_t[3];
593
594               block1[ 8]  = append1_t[0];
595               block1[ 9]  = append1_t[1];
596               block1[10]  = append1_t[2];
597               block1[11]  = append1_t[3];
598
599               block1[12]  = append2_t[0];
600               block1[13]  = append2_t[1];
601               block1[14]  = append2_t[2];
602               block1[15]  = append2_t[3];
603               break;
604
605     case 21:  block1[ 5] |= append0_t[0];
606               block1[ 6]  = append0_t[1];
607               block1[ 7]  = append0_t[2];
608               block1[ 8]  = append0_t[3];
609
610               block1[ 9]  = append1_t[0];
611               block1[10]  = append1_t[1];
612               block1[11]  = append1_t[2];
613               block1[12]  = append1_t[3];
614
615               block1[13]  = append2_t[0];
616               block1[14]  = append2_t[1];
617               block1[15]  = append2_t[2];
618               break;
619
620     case 22:  block1[ 6] |= append0_t[0];
621               block1[ 7]  = append0_t[1];
622               block1[ 8]  = append0_t[2];
623               block1[ 9]  = append0_t[3];
624
625               block1[10]  = append1_t[0];
626               block1[11]  = append1_t[1];
627               block1[12]  = append1_t[2];
628               block1[13]  = append1_t[3];
629
630               block1[14]  = append2_t[0];
631               block1[15]  = append2_t[1];
632               break;
633
634     case 23:  block1[ 7] |= append0_t[0];
635               block1[ 8]  = append0_t[1];
636               block1[ 9]  = append0_t[2];
637               block1[10]  = append0_t[3];
638
639               block1[11]  = append1_t[0];
640               block1[12]  = append1_t[1];
641               block1[13]  = append1_t[2];
642               block1[14]  = append1_t[3];
643
644               block1[15]  = append2_t[0];
645               break;
646
647     case 24:  block1[ 8] |= append0_t[0];
648               block1[ 9]  = append0_t[1];
649               block1[10]  = append0_t[2];
650               block1[11]  = append0_t[3];
651
652               block1[12]  = append1_t[0];
653               block1[13]  = append1_t[1];
654               block1[14]  = append1_t[2];
655               block1[15]  = append1_t[3];
656               break;
657
658     case 25:  block1[ 9] |= append0_t[0];
659               block1[10]  = append0_t[1];
660               block1[11]  = append0_t[2];
661               block1[12]  = append0_t[3];
662
663               block1[13]  = append1_t[0];
664               block1[14]  = append1_t[1];
665               block1[15]  = append1_t[2];
666               break;
667
668     case 26:  block1[10] |= append0_t[0];
669               block1[11]  = append0_t[1];
670               block1[12]  = append0_t[2];
671               block1[13]  = append0_t[3];
672
673               block1[14]  = append1_t[0];
674               block1[15]  = append1_t[1];
675               break;
676
677     case 27:  block1[11] |= append0_t[0];
678               block1[12]  = append0_t[1];
679               block1[13]  = append0_t[2];
680               block1[14]  = append0_t[3];
681
682               block1[15]  = append1_t[0];
683               break;
684
685     case 28:  block1[12] |= append0_t[0];
686               block1[13]  = append0_t[1];
687               block1[14]  = append0_t[2];
688               block1[15]  = append0_t[3];
689               break;
690
691     case 29:  block1[13] |= append0_t[0];
692               block1[14]  = append0_t[1];
693               block1[15]  = append0_t[2];
694               break;
695
696     case 30:  block1[14] |= append0_t[0];
697               block1[15]  = append0_t[1];
698               break;
699   }
700
701   u32 new_len = block_len + append_len;
702
703   return new_len;
704 }
705
706 __device__ __constant__ char c_bin2asc[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
707
708 __device__ __shared__ short l_bin2asc[256];
709
710 __device__ __constant__ bf_t c_bfs[1024];
711
712 __device__ static void m11400m_0_0 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
713 {
714   /**
715    * modifier
716    */
717
718   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
719   const u32 lid = threadIdx.x;
720
721   /**
722    * digest
723    */
724
725   const u32 search[4] =
726   {
727     digests_buf[digests_offset].digest_buf[DGST_R0],
728     digests_buf[digests_offset].digest_buf[DGST_R1],
729     digests_buf[digests_offset].digest_buf[DGST_R2],
730     digests_buf[digests_offset].digest_buf[DGST_R3]
731   };
732
733   /**
734    * salt
735    */
736
737   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
738
739   const u32 pw_salt_len = salt_len + pw_len;
740
741   u32 salt_buf0[16];
742
743   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
744   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
745   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
746   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
747   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
748   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
749   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
750   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
751   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
752   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
753   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
754   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
755   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
756   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
757   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
758   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
759
760   u32 salt_buf1[16];
761
762   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
763   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
764   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
765   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
766   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
767   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
768   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
769   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
770   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
771   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
772   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
773   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
774   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
775   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
776   salt_buf1[14] = 0;
777   salt_buf1[15] = 0;
778
779   /**
780    * esalt
781    */
782
783   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
784
785   u32 esalt_buf0[16];
786
787   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
788   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
789   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
790   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
791   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
792   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
793   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
794   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
795   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
796   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
797   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
798   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
799   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
800   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
801   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
802   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
803
804   u32 esalt_buf1[16];
805
806   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
807   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
808   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
809   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
810   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
811   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
812   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
813   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
814   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
815   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
816   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
817   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
818   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
819   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
820   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
821   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
822
823   const u32 digest_esalt_len = 32 + esalt_len;
824
825   /**
826    * loop
827    */
828
829   u32x w0l = w0[0];
830
831   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
832   {
833     const u32 w0r = c_bfs[il_pos].i;
834
835     w0[0] = w0l | w0r;
836
837     /*
838      * HA1 = md5 ($salt . $pass)
839      */
840
841     // append the pass to the salt
842
843     u32x block0[16];
844
845     block0[ 0] = salt_buf0[ 0];
846     block0[ 1] = salt_buf0[ 1];
847     block0[ 2] = salt_buf0[ 2];
848     block0[ 3] = salt_buf0[ 3];
849     block0[ 4] = salt_buf0[ 4];
850     block0[ 5] = salt_buf0[ 5];
851     block0[ 6] = salt_buf0[ 6];
852     block0[ 7] = salt_buf0[ 7];
853     block0[ 8] = salt_buf0[ 8];
854     block0[ 9] = salt_buf0[ 9];
855     block0[10] = salt_buf0[10];
856     block0[11] = salt_buf0[11];
857     block0[12] = salt_buf0[12];
858     block0[13] = salt_buf0[13];
859     block0[14] = salt_buf0[14];
860     block0[15] = salt_buf0[15];
861
862     u32x block1[16];
863
864     block1[ 0] = salt_buf1[ 0];
865     block1[ 1] = salt_buf1[ 1];
866     block1[ 2] = salt_buf1[ 2];
867     block1[ 3] = salt_buf1[ 3];
868     block1[ 4] = salt_buf1[ 4];
869     block1[ 5] = salt_buf1[ 5];
870     block1[ 6] = salt_buf1[ 6];
871     block1[ 7] = salt_buf1[ 7];
872     block1[ 8] = salt_buf1[ 8];
873     block1[ 9] = salt_buf1[ 9];
874     block1[10] = salt_buf1[10];
875     block1[11] = salt_buf1[11];
876     block1[12] = salt_buf1[12];
877     block1[13] = salt_buf1[13];
878     block1[14] = salt_buf1[14];
879     block1[15] = salt_buf1[15];
880
881     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
882
883     u32x w0_t[4];
884
885     w0_t[0] = block0[ 0];
886     w0_t[1] = block0[ 1];
887     w0_t[2] = block0[ 2];
888     w0_t[3] = block0[ 3];
889
890     u32x w1_t[4];
891
892     w1_t[0] = block0[ 4];
893     w1_t[1] = block0[ 5];
894     w1_t[2] = block0[ 6];
895     w1_t[3] = block0[ 7];
896
897     u32x w2_t[4];
898
899     w2_t[0] = block0[ 8];
900     w2_t[1] = block0[ 9];
901     w2_t[2] = block0[10];
902     w2_t[3] = block0[11];
903
904     u32x w3_t[4];
905
906     w3_t[0] = block0[12];
907     w3_t[1] = block0[13];
908     w3_t[2] = pw_salt_len * 8;
909     w3_t[3] = 0;
910
911     // md5
912
913     u32x tmp2;
914
915     u32x a = MD5M_A;
916     u32x b = MD5M_B;
917     u32x c = MD5M_C;
918     u32x d = MD5M_D;
919
920     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
921     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
922     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
923     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
924     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
925     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
926     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
927     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
928     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
929     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
930     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
931     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
932     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
933     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
934     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
935     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
936
937     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
938     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
939     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
940     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
941     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
942     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
943     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
944     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
945     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
946     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
947     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
948     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
949     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
950     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
951     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
952     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
953
954     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
955     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
956     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
957     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
958     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
959     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
960     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
961     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
962     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
963     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
964     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
965     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
966     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
967     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
968     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
969     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
970
971     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
972     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
973     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
974     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
975     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
976     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
977     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
978     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
979     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
980     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
981     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
982     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
983     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
984     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
985     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
986     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
987
988     a += MD5M_A;
989     b += MD5M_B;
990     c += MD5M_C;
991     d += MD5M_D;
992
993     /*
994      * final = md5 ($HA1 . $esalt)
995      * we have at least 2 MD5 blocks/transformations, but we might need 3
996      */
997
998     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
999             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
1000     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
1001             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
1002     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
1003             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
1004     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
1005             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
1006     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
1007             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
1008     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
1009             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
1010     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
1011             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
1012     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
1013             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
1014
1015     w2_t[0] = esalt_buf0[0];
1016     w2_t[1] = esalt_buf0[1];
1017     w2_t[2] = esalt_buf0[2];
1018     w2_t[3] = esalt_buf0[3];
1019
1020     w3_t[0] = esalt_buf0[4];
1021     w3_t[1] = esalt_buf0[5];
1022     w3_t[2] = esalt_buf0[6];
1023     w3_t[3] = esalt_buf0[7];
1024
1025     // md5
1026     // 1st transform
1027
1028     a = MD5M_A;
1029     b = MD5M_B;
1030     c = MD5M_C;
1031     d = MD5M_D;
1032
1033     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
1034     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
1035     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
1036     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
1037     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
1038     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
1039     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
1040     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
1041     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
1042     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
1043     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
1044     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
1045     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
1046     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
1047     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
1048     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
1049
1050     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
1051     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
1052     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
1053     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
1054     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
1055     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
1056     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
1057     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
1058     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
1059     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
1060     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
1061     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
1062     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
1063     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
1064     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
1065     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
1066
1067     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
1068     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
1069     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
1070     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
1071     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
1072     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
1073     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
1074     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
1075     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
1076     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
1077     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
1078     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
1079     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
1080     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
1081     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
1082     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
1083
1084     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
1085     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
1086     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
1087     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
1088     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
1089     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
1090     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
1091     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
1092     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
1093     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
1094     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
1095     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
1096     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
1097     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
1098     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
1099     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
1100
1101     a += MD5M_A;
1102     b += MD5M_B;
1103     c += MD5M_C;
1104     d += MD5M_D;
1105
1106     u32x r_a = a;
1107     u32x r_b = b;
1108     u32x r_c = c;
1109     u32x r_d = d;
1110
1111     // 2nd transform
1112
1113     w0_t[0] = esalt_buf0[ 8];
1114     w0_t[1] = esalt_buf0[ 9];
1115     w0_t[2] = esalt_buf0[10];
1116     w0_t[3] = esalt_buf0[11];
1117
1118     w1_t[0] = esalt_buf0[12];
1119     w1_t[1] = esalt_buf0[13];
1120     w1_t[2] = esalt_buf0[14];
1121     w1_t[3] = esalt_buf0[15];
1122
1123     w2_t[0] = esalt_buf1[ 0];
1124     w2_t[1] = esalt_buf1[ 1];
1125     w2_t[2] = esalt_buf1[ 2];
1126     w2_t[3] = esalt_buf1[ 3];
1127
1128     w3_t[0] = esalt_buf1[ 4];
1129     w3_t[1] = esalt_buf1[ 5];
1130     w3_t[2] = digest_esalt_len * 8;
1131     w3_t[3] = 0;
1132
1133     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
1134     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
1135     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
1136     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
1137     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
1138     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
1139     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
1140     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
1141     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
1142     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
1143     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
1144     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
1145     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
1146     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
1147     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
1148     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
1149
1150     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
1151     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
1152     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
1153     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
1154     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
1155     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
1156     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
1157     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
1158     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
1159     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
1160     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
1161     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
1162     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
1163     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
1164     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
1165     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
1166
1167     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
1168     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
1169     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
1170     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
1171     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
1172     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
1173     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
1174     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
1175     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
1176     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
1177     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
1178     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
1179     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
1180     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
1181     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
1182     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
1183
1184     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
1185     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
1186     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
1187     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
1188     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
1189     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
1190     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
1191     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
1192     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
1193     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
1194     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
1195     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
1196     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
1197     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
1198     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
1199     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
1200
1201     a += r_a;
1202     b += r_b;
1203     c += r_c;
1204     d += r_d;
1205
1206     const u32x r0 = a;
1207     const u32x r1 = d;
1208     const u32x r2 = c;
1209     const u32x r3 = b;
1210
1211     #include VECT_COMPARE_S
1212   }
1213 }
1214
1215 __device__ static void m11400m_0_1 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
1216 {
1217   /**
1218    * modifier
1219    */
1220
1221   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
1222   const u32 lid = threadIdx.x;
1223
1224   /**
1225    * digest
1226    */
1227
1228   const u32 search[4] =
1229   {
1230     digests_buf[digests_offset].digest_buf[DGST_R0],
1231     digests_buf[digests_offset].digest_buf[DGST_R1],
1232     digests_buf[digests_offset].digest_buf[DGST_R2],
1233     digests_buf[digests_offset].digest_buf[DGST_R3]
1234   };
1235
1236   /**
1237    * salt
1238    */
1239
1240   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
1241
1242   const u32 pw_salt_len = salt_len + pw_len;
1243
1244   u32 salt_buf0[16];
1245
1246   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
1247   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
1248   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
1249   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
1250   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
1251   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
1252   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
1253   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
1254   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
1255   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
1256   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
1257   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
1258   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
1259   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
1260   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
1261   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
1262
1263   u32 salt_buf1[16];
1264
1265   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
1266   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
1267   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
1268   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
1269   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
1270   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
1271   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
1272   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
1273   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
1274   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
1275   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
1276   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
1277   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
1278   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
1279   salt_buf1[14] = 0;
1280   salt_buf1[15] = 0;
1281
1282   /**
1283    * esalt
1284    */
1285
1286   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
1287
1288   u32 esalt_buf0[16];
1289
1290   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
1291   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
1292   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
1293   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
1294   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
1295   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
1296   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
1297   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
1298   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
1299   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
1300   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
1301   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
1302   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
1303   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
1304   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
1305   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
1306
1307   u32 esalt_buf1[16];
1308
1309   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
1310   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
1311   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
1312   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
1313   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
1314   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
1315   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
1316   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
1317   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
1318   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
1319   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
1320   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
1321   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
1322   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
1323   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
1324   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
1325
1326   u32 esalt_buf2[16];
1327
1328   esalt_buf2[ 0] = esalt_bufs[salt_pos].esalt_buf[32];
1329   esalt_buf2[ 1] = esalt_bufs[salt_pos].esalt_buf[33];
1330   esalt_buf2[ 2] = esalt_bufs[salt_pos].esalt_buf[34];
1331   esalt_buf2[ 3] = esalt_bufs[salt_pos].esalt_buf[35];
1332   esalt_buf2[ 4] = esalt_bufs[salt_pos].esalt_buf[36];
1333   esalt_buf2[ 5] = esalt_bufs[salt_pos].esalt_buf[37];
1334   esalt_buf2[ 6] = 0;
1335   esalt_buf2[ 7] = 0;
1336   esalt_buf2[ 8] = 0;
1337   esalt_buf2[ 9] = 0;
1338   esalt_buf2[10] = 0;
1339   esalt_buf2[11] = 0;
1340   esalt_buf2[12] = 0;
1341   esalt_buf2[13] = 0;
1342   esalt_buf2[14] = 0;
1343   esalt_buf2[15] = 0;
1344
1345   const u32 digest_esalt_len = 32 + esalt_len;
1346
1347   /**
1348    * loop
1349    */
1350
1351   u32x w0l = w0[0];
1352
1353   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
1354   {
1355     const u32 w0r = c_bfs[il_pos].i;
1356
1357     w0[0] = w0l | w0r;
1358
1359     /*
1360      * HA1 = md5 ($salt . $pass)
1361      */
1362
1363     // append the pass to the salt
1364
1365     u32x block0[16];
1366
1367     block0[ 0] = salt_buf0[ 0];
1368     block0[ 1] = salt_buf0[ 1];
1369     block0[ 2] = salt_buf0[ 2];
1370     block0[ 3] = salt_buf0[ 3];
1371     block0[ 4] = salt_buf0[ 4];
1372     block0[ 5] = salt_buf0[ 5];
1373     block0[ 6] = salt_buf0[ 6];
1374     block0[ 7] = salt_buf0[ 7];
1375     block0[ 8] = salt_buf0[ 8];
1376     block0[ 9] = salt_buf0[ 9];
1377     block0[10] = salt_buf0[10];
1378     block0[11] = salt_buf0[11];
1379     block0[12] = salt_buf0[12];
1380     block0[13] = salt_buf0[13];
1381     block0[14] = salt_buf0[14];
1382     block0[15] = salt_buf0[15];
1383
1384     u32x block1[16];
1385
1386     block1[ 0] = salt_buf1[ 0];
1387     block1[ 1] = salt_buf1[ 1];
1388     block1[ 2] = salt_buf1[ 2];
1389     block1[ 3] = salt_buf1[ 3];
1390     block1[ 4] = salt_buf1[ 4];
1391     block1[ 5] = salt_buf1[ 5];
1392     block1[ 6] = salt_buf1[ 6];
1393     block1[ 7] = salt_buf1[ 7];
1394     block1[ 8] = salt_buf1[ 8];
1395     block1[ 9] = salt_buf1[ 9];
1396     block1[10] = salt_buf1[10];
1397     block1[11] = salt_buf1[11];
1398     block1[12] = salt_buf1[12];
1399     block1[13] = salt_buf1[13];
1400     block1[14] = salt_buf1[14];
1401     block1[15] = salt_buf1[15];
1402
1403     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
1404
1405     u32x w0_t[4];
1406
1407     w0_t[0] = block0[ 0];
1408     w0_t[1] = block0[ 1];
1409     w0_t[2] = block0[ 2];
1410     w0_t[3] = block0[ 3];
1411
1412     u32x w1_t[4];
1413
1414     w1_t[0] = block0[ 4];
1415     w1_t[1] = block0[ 5];
1416     w1_t[2] = block0[ 6];
1417     w1_t[3] = block0[ 7];
1418
1419     u32x w2_t[4];
1420
1421     w2_t[0] = block0[ 8];
1422     w2_t[1] = block0[ 9];
1423     w2_t[2] = block0[10];
1424     w2_t[3] = block0[11];
1425
1426     u32x w3_t[4];
1427
1428     w3_t[0] = block0[12];
1429     w3_t[1] = block0[13];
1430     w3_t[2] = pw_salt_len * 8;
1431     w3_t[3] = 0;
1432
1433     // md5
1434
1435     u32x tmp2;
1436
1437     u32x a = MD5M_A;
1438     u32x b = MD5M_B;
1439     u32x c = MD5M_C;
1440     u32x d = MD5M_D;
1441
1442     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
1443     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
1444     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
1445     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
1446     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
1447     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
1448     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
1449     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
1450     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
1451     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
1452     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
1453     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
1454     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
1455     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
1456     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
1457     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
1458
1459     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
1460     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
1461     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
1462     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
1463     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
1464     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
1465     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
1466     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
1467     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
1468     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
1469     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
1470     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
1471     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
1472     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
1473     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
1474     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
1475
1476     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
1477     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
1478     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
1479     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
1480     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
1481     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
1482     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
1483     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
1484     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
1485     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
1486     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
1487     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
1488     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
1489     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
1490     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
1491     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
1492
1493     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
1494     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
1495     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
1496     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
1497     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
1498     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
1499     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
1500     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
1501     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
1502     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
1503     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
1504     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
1505     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
1506     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
1507     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
1508     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
1509
1510     a += MD5M_A;
1511     b += MD5M_B;
1512     c += MD5M_C;
1513     d += MD5M_D;
1514
1515     /*
1516      * final = md5 ($HA1 . $esalt)
1517      * we have at least 2 MD5 blocks/transformations, but we might need 3
1518      */
1519
1520     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
1521             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
1522     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
1523             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
1524     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
1525             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
1526     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
1527             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
1528     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
1529             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
1530     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
1531             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
1532     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
1533             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
1534     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
1535             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
1536
1537     w2_t[0] = esalt_buf0[0];
1538     w2_t[1] = esalt_buf0[1];
1539     w2_t[2] = esalt_buf0[2];
1540     w2_t[3] = esalt_buf0[3];
1541
1542     w3_t[0] = esalt_buf0[4];
1543     w3_t[1] = esalt_buf0[5];
1544     w3_t[2] = esalt_buf0[6];
1545     w3_t[3] = esalt_buf0[7];
1546
1547     // md5
1548     // 1st transform
1549
1550     a = MD5M_A;
1551     b = MD5M_B;
1552     c = MD5M_C;
1553     d = MD5M_D;
1554
1555     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
1556     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
1557     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
1558     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
1559     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
1560     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
1561     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
1562     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
1563     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
1564     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
1565     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
1566     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
1567     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
1568     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
1569     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
1570     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
1571
1572     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
1573     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
1574     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
1575     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
1576     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
1577     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
1578     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
1579     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
1580     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
1581     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
1582     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
1583     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
1584     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
1585     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
1586     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
1587     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
1588
1589     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
1590     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
1591     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
1592     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
1593     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
1594     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
1595     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
1596     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
1597     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
1598     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
1599     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
1600     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
1601     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
1602     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
1603     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
1604     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
1605
1606     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
1607     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
1608     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
1609     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
1610     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
1611     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
1612     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
1613     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
1614     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
1615     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
1616     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
1617     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
1618     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
1619     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
1620     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
1621     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
1622
1623     a += MD5M_A;
1624     b += MD5M_B;
1625     c += MD5M_C;
1626     d += MD5M_D;
1627
1628     u32x r_a = a;
1629     u32x r_b = b;
1630     u32x r_c = c;
1631     u32x r_d = d;
1632
1633     // 2nd transform
1634
1635     w0_t[0] = esalt_buf0[ 8];
1636     w0_t[1] = esalt_buf0[ 9];
1637     w0_t[2] = esalt_buf0[10];
1638     w0_t[3] = esalt_buf0[11];
1639
1640     w1_t[0] = esalt_buf0[12];
1641     w1_t[1] = esalt_buf0[13];
1642     w1_t[2] = esalt_buf0[14];
1643     w1_t[3] = esalt_buf0[15];
1644
1645     w2_t[0] = esalt_buf1[ 0];
1646     w2_t[1] = esalt_buf1[ 1];
1647     w2_t[2] = esalt_buf1[ 2];
1648     w2_t[3] = esalt_buf1[ 3];
1649
1650     w3_t[0] = esalt_buf1[ 4];
1651     w3_t[1] = esalt_buf1[ 5];
1652     w3_t[2] = esalt_buf1[ 6];
1653     w3_t[3] = esalt_buf1[ 7];
1654
1655     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
1656     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
1657     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
1658     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
1659     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
1660     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
1661     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
1662     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
1663     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
1664     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
1665     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
1666     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
1667     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
1668     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
1669     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
1670     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
1671
1672     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
1673     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
1674     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
1675     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
1676     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
1677     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
1678     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
1679     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
1680     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
1681     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
1682     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
1683     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
1684     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
1685     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
1686     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
1687     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
1688
1689     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
1690     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
1691     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
1692     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
1693     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
1694     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
1695     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
1696     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
1697     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
1698     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
1699     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
1700     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
1701     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
1702     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
1703     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
1704     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
1705
1706     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
1707     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
1708     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
1709     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
1710     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
1711     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
1712     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
1713     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
1714     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
1715     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
1716     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
1717     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
1718     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
1719     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
1720     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
1721     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
1722
1723     // this is for sure the final block
1724
1725     a += r_a;
1726     b += r_b;
1727     c += r_c;
1728     d += r_d;
1729
1730     r_a = a;
1731     r_b = b;
1732     r_c = c;
1733     r_d = d;
1734
1735     w0_t[0] = esalt_buf1[ 8];
1736     w0_t[1] = esalt_buf1[ 9];
1737     w0_t[2] = esalt_buf1[10];
1738     w0_t[3] = esalt_buf1[11];
1739
1740     w1_t[0] = esalt_buf1[12];
1741     w1_t[1] = esalt_buf1[13];
1742     w1_t[2] = esalt_buf1[14];
1743     w1_t[3] = esalt_buf1[15];
1744
1745     w2_t[0] = esalt_buf2[ 0];
1746     w2_t[1] = esalt_buf2[ 1];
1747     w2_t[2] = esalt_buf2[ 2];
1748     w2_t[3] = esalt_buf2[ 3];
1749
1750     w3_t[0] = esalt_buf2[ 4];
1751     w3_t[1] = esalt_buf2[ 5];
1752     w3_t[2] = digest_esalt_len * 8;
1753     w3_t[3] = 0;
1754
1755     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
1756     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
1757     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
1758     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
1759     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
1760     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
1761     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
1762     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
1763     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
1764     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
1765     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
1766     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
1767     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
1768     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
1769     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
1770     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
1771
1772     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
1773     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
1774     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
1775     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
1776     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
1777     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
1778     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
1779     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
1780     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
1781     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
1782     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
1783     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
1784     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
1785     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
1786     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
1787     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
1788
1789     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
1790     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
1791     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
1792     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
1793     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
1794     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
1795     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
1796     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
1797     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
1798     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
1799     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
1800     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
1801     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
1802     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
1803     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
1804     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
1805
1806     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
1807     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
1808     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
1809     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
1810     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
1811     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
1812     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
1813     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
1814     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
1815     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
1816     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
1817     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
1818     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
1819     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
1820     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
1821     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
1822
1823     a += r_a;
1824     b += r_b;
1825     c += r_c;
1826     d += r_d;
1827
1828     const u32x r0 = a;
1829     const u32x r1 = d;
1830     const u32x r2 = c;
1831     const u32x r3 = b;
1832
1833     #include VECT_COMPARE_S
1834   }
1835 }
1836
1837 __device__ static void m11400m_1_0 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
1838 {
1839   /**
1840    * modifier
1841    */
1842
1843   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
1844   const u32 lid = threadIdx.x;
1845
1846   /**
1847    * digest
1848    */
1849
1850   const u32 search[4] =
1851   {
1852     digests_buf[digests_offset].digest_buf[DGST_R0],
1853     digests_buf[digests_offset].digest_buf[DGST_R1],
1854     digests_buf[digests_offset].digest_buf[DGST_R2],
1855     digests_buf[digests_offset].digest_buf[DGST_R3]
1856   };
1857
1858   /**
1859    * salt
1860    */
1861
1862   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
1863
1864   const u32 pw_salt_len = salt_len + pw_len;
1865
1866   u32 salt_buf0[16];
1867
1868   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
1869   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
1870   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
1871   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
1872   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
1873   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
1874   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
1875   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
1876   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
1877   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
1878   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
1879   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
1880   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
1881   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
1882   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
1883   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
1884
1885   u32 salt_buf1[16];
1886
1887   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
1888   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
1889   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
1890   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
1891   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
1892   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
1893   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
1894   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
1895   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
1896   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
1897   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
1898   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
1899   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
1900   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
1901   salt_buf1[14] = 0;
1902   salt_buf1[15] = 0;
1903
1904   /**
1905    * esalt
1906    */
1907
1908   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
1909
1910   u32 esalt_buf0[16];
1911
1912   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
1913   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
1914   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
1915   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
1916   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
1917   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
1918   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
1919   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
1920   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
1921   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
1922   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
1923   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
1924   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
1925   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
1926   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
1927   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
1928
1929   u32 esalt_buf1[16];
1930
1931   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
1932   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
1933   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
1934   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
1935   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
1936   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
1937   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
1938   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
1939   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
1940   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
1941   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
1942   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
1943   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
1944   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
1945   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
1946   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
1947
1948   const u32 digest_esalt_len = 32 + esalt_len;
1949
1950   /**
1951    * loop
1952    */
1953
1954   u32x w0l = w0[0];
1955
1956   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
1957   {
1958     const u32 w0r = c_bfs[il_pos].i;
1959
1960     w0[0] = w0l | w0r;
1961
1962     /*
1963      * HA1 = md5 ($salt . $pass)
1964      */
1965
1966     // append the pass to the salt
1967
1968     u32x block0[16];
1969
1970     block0[ 0] = salt_buf0[ 0];
1971     block0[ 1] = salt_buf0[ 1];
1972     block0[ 2] = salt_buf0[ 2];
1973     block0[ 3] = salt_buf0[ 3];
1974     block0[ 4] = salt_buf0[ 4];
1975     block0[ 5] = salt_buf0[ 5];
1976     block0[ 6] = salt_buf0[ 6];
1977     block0[ 7] = salt_buf0[ 7];
1978     block0[ 8] = salt_buf0[ 8];
1979     block0[ 9] = salt_buf0[ 9];
1980     block0[10] = salt_buf0[10];
1981     block0[11] = salt_buf0[11];
1982     block0[12] = salt_buf0[12];
1983     block0[13] = salt_buf0[13];
1984     block0[14] = salt_buf0[14];
1985     block0[15] = salt_buf0[15];
1986
1987     u32x block1[16];
1988
1989     block1[ 0] = salt_buf1[ 0];
1990     block1[ 1] = salt_buf1[ 1];
1991     block1[ 2] = salt_buf1[ 2];
1992     block1[ 3] = salt_buf1[ 3];
1993     block1[ 4] = salt_buf1[ 4];
1994     block1[ 5] = salt_buf1[ 5];
1995     block1[ 6] = salt_buf1[ 6];
1996     block1[ 7] = salt_buf1[ 7];
1997     block1[ 8] = salt_buf1[ 8];
1998     block1[ 9] = salt_buf1[ 9];
1999     block1[10] = salt_buf1[10];
2000     block1[11] = salt_buf1[11];
2001     block1[12] = salt_buf1[12];
2002     block1[13] = salt_buf1[13];
2003     block1[14] = salt_buf1[14];
2004     block1[15] = salt_buf1[15];
2005
2006     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
2007
2008     u32x w0_t[4];
2009
2010     w0_t[0] = block0[ 0];
2011     w0_t[1] = block0[ 1];
2012     w0_t[2] = block0[ 2];
2013     w0_t[3] = block0[ 3];
2014
2015     u32x w1_t[4];
2016
2017     w1_t[0] = block0[ 4];
2018     w1_t[1] = block0[ 5];
2019     w1_t[2] = block0[ 6];
2020     w1_t[3] = block0[ 7];
2021
2022     u32x w2_t[4];
2023
2024     w2_t[0] = block0[ 8];
2025     w2_t[1] = block0[ 9];
2026     w2_t[2] = block0[10];
2027     w2_t[3] = block0[11];
2028
2029     u32x w3_t[4];
2030
2031     w3_t[0] = block0[12];
2032     w3_t[1] = block0[13];
2033     w3_t[2] = block0[14];
2034     w3_t[3] = block0[15];
2035
2036     // md5
2037
2038     u32x tmp2;
2039
2040     u32x a = MD5M_A;
2041     u32x b = MD5M_B;
2042     u32x c = MD5M_C;
2043     u32x d = MD5M_D;
2044
2045     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2046     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2047     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2048     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2049     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2050     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2051     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2052     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2053     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2054     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2055     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2056     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2057     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2058     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2059     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2060     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2061
2062     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2063     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2064     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2065     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2066     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2067     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2068     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2069     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2070     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2071     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2072     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2073     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2074     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2075     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2076     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2077     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2078
2079     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2080     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2081     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2082     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2083     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2084     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2085     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2086     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2087     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2088     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2089     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2090     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2091     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2092     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2093     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2094     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2095
2096     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2097     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2098     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2099     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2100     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2101     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2102     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2103     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2104     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2105     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2106     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2107     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2108     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2109     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2110     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2111     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2112
2113     a += MD5M_A;
2114     b += MD5M_B;
2115     c += MD5M_C;
2116     d += MD5M_D;
2117
2118     u32x r_a = a;
2119     u32x r_b = b;
2120     u32x r_c = c;
2121     u32x r_d = d;
2122
2123     w0_t[0] = block1[ 0];
2124     w0_t[1] = block1[ 1];
2125     w0_t[2] = block1[ 2];
2126     w0_t[3] = block1[ 3];
2127
2128     w1_t[0] = block1[ 4];
2129     w1_t[1] = block1[ 5];
2130     w1_t[2] = block1[ 6];
2131     w1_t[3] = block1[ 7];
2132
2133     w2_t[0] = block1[ 8];
2134     w2_t[1] = block1[ 9];
2135     w2_t[2] = block1[10];
2136     w2_t[3] = block1[11];
2137
2138     w3_t[0] = block1[12];
2139     w3_t[1] = block1[13];
2140     w3_t[2] = pw_salt_len * 8;
2141     w3_t[3] = 0;
2142
2143     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2144     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2145     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2146     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2147     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2148     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2149     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2150     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2151     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2152     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2153     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2154     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2155     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2156     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2157     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2158     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2159
2160     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2161     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2162     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2163     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2164     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2165     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2166     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2167     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2168     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2169     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2170     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2171     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2172     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2173     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2174     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2175     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2176
2177     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2178     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2179     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2180     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2181     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2182     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2183     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2184     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2185     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2186     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2187     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2188     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2189     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2190     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2191     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2192     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2193
2194     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2195     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2196     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2197     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2198     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2199     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2200     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2201     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2202     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2203     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2204     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2205     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2206     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2207     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2208     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2209     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2210
2211     a += r_a;
2212     b += r_b;
2213     c += r_c;
2214     d += r_d;
2215
2216     /*
2217      * final = md5 ($HA1 . $esalt)
2218      * we have at least 2 MD5 blocks/transformations, but we might need 3
2219      */
2220
2221     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
2222             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
2223     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
2224             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
2225     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
2226             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
2227     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
2228             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
2229     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
2230             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
2231     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
2232             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
2233     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
2234             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
2235     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
2236             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
2237
2238     w2_t[0] = esalt_buf0[0];
2239     w2_t[1] = esalt_buf0[1];
2240     w2_t[2] = esalt_buf0[2];
2241     w2_t[3] = esalt_buf0[3];
2242
2243     w3_t[0] = esalt_buf0[4];
2244     w3_t[1] = esalt_buf0[5];
2245     w3_t[2] = esalt_buf0[6];
2246     w3_t[3] = esalt_buf0[7];
2247
2248     // md5
2249     // 1st transform
2250
2251     a = MD5M_A;
2252     b = MD5M_B;
2253     c = MD5M_C;
2254     d = MD5M_D;
2255
2256     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2257     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2258     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2259     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2260     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2261     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2262     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2263     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2264     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2265     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2266     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2267     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2268     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2269     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2270     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2271     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2272
2273     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2274     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2275     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2276     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2277     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2278     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2279     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2280     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2281     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2282     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2283     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2284     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2285     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2286     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2287     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2288     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2289
2290     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2291     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2292     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2293     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2294     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2295     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2296     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2297     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2298     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2299     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2300     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2301     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2302     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2303     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2304     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2305     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2306
2307     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2308     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2309     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2310     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2311     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2312     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2313     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2314     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2315     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2316     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2317     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2318     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2319     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2320     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2321     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2322     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2323
2324     a += MD5M_A;
2325     b += MD5M_B;
2326     c += MD5M_C;
2327     d += MD5M_D;
2328
2329     r_a = a;
2330     r_b = b;
2331     r_c = c;
2332     r_d = d;
2333
2334     // 2nd transform
2335
2336     w0_t[0] = esalt_buf0[ 8];
2337     w0_t[1] = esalt_buf0[ 9];
2338     w0_t[2] = esalt_buf0[10];
2339     w0_t[3] = esalt_buf0[11];
2340
2341     w1_t[0] = esalt_buf0[12];
2342     w1_t[1] = esalt_buf0[13];
2343     w1_t[2] = esalt_buf0[14];
2344     w1_t[3] = esalt_buf0[15];
2345
2346     w2_t[0] = esalt_buf1[ 0];
2347     w2_t[1] = esalt_buf1[ 1];
2348     w2_t[2] = esalt_buf1[ 2];
2349     w2_t[3] = esalt_buf1[ 3];
2350
2351     w3_t[0] = esalt_buf1[ 4];
2352     w3_t[1] = esalt_buf1[ 5];
2353     w3_t[2] = digest_esalt_len * 8;
2354     w3_t[3] = 0;
2355
2356     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2357     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2358     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2359     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2360     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2361     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2362     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2363     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2364     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2365     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2366     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2367     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2368     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2369     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2370     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2371     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2372
2373     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2374     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2375     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2376     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2377     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2378     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2379     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2380     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2381     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2382     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2383     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2384     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2385     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2386     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2387     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2388     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2389
2390     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2391     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2392     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2393     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2394     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2395     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2396     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2397     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2398     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2399     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2400     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2401     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2402     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2403     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2404     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2405     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2406
2407     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2408     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2409     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2410     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2411     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2412     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2413     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2414     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2415     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2416     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2417     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2418     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2419     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2420     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2421     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2422     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2423
2424     a += r_a;
2425     b += r_b;
2426     c += r_c;
2427     d += r_d;
2428
2429     const u32x r0 = a;
2430     const u32x r1 = d;
2431     const u32x r2 = c;
2432     const u32x r3 = b;
2433
2434     #include VECT_COMPARE_S
2435   }
2436 }
2437
2438 __device__ static void m11400m_1_1 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
2439 {
2440   /**
2441    * modifier
2442    */
2443
2444   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
2445   const u32 lid = threadIdx.x;
2446
2447   /**
2448    * digest
2449    */
2450
2451   const u32 search[4] =
2452   {
2453     digests_buf[digests_offset].digest_buf[DGST_R0],
2454     digests_buf[digests_offset].digest_buf[DGST_R1],
2455     digests_buf[digests_offset].digest_buf[DGST_R2],
2456     digests_buf[digests_offset].digest_buf[DGST_R3]
2457   };
2458
2459   /**
2460    * salt
2461    */
2462
2463   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
2464
2465   const u32 pw_salt_len = salt_len + pw_len;
2466
2467   u32 salt_buf0[16];
2468
2469   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
2470   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
2471   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
2472   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
2473   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
2474   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
2475   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
2476   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
2477   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
2478   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
2479   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
2480   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
2481   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
2482   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
2483   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
2484   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
2485
2486   u32 salt_buf1[16];
2487
2488   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
2489   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
2490   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
2491   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
2492   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
2493   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
2494   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
2495   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
2496   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
2497   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
2498   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
2499   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
2500   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
2501   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
2502   salt_buf1[14] = 0;
2503   salt_buf1[15] = 0;
2504
2505   /**
2506    * esalt
2507    */
2508
2509   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
2510
2511   u32 esalt_buf0[16];
2512
2513   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
2514   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
2515   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
2516   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
2517   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
2518   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
2519   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
2520   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
2521   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
2522   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
2523   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
2524   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
2525   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
2526   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
2527   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
2528   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
2529
2530   u32 esalt_buf1[16];
2531
2532   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
2533   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
2534   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
2535   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
2536   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
2537   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
2538   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
2539   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
2540   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
2541   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
2542   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
2543   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
2544   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
2545   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
2546   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
2547   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
2548
2549   u32 esalt_buf2[16];
2550
2551   esalt_buf2[ 0] = esalt_bufs[salt_pos].esalt_buf[32];
2552   esalt_buf2[ 1] = esalt_bufs[salt_pos].esalt_buf[33];
2553   esalt_buf2[ 2] = esalt_bufs[salt_pos].esalt_buf[34];
2554   esalt_buf2[ 3] = esalt_bufs[salt_pos].esalt_buf[35];
2555   esalt_buf2[ 4] = esalt_bufs[salt_pos].esalt_buf[36];
2556   esalt_buf2[ 5] = esalt_bufs[salt_pos].esalt_buf[37];
2557   esalt_buf2[ 6] = 0;
2558   esalt_buf2[ 7] = 0;
2559   esalt_buf2[ 8] = 0;
2560   esalt_buf2[ 9] = 0;
2561   esalt_buf2[10] = 0;
2562   esalt_buf2[11] = 0;
2563   esalt_buf2[12] = 0;
2564   esalt_buf2[13] = 0;
2565   esalt_buf2[14] = 0;
2566   esalt_buf2[15] = 0;
2567
2568   const u32 digest_esalt_len = 32 + esalt_len;
2569
2570   /**
2571    * loop
2572    */
2573
2574   u32x w0l = w0[0];
2575
2576   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
2577   {
2578     const u32 w0r = c_bfs[il_pos].i;
2579
2580     w0[0] = w0l | w0r;
2581
2582     /*
2583      * HA1 = md5 ($salt . $pass)
2584      */
2585
2586     // append the pass to the salt
2587
2588     u32x block0[16];
2589
2590     block0[ 0] = salt_buf0[ 0];
2591     block0[ 1] = salt_buf0[ 1];
2592     block0[ 2] = salt_buf0[ 2];
2593     block0[ 3] = salt_buf0[ 3];
2594     block0[ 4] = salt_buf0[ 4];
2595     block0[ 5] = salt_buf0[ 5];
2596     block0[ 6] = salt_buf0[ 6];
2597     block0[ 7] = salt_buf0[ 7];
2598     block0[ 8] = salt_buf0[ 8];
2599     block0[ 9] = salt_buf0[ 9];
2600     block0[10] = salt_buf0[10];
2601     block0[11] = salt_buf0[11];
2602     block0[12] = salt_buf0[12];
2603     block0[13] = salt_buf0[13];
2604     block0[14] = salt_buf0[14];
2605     block0[15] = salt_buf0[15];
2606
2607     u32x block1[16];
2608
2609     block1[ 0] = salt_buf1[ 0];
2610     block1[ 1] = salt_buf1[ 1];
2611     block1[ 2] = salt_buf1[ 2];
2612     block1[ 3] = salt_buf1[ 3];
2613     block1[ 4] = salt_buf1[ 4];
2614     block1[ 5] = salt_buf1[ 5];
2615     block1[ 6] = salt_buf1[ 6];
2616     block1[ 7] = salt_buf1[ 7];
2617     block1[ 8] = salt_buf1[ 8];
2618     block1[ 9] = salt_buf1[ 9];
2619     block1[10] = salt_buf1[10];
2620     block1[11] = salt_buf1[11];
2621     block1[12] = salt_buf1[12];
2622     block1[13] = salt_buf1[13];
2623     block1[14] = salt_buf1[14];
2624     block1[15] = salt_buf1[15];
2625
2626     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
2627
2628     u32x w0_t[4];
2629
2630     w0_t[0] = block0[ 0];
2631     w0_t[1] = block0[ 1];
2632     w0_t[2] = block0[ 2];
2633     w0_t[3] = block0[ 3];
2634
2635     u32x w1_t[4];
2636
2637     w1_t[0] = block0[ 4];
2638     w1_t[1] = block0[ 5];
2639     w1_t[2] = block0[ 6];
2640     w1_t[3] = block0[ 7];
2641
2642     u32x w2_t[4];
2643
2644     w2_t[0] = block0[ 8];
2645     w2_t[1] = block0[ 9];
2646     w2_t[2] = block0[10];
2647     w2_t[3] = block0[11];
2648
2649     u32x w3_t[4];
2650
2651     w3_t[0] = block0[12];
2652     w3_t[1] = block0[13];
2653     w3_t[2] = block0[14];
2654     w3_t[3] = block0[15];
2655
2656     // md5
2657
2658     u32x tmp2;
2659
2660     u32x a = MD5M_A;
2661     u32x b = MD5M_B;
2662     u32x c = MD5M_C;
2663     u32x d = MD5M_D;
2664
2665     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2666     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2667     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2668     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2669     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2670     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2671     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2672     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2673     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2674     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2675     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2676     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2677     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2678     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2679     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2680     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2681
2682     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2683     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2684     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2685     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2686     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2687     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2688     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2689     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2690     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2691     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2692     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2693     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2694     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2695     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2696     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2697     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2698
2699     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2700     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2701     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2702     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2703     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2704     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2705     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2706     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2707     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2708     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2709     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2710     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2711     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2712     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2713     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2714     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2715
2716     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2717     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2718     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2719     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2720     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2721     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2722     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2723     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2724     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2725     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2726     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2727     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2728     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2729     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2730     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2731     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2732
2733     a += MD5M_A;
2734     b += MD5M_B;
2735     c += MD5M_C;
2736     d += MD5M_D;
2737
2738     u32x r_a = a;
2739     u32x r_b = b;
2740     u32x r_c = c;
2741     u32x r_d = d;
2742
2743     w0_t[0] = block1[ 0];
2744     w0_t[1] = block1[ 1];
2745     w0_t[2] = block1[ 2];
2746     w0_t[3] = block1[ 3];
2747
2748     w1_t[0] = block1[ 4];
2749     w1_t[1] = block1[ 5];
2750     w1_t[2] = block1[ 6];
2751     w1_t[3] = block1[ 7];
2752
2753     w2_t[0] = block1[ 8];
2754     w2_t[1] = block1[ 9];
2755     w2_t[2] = block1[10];
2756     w2_t[3] = block1[11];
2757
2758     w3_t[0] = block1[12];
2759     w3_t[1] = block1[13];
2760     w3_t[2] = pw_salt_len * 8;
2761     w3_t[3] = 0;
2762
2763     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2764     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2765     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2766     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2767     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2768     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2769     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2770     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2771     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2772     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2773     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2774     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2775     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2776     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2777     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2778     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2779
2780     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2781     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2782     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2783     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2784     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2785     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2786     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2787     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2788     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2789     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2790     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2791     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2792     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2793     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2794     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2795     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2796
2797     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2798     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2799     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2800     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2801     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2802     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2803     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2804     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2805     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2806     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2807     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2808     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2809     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2810     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2811     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2812     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2813
2814     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2815     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2816     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2817     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2818     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2819     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2820     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2821     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2822     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2823     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2824     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2825     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2826     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2827     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2828     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2829     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2830
2831     a += r_a;
2832     b += r_b;
2833     c += r_c;
2834     d += r_d;
2835
2836     /*
2837      * final = md5 ($HA1 . $esalt)
2838      * we have at least 2 MD5 blocks/transformations, but we might need 3
2839      */
2840
2841     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
2842             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
2843     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
2844             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
2845     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
2846             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
2847     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
2848             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
2849     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
2850             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
2851     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
2852             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
2853     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
2854             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
2855     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
2856             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
2857
2858     w2_t[0] = esalt_buf0[0];
2859     w2_t[1] = esalt_buf0[1];
2860     w2_t[2] = esalt_buf0[2];
2861     w2_t[3] = esalt_buf0[3];
2862
2863     w3_t[0] = esalt_buf0[4];
2864     w3_t[1] = esalt_buf0[5];
2865     w3_t[2] = esalt_buf0[6];
2866     w3_t[3] = esalt_buf0[7];
2867
2868     // md5
2869     // 1st transform
2870
2871     a = MD5M_A;
2872     b = MD5M_B;
2873     c = MD5M_C;
2874     d = MD5M_D;
2875
2876     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2877     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2878     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2879     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2880     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2881     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2882     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2883     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2884     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2885     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2886     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2887     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2888     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2889     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2890     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2891     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2892
2893     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2894     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2895     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2896     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2897     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2898     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2899     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
2900     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
2901     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
2902     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
2903     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
2904     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
2905     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
2906     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
2907     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
2908     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
2909
2910     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
2911     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
2912     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
2913     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
2914     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
2915     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
2916     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
2917     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
2918     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
2919     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
2920     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
2921     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
2922     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
2923     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
2924     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
2925     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
2926
2927     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
2928     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
2929     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
2930     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
2931     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
2932     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
2933     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
2934     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
2935     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
2936     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
2937     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
2938     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
2939     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
2940     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
2941     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
2942     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
2943
2944     a += MD5M_A;
2945     b += MD5M_B;
2946     c += MD5M_C;
2947     d += MD5M_D;
2948
2949     r_a = a;
2950     r_b = b;
2951     r_c = c;
2952     r_d = d;
2953
2954     // 2nd transform
2955
2956     w0_t[0] = esalt_buf0[ 8];
2957     w0_t[1] = esalt_buf0[ 9];
2958     w0_t[2] = esalt_buf0[10];
2959     w0_t[3] = esalt_buf0[11];
2960
2961     w1_t[0] = esalt_buf0[12];
2962     w1_t[1] = esalt_buf0[13];
2963     w1_t[2] = esalt_buf0[14];
2964     w1_t[3] = esalt_buf0[15];
2965
2966     w2_t[0] = esalt_buf1[ 0];
2967     w2_t[1] = esalt_buf1[ 1];
2968     w2_t[2] = esalt_buf1[ 2];
2969     w2_t[3] = esalt_buf1[ 3];
2970
2971     w3_t[0] = esalt_buf1[ 4];
2972     w3_t[1] = esalt_buf1[ 5];
2973     w3_t[2] = esalt_buf1[ 6];
2974     w3_t[3] = esalt_buf1[ 7];
2975
2976     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
2977     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
2978     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
2979     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
2980     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
2981     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
2982     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
2983     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
2984     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
2985     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
2986     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
2987     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
2988     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
2989     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
2990     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
2991     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
2992
2993     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
2994     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
2995     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
2996     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
2997     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
2998     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
2999     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
3000     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
3001     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
3002     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
3003     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
3004     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
3005     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
3006     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
3007     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
3008     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
3009
3010     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
3011     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
3012     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
3013     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
3014     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
3015     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
3016     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
3017     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
3018     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
3019     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
3020     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
3021     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
3022     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
3023     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
3024     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
3025     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
3026
3027     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
3028     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
3029     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
3030     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
3031     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
3032     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
3033     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
3034     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
3035     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
3036     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
3037     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
3038     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
3039     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
3040     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
3041     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
3042     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
3043
3044     // this is for sure the final block
3045
3046     a += r_a;
3047     b += r_b;
3048     c += r_c;
3049     d += r_d;
3050
3051     r_a = a;
3052     r_b = b;
3053     r_c = c;
3054     r_d = d;
3055
3056     w0_t[0] = esalt_buf1[ 8];
3057     w0_t[1] = esalt_buf1[ 9];
3058     w0_t[2] = esalt_buf1[10];
3059     w0_t[3] = esalt_buf1[11];
3060
3061     w1_t[0] = esalt_buf1[12];
3062     w1_t[1] = esalt_buf1[13];
3063     w1_t[2] = esalt_buf1[14];
3064     w1_t[3] = esalt_buf1[15];
3065
3066     w2_t[0] = esalt_buf2[ 0];
3067     w2_t[1] = esalt_buf2[ 1];
3068     w2_t[2] = esalt_buf2[ 2];
3069     w2_t[3] = esalt_buf2[ 3];
3070
3071     w3_t[0] = esalt_buf2[ 4];
3072     w3_t[1] = esalt_buf2[ 5];
3073     w3_t[2] = digest_esalt_len * 8;
3074     w3_t[3] = 0;
3075
3076     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
3077     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
3078     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
3079     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
3080     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
3081     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
3082     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
3083     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
3084     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
3085     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
3086     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
3087     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
3088     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
3089     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
3090     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
3091     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
3092
3093     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
3094     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
3095     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
3096     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
3097     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
3098     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
3099     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
3100     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
3101     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
3102     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
3103     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
3104     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
3105     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
3106     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
3107     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
3108     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
3109
3110     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
3111     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
3112     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
3113     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
3114     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
3115     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
3116     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
3117     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
3118     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
3119     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
3120     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
3121     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
3122     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
3123     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
3124     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
3125     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
3126
3127     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
3128     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
3129     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
3130     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
3131     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
3132     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
3133     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
3134     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
3135     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
3136     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
3137     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
3138     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
3139     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
3140     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
3141     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
3142     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
3143
3144     a += r_a;
3145     b += r_b;
3146     c += r_c;
3147     d += r_d;
3148
3149     const u32x r0 = a;
3150     const u32x r1 = d;
3151     const u32x r2 = c;
3152     const u32x r3 = b;
3153
3154     #include VECT_COMPARE_S
3155   }
3156 }
3157
3158 __device__ static void m11400s_0_0 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
3159 {
3160   /**
3161    * modifier
3162    */
3163
3164   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
3165   const u32 lid = threadIdx.x;
3166
3167   /**
3168    * digest
3169    */
3170
3171   const u32 search[4] =
3172   {
3173     digests_buf[digests_offset].digest_buf[DGST_R0],
3174     digests_buf[digests_offset].digest_buf[DGST_R1],
3175     digests_buf[digests_offset].digest_buf[DGST_R2],
3176     digests_buf[digests_offset].digest_buf[DGST_R3]
3177   };
3178
3179   /**
3180    * salt
3181    */
3182
3183   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
3184
3185   const u32 pw_salt_len = salt_len + pw_len;
3186
3187   u32 salt_buf0[16];
3188
3189   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
3190   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
3191   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
3192   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
3193   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
3194   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
3195   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
3196   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
3197   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
3198   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
3199   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
3200   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
3201   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
3202   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
3203   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
3204   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
3205
3206   u32 salt_buf1[16];
3207
3208   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
3209   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
3210   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
3211   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
3212   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
3213   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
3214   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
3215   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
3216   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
3217   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
3218   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
3219   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
3220   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
3221   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
3222   salt_buf1[14] = 0;
3223   salt_buf1[15] = 0;
3224
3225   /**
3226    * esalt
3227    */
3228
3229   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
3230
3231   u32 esalt_buf0[16];
3232
3233   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
3234   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
3235   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
3236   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
3237   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
3238   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
3239   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
3240   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
3241   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
3242   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
3243   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
3244   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
3245   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
3246   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
3247   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
3248   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
3249
3250   u32 esalt_buf1[16];
3251
3252   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
3253   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
3254   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
3255   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
3256   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
3257   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
3258   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
3259   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
3260   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
3261   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
3262   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
3263   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
3264   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
3265   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
3266   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
3267   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
3268
3269   const u32 digest_esalt_len = 32 + esalt_len;
3270
3271   /**
3272    * loop
3273    */
3274
3275   u32x w0l = w0[0];
3276
3277   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
3278   {
3279     const u32 w0r = c_bfs[il_pos].i;
3280
3281     w0[0] = w0l | w0r;
3282
3283     /*
3284      * HA1 = md5 ($salt . $pass)
3285      */
3286
3287     // append the pass to the salt
3288
3289     u32x block0[16];
3290
3291     block0[ 0] = salt_buf0[ 0];
3292     block0[ 1] = salt_buf0[ 1];
3293     block0[ 2] = salt_buf0[ 2];
3294     block0[ 3] = salt_buf0[ 3];
3295     block0[ 4] = salt_buf0[ 4];
3296     block0[ 5] = salt_buf0[ 5];
3297     block0[ 6] = salt_buf0[ 6];
3298     block0[ 7] = salt_buf0[ 7];
3299     block0[ 8] = salt_buf0[ 8];
3300     block0[ 9] = salt_buf0[ 9];
3301     block0[10] = salt_buf0[10];
3302     block0[11] = salt_buf0[11];
3303     block0[12] = salt_buf0[12];
3304     block0[13] = salt_buf0[13];
3305     block0[14] = salt_buf0[14];
3306     block0[15] = salt_buf0[15];
3307
3308     u32x block1[16];
3309
3310     block1[ 0] = salt_buf1[ 0];
3311     block1[ 1] = salt_buf1[ 1];
3312     block1[ 2] = salt_buf1[ 2];
3313     block1[ 3] = salt_buf1[ 3];
3314     block1[ 4] = salt_buf1[ 4];
3315     block1[ 5] = salt_buf1[ 5];
3316     block1[ 6] = salt_buf1[ 6];
3317     block1[ 7] = salt_buf1[ 7];
3318     block1[ 8] = salt_buf1[ 8];
3319     block1[ 9] = salt_buf1[ 9];
3320     block1[10] = salt_buf1[10];
3321     block1[11] = salt_buf1[11];
3322     block1[12] = salt_buf1[12];
3323     block1[13] = salt_buf1[13];
3324     block1[14] = salt_buf1[14];
3325     block1[15] = salt_buf1[15];
3326
3327     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
3328
3329     u32x w0_t[4];
3330
3331     w0_t[0] = block0[ 0];
3332     w0_t[1] = block0[ 1];
3333     w0_t[2] = block0[ 2];
3334     w0_t[3] = block0[ 3];
3335
3336     u32x w1_t[4];
3337
3338     w1_t[0] = block0[ 4];
3339     w1_t[1] = block0[ 5];
3340     w1_t[2] = block0[ 6];
3341     w1_t[3] = block0[ 7];
3342
3343     u32x w2_t[4];
3344
3345     w2_t[0] = block0[ 8];
3346     w2_t[1] = block0[ 9];
3347     w2_t[2] = block0[10];
3348     w2_t[3] = block0[11];
3349
3350     u32x w3_t[4];
3351
3352     w3_t[0] = block0[12];
3353     w3_t[1] = block0[13];
3354     w3_t[2] = pw_salt_len * 8;
3355     w3_t[3] = 0;
3356
3357     // md5
3358
3359     u32x tmp2;
3360
3361     u32x a = MD5M_A;
3362     u32x b = MD5M_B;
3363     u32x c = MD5M_C;
3364     u32x d = MD5M_D;
3365
3366     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
3367     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
3368     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
3369     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
3370     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
3371     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
3372     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
3373     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
3374     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
3375     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
3376     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
3377     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
3378     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
3379     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
3380     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
3381     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
3382
3383     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
3384     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
3385     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
3386     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
3387     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
3388     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
3389     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
3390     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
3391     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
3392     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
3393     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
3394     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
3395     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
3396     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
3397     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
3398     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
3399
3400     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
3401     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
3402     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
3403     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
3404     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
3405     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
3406     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
3407     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
3408     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
3409     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
3410     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
3411     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
3412     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
3413     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
3414     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
3415     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
3416
3417     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
3418     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
3419     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
3420     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
3421     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
3422     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
3423     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
3424     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
3425     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
3426     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
3427     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
3428     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
3429     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
3430     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
3431     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
3432     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
3433
3434     a += MD5M_A;
3435     b += MD5M_B;
3436     c += MD5M_C;
3437     d += MD5M_D;
3438
3439     /*
3440      * final = md5 ($HA1 . $esalt)
3441      * we have at least 2 MD5 blocks/transformations, but we might need 3
3442      */
3443
3444     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
3445             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
3446     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
3447             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
3448     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
3449             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
3450     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
3451             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
3452     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
3453             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
3454     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
3455             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
3456     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
3457             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
3458     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
3459             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
3460
3461     w2_t[0] = esalt_buf0[0];
3462     w2_t[1] = esalt_buf0[1];
3463     w2_t[2] = esalt_buf0[2];
3464     w2_t[3] = esalt_buf0[3];
3465
3466     w3_t[0] = esalt_buf0[4];
3467     w3_t[1] = esalt_buf0[5];
3468     w3_t[2] = esalt_buf0[6];
3469     w3_t[3] = esalt_buf0[7];
3470
3471     // md5
3472     // 1st transform
3473
3474     a = MD5M_A;
3475     b = MD5M_B;
3476     c = MD5M_C;
3477     d = MD5M_D;
3478
3479     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
3480     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
3481     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
3482     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
3483     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
3484     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
3485     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
3486     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
3487     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
3488     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
3489     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
3490     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
3491     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
3492     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
3493     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
3494     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
3495
3496     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
3497     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
3498     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
3499     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
3500     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
3501     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
3502     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
3503     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
3504     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
3505     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
3506     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
3507     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
3508     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
3509     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
3510     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
3511     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
3512
3513     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
3514     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
3515     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
3516     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
3517     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
3518     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
3519     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
3520     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
3521     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
3522     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
3523     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
3524     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
3525     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
3526     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
3527     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
3528     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
3529
3530     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
3531     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
3532     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
3533     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
3534     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
3535     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
3536     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
3537     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
3538     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
3539     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
3540     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
3541     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
3542     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
3543     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
3544     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
3545     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
3546
3547     a += MD5M_A;
3548     b += MD5M_B;
3549     c += MD5M_C;
3550     d += MD5M_D;
3551
3552     u32x r_a = a;
3553     u32x r_b = b;
3554     u32x r_c = c;
3555     u32x r_d = d;
3556
3557     // 2nd transform
3558
3559     w0_t[0] = esalt_buf0[ 8];
3560     w0_t[1] = esalt_buf0[ 9];
3561     w0_t[2] = esalt_buf0[10];
3562     w0_t[3] = esalt_buf0[11];
3563
3564     w1_t[0] = esalt_buf0[12];
3565     w1_t[1] = esalt_buf0[13];
3566     w1_t[2] = esalt_buf0[14];
3567     w1_t[3] = esalt_buf0[15];
3568
3569     w2_t[0] = esalt_buf1[ 0];
3570     w2_t[1] = esalt_buf1[ 1];
3571     w2_t[2] = esalt_buf1[ 2];
3572     w2_t[3] = esalt_buf1[ 3];
3573
3574     w3_t[0] = esalt_buf1[ 4];
3575     w3_t[1] = esalt_buf1[ 5];
3576     w3_t[2] = digest_esalt_len * 8;
3577     w3_t[3] = 0;
3578
3579     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
3580     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
3581     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
3582     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
3583     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
3584     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
3585     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
3586     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
3587     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
3588     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
3589     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
3590     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
3591     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
3592     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
3593     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
3594     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
3595
3596     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
3597     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
3598     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
3599     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
3600     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
3601     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
3602     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
3603     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
3604     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
3605     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
3606     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
3607     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
3608     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
3609     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
3610     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
3611     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
3612
3613     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
3614     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
3615     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
3616     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
3617     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
3618     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
3619     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
3620     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
3621     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
3622     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
3623     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
3624     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
3625     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
3626     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
3627     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
3628     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
3629
3630     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
3631     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
3632     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
3633     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
3634     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
3635     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
3636     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
3637     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
3638     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
3639     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
3640     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
3641     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
3642     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
3643     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
3644     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
3645     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
3646
3647     a += r_a;
3648     b += r_b;
3649     c += r_c;
3650     d += r_d;
3651
3652     const u32x r0 = a;
3653     const u32x r1 = d;
3654     const u32x r2 = c;
3655     const u32x r3 = b;
3656
3657     #include VECT_COMPARE_S
3658   }
3659 }
3660
3661 __device__ static void m11400s_0_1 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
3662 {
3663   /**
3664    * modifier
3665    */
3666
3667   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
3668   const u32 lid = threadIdx.x;
3669
3670   /**
3671    * digest
3672    */
3673
3674   const u32 search[4] =
3675   {
3676     digests_buf[digests_offset].digest_buf[DGST_R0],
3677     digests_buf[digests_offset].digest_buf[DGST_R1],
3678     digests_buf[digests_offset].digest_buf[DGST_R2],
3679     digests_buf[digests_offset].digest_buf[DGST_R3]
3680   };
3681
3682   /**
3683    * salt
3684    */
3685
3686   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
3687
3688   const u32 pw_salt_len = salt_len + pw_len;
3689
3690   u32 salt_buf0[16];
3691
3692   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
3693   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
3694   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
3695   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
3696   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
3697   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
3698   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
3699   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
3700   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
3701   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
3702   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
3703   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
3704   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
3705   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
3706   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
3707   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
3708
3709   u32 salt_buf1[16];
3710
3711   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
3712   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
3713   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
3714   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
3715   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
3716   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
3717   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
3718   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
3719   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
3720   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
3721   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
3722   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
3723   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
3724   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
3725   salt_buf1[14] = 0;
3726   salt_buf1[15] = 0;
3727
3728   /**
3729    * esalt
3730    */
3731
3732   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
3733
3734   u32 esalt_buf0[16];
3735
3736   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
3737   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
3738   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
3739   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
3740   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
3741   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
3742   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
3743   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
3744   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
3745   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
3746   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
3747   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
3748   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
3749   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
3750   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
3751   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
3752
3753   u32 esalt_buf1[16];
3754
3755   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
3756   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
3757   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
3758   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
3759   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
3760   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
3761   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
3762   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
3763   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
3764   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
3765   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
3766   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
3767   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
3768   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
3769   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
3770   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
3771
3772   u32 esalt_buf2[16];
3773
3774   esalt_buf2[ 0] = esalt_bufs[salt_pos].esalt_buf[32];
3775   esalt_buf2[ 1] = esalt_bufs[salt_pos].esalt_buf[33];
3776   esalt_buf2[ 2] = esalt_bufs[salt_pos].esalt_buf[34];
3777   esalt_buf2[ 3] = esalt_bufs[salt_pos].esalt_buf[35];
3778   esalt_buf2[ 4] = esalt_bufs[salt_pos].esalt_buf[36];
3779   esalt_buf2[ 5] = esalt_bufs[salt_pos].esalt_buf[37];
3780   esalt_buf2[ 6] = 0;
3781   esalt_buf2[ 7] = 0;
3782   esalt_buf2[ 8] = 0;
3783   esalt_buf2[ 9] = 0;
3784   esalt_buf2[10] = 0;
3785   esalt_buf2[11] = 0;
3786   esalt_buf2[12] = 0;
3787   esalt_buf2[13] = 0;
3788   esalt_buf2[14] = 0;
3789   esalt_buf2[15] = 0;
3790
3791   const u32 digest_esalt_len = 32 + esalt_len;
3792
3793   /**
3794    * loop
3795    */
3796
3797   u32x w0l = w0[0];
3798
3799   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
3800   {
3801     const u32 w0r = c_bfs[il_pos].i;
3802
3803     w0[0] = w0l | w0r;
3804
3805     /*
3806      * HA1 = md5 ($salt . $pass)
3807      */
3808
3809     // append the pass to the salt
3810
3811     u32x block0[16];
3812
3813     block0[ 0] = salt_buf0[ 0];
3814     block0[ 1] = salt_buf0[ 1];
3815     block0[ 2] = salt_buf0[ 2];
3816     block0[ 3] = salt_buf0[ 3];
3817     block0[ 4] = salt_buf0[ 4];
3818     block0[ 5] = salt_buf0[ 5];
3819     block0[ 6] = salt_buf0[ 6];
3820     block0[ 7] = salt_buf0[ 7];
3821     block0[ 8] = salt_buf0[ 8];
3822     block0[ 9] = salt_buf0[ 9];
3823     block0[10] = salt_buf0[10];
3824     block0[11] = salt_buf0[11];
3825     block0[12] = salt_buf0[12];
3826     block0[13] = salt_buf0[13];
3827     block0[14] = salt_buf0[14];
3828     block0[15] = salt_buf0[15];
3829
3830     u32x block1[16];
3831
3832     block1[ 0] = salt_buf1[ 0];
3833     block1[ 1] = salt_buf1[ 1];
3834     block1[ 2] = salt_buf1[ 2];
3835     block1[ 3] = salt_buf1[ 3];
3836     block1[ 4] = salt_buf1[ 4];
3837     block1[ 5] = salt_buf1[ 5];
3838     block1[ 6] = salt_buf1[ 6];
3839     block1[ 7] = salt_buf1[ 7];
3840     block1[ 8] = salt_buf1[ 8];
3841     block1[ 9] = salt_buf1[ 9];
3842     block1[10] = salt_buf1[10];
3843     block1[11] = salt_buf1[11];
3844     block1[12] = salt_buf1[12];
3845     block1[13] = salt_buf1[13];
3846     block1[14] = salt_buf1[14];
3847     block1[15] = salt_buf1[15];
3848
3849     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
3850
3851     u32x w0_t[4];
3852
3853     w0_t[0] = block0[ 0];
3854     w0_t[1] = block0[ 1];
3855     w0_t[2] = block0[ 2];
3856     w0_t[3] = block0[ 3];
3857
3858     u32x w1_t[4];
3859
3860     w1_t[0] = block0[ 4];
3861     w1_t[1] = block0[ 5];
3862     w1_t[2] = block0[ 6];
3863     w1_t[3] = block0[ 7];
3864
3865     u32x w2_t[4];
3866
3867     w2_t[0] = block0[ 8];
3868     w2_t[1] = block0[ 9];
3869     w2_t[2] = block0[10];
3870     w2_t[3] = block0[11];
3871
3872     u32x w3_t[4];
3873
3874     w3_t[0] = block0[12];
3875     w3_t[1] = block0[13];
3876     w3_t[2] = pw_salt_len * 8;
3877     w3_t[3] = 0;
3878
3879     // md5
3880
3881     u32x tmp2;
3882
3883     u32x a = MD5M_A;
3884     u32x b = MD5M_B;
3885     u32x c = MD5M_C;
3886     u32x d = MD5M_D;
3887
3888     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
3889     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
3890     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
3891     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
3892     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
3893     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
3894     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
3895     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
3896     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
3897     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
3898     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
3899     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
3900     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
3901     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
3902     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
3903     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
3904
3905     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
3906     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
3907     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
3908     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
3909     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
3910     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
3911     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
3912     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
3913     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
3914     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
3915     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
3916     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
3917     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
3918     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
3919     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
3920     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
3921
3922     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
3923     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
3924     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
3925     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
3926     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
3927     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
3928     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
3929     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
3930     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
3931     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
3932     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
3933     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
3934     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
3935     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
3936     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
3937     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
3938
3939     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
3940     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
3941     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
3942     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
3943     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
3944     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
3945     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
3946     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
3947     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
3948     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
3949     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
3950     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
3951     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
3952     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
3953     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
3954     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
3955
3956     a += MD5M_A;
3957     b += MD5M_B;
3958     c += MD5M_C;
3959     d += MD5M_D;
3960
3961     /*
3962      * final = md5 ($HA1 . $esalt)
3963      * we have at least 2 MD5 blocks/transformations, but we might need 3
3964      */
3965
3966     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
3967             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
3968     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
3969             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
3970     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
3971             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
3972     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
3973             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
3974     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
3975             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
3976     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
3977             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
3978     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
3979             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
3980     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
3981             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
3982
3983     w2_t[0] = esalt_buf0[0];
3984     w2_t[1] = esalt_buf0[1];
3985     w2_t[2] = esalt_buf0[2];
3986     w2_t[3] = esalt_buf0[3];
3987
3988     w3_t[0] = esalt_buf0[4];
3989     w3_t[1] = esalt_buf0[5];
3990     w3_t[2] = esalt_buf0[6];
3991     w3_t[3] = esalt_buf0[7];
3992
3993     // md5
3994     // 1st transform
3995
3996     a = MD5M_A;
3997     b = MD5M_B;
3998     c = MD5M_C;
3999     d = MD5M_D;
4000
4001     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4002     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4003     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4004     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4005     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4006     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4007     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4008     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4009     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4010     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4011     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4012     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4013     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4014     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4015     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4016     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4017
4018     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4019     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4020     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4021     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4022     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4023     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4024     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4025     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4026     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4027     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4028     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4029     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4030     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4031     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4032     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4033     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4034
4035     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4036     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4037     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4038     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4039     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4040     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4041     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4042     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4043     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4044     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4045     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4046     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4047     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4048     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4049     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4050     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4051
4052     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4053     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4054     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4055     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4056     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4057     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4058     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4059     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4060     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4061     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4062     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4063     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4064     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4065     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4066     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4067     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4068
4069     a += MD5M_A;
4070     b += MD5M_B;
4071     c += MD5M_C;
4072     d += MD5M_D;
4073
4074     u32x r_a = a;
4075     u32x r_b = b;
4076     u32x r_c = c;
4077     u32x r_d = d;
4078
4079     // 2nd transform
4080
4081     w0_t[0] = esalt_buf0[ 8];
4082     w0_t[1] = esalt_buf0[ 9];
4083     w0_t[2] = esalt_buf0[10];
4084     w0_t[3] = esalt_buf0[11];
4085
4086     w1_t[0] = esalt_buf0[12];
4087     w1_t[1] = esalt_buf0[13];
4088     w1_t[2] = esalt_buf0[14];
4089     w1_t[3] = esalt_buf0[15];
4090
4091     w2_t[0] = esalt_buf1[ 0];
4092     w2_t[1] = esalt_buf1[ 1];
4093     w2_t[2] = esalt_buf1[ 2];
4094     w2_t[3] = esalt_buf1[ 3];
4095
4096     w3_t[0] = esalt_buf1[ 4];
4097     w3_t[1] = esalt_buf1[ 5];
4098     w3_t[2] = esalt_buf1[ 6];
4099     w3_t[3] = esalt_buf1[ 7];
4100
4101     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4102     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4103     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4104     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4105     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4106     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4107     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4108     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4109     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4110     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4111     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4112     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4113     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4114     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4115     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4116     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4117
4118     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4119     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4120     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4121     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4122     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4123     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4124     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4125     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4126     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4127     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4128     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4129     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4130     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4131     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4132     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4133     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4134
4135     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4136     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4137     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4138     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4139     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4140     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4141     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4142     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4143     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4144     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4145     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4146     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4147     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4148     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4149     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4150     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4151
4152     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4153     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4154     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4155     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4156     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4157     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4158     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4159     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4160     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4161     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4162     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4163     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4164     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4165     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4166     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4167     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4168
4169     // this is for sure the final block
4170
4171     a += r_a;
4172     b += r_b;
4173     c += r_c;
4174     d += r_d;
4175
4176     r_a = a;
4177     r_b = b;
4178     r_c = c;
4179     r_d = d;
4180
4181     w0_t[0] = esalt_buf1[ 8];
4182     w0_t[1] = esalt_buf1[ 9];
4183     w0_t[2] = esalt_buf1[10];
4184     w0_t[3] = esalt_buf1[11];
4185
4186     w1_t[0] = esalt_buf1[12];
4187     w1_t[1] = esalt_buf1[13];
4188     w1_t[2] = esalt_buf1[14];
4189     w1_t[3] = esalt_buf1[15];
4190
4191     w2_t[0] = esalt_buf2[ 0];
4192     w2_t[1] = esalt_buf2[ 1];
4193     w2_t[2] = esalt_buf2[ 2];
4194     w2_t[3] = esalt_buf2[ 3];
4195
4196     w3_t[0] = esalt_buf2[ 4];
4197     w3_t[1] = esalt_buf2[ 5];
4198     w3_t[2] = digest_esalt_len * 8;
4199     w3_t[3] = 0;
4200
4201     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4202     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4203     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4204     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4205     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4206     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4207     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4208     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4209     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4210     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4211     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4212     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4213     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4214     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4215     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4216     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4217
4218     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4219     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4220     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4221     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4222     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4223     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4224     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4225     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4226     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4227     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4228     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4229     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4230     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4231     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4232     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4233     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4234
4235     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4236     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4237     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4238     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4239     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4240     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4241     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4242     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4243     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4244     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4245     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4246     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4247     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4248     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4249     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4250     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4251
4252     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4253     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4254     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4255     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4256     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4257     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4258     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4259     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4260     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4261     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4262     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4263     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4264     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4265     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4266     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4267     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4268
4269     a += r_a;
4270     b += r_b;
4271     c += r_c;
4272     d += r_d;
4273
4274     const u32x r0 = a;
4275     const u32x r1 = d;
4276     const u32x r2 = c;
4277     const u32x r3 = b;
4278
4279     #include VECT_COMPARE_S
4280   }
4281 }
4282
4283 __device__ static void m11400s_1_0 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
4284 {
4285   /**
4286    * modifier
4287    */
4288
4289   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
4290   const u32 lid = threadIdx.x;
4291
4292   /**
4293    * digest
4294    */
4295
4296   const u32 search[4] =
4297   {
4298     digests_buf[digests_offset].digest_buf[DGST_R0],
4299     digests_buf[digests_offset].digest_buf[DGST_R1],
4300     digests_buf[digests_offset].digest_buf[DGST_R2],
4301     digests_buf[digests_offset].digest_buf[DGST_R3]
4302   };
4303
4304   /**
4305    * salt
4306    */
4307
4308   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
4309
4310   const u32 pw_salt_len = salt_len + pw_len;
4311
4312   u32 salt_buf0[16];
4313
4314   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
4315   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
4316   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
4317   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
4318   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
4319   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
4320   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
4321   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
4322   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
4323   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
4324   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
4325   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
4326   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
4327   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
4328   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
4329   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
4330
4331   u32 salt_buf1[16];
4332
4333   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
4334   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
4335   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
4336   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
4337   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
4338   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
4339   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
4340   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
4341   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
4342   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
4343   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
4344   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
4345   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
4346   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
4347   salt_buf1[14] = 0;
4348   salt_buf1[15] = 0;
4349
4350   /**
4351    * esalt
4352    */
4353
4354   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
4355
4356   u32 esalt_buf0[16];
4357
4358   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
4359   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
4360   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
4361   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
4362   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
4363   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
4364   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
4365   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
4366   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
4367   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
4368   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
4369   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
4370   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
4371   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
4372   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
4373   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
4374
4375   u32 esalt_buf1[16];
4376
4377   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
4378   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
4379   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
4380   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
4381   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
4382   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
4383   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
4384   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
4385   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
4386   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
4387   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
4388   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
4389   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
4390   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
4391   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
4392   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
4393
4394   const u32 digest_esalt_len = 32 + esalt_len;
4395
4396   /**
4397    * loop
4398    */
4399
4400   u32x w0l = w0[0];
4401
4402   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
4403   {
4404     const u32 w0r = c_bfs[il_pos].i;
4405
4406     w0[0] = w0l | w0r;
4407
4408     /*
4409      * HA1 = md5 ($salt . $pass)
4410      */
4411
4412     // append the pass to the salt
4413
4414     u32x block0[16];
4415
4416     block0[ 0] = salt_buf0[ 0];
4417     block0[ 1] = salt_buf0[ 1];
4418     block0[ 2] = salt_buf0[ 2];
4419     block0[ 3] = salt_buf0[ 3];
4420     block0[ 4] = salt_buf0[ 4];
4421     block0[ 5] = salt_buf0[ 5];
4422     block0[ 6] = salt_buf0[ 6];
4423     block0[ 7] = salt_buf0[ 7];
4424     block0[ 8] = salt_buf0[ 8];
4425     block0[ 9] = salt_buf0[ 9];
4426     block0[10] = salt_buf0[10];
4427     block0[11] = salt_buf0[11];
4428     block0[12] = salt_buf0[12];
4429     block0[13] = salt_buf0[13];
4430     block0[14] = salt_buf0[14];
4431     block0[15] = salt_buf0[15];
4432
4433     u32x block1[16];
4434
4435     block1[ 0] = salt_buf1[ 0];
4436     block1[ 1] = salt_buf1[ 1];
4437     block1[ 2] = salt_buf1[ 2];
4438     block1[ 3] = salt_buf1[ 3];
4439     block1[ 4] = salt_buf1[ 4];
4440     block1[ 5] = salt_buf1[ 5];
4441     block1[ 6] = salt_buf1[ 6];
4442     block1[ 7] = salt_buf1[ 7];
4443     block1[ 8] = salt_buf1[ 8];
4444     block1[ 9] = salt_buf1[ 9];
4445     block1[10] = salt_buf1[10];
4446     block1[11] = salt_buf1[11];
4447     block1[12] = salt_buf1[12];
4448     block1[13] = salt_buf1[13];
4449     block1[14] = salt_buf1[14];
4450     block1[15] = salt_buf1[15];
4451
4452     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
4453
4454     u32x w0_t[4];
4455
4456     w0_t[0] = block0[ 0];
4457     w0_t[1] = block0[ 1];
4458     w0_t[2] = block0[ 2];
4459     w0_t[3] = block0[ 3];
4460
4461     u32x w1_t[4];
4462
4463     w1_t[0] = block0[ 4];
4464     w1_t[1] = block0[ 5];
4465     w1_t[2] = block0[ 6];
4466     w1_t[3] = block0[ 7];
4467
4468     u32x w2_t[4];
4469
4470     w2_t[0] = block0[ 8];
4471     w2_t[1] = block0[ 9];
4472     w2_t[2] = block0[10];
4473     w2_t[3] = block0[11];
4474
4475     u32x w3_t[4];
4476
4477     w3_t[0] = block0[12];
4478     w3_t[1] = block0[13];
4479     w3_t[2] = block0[14];
4480     w3_t[3] = block0[15];
4481
4482     // md5
4483
4484     u32x tmp2;
4485
4486     u32x a = MD5M_A;
4487     u32x b = MD5M_B;
4488     u32x c = MD5M_C;
4489     u32x d = MD5M_D;
4490
4491     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4492     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4493     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4494     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4495     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4496     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4497     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4498     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4499     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4500     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4501     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4502     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4503     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4504     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4505     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4506     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4507
4508     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4509     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4510     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4511     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4512     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4513     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4514     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4515     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4516     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4517     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4518     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4519     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4520     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4521     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4522     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4523     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4524
4525     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4526     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4527     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4528     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4529     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4530     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4531     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4532     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4533     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4534     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4535     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4536     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4537     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4538     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4539     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4540     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4541
4542     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4543     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4544     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4545     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4546     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4547     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4548     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4549     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4550     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4551     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4552     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4553     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4554     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4555     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4556     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4557     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4558
4559     a += MD5M_A;
4560     b += MD5M_B;
4561     c += MD5M_C;
4562     d += MD5M_D;
4563
4564     u32x r_a = a;
4565     u32x r_b = b;
4566     u32x r_c = c;
4567     u32x r_d = d;
4568
4569     w0_t[0] = block1[ 0];
4570     w0_t[1] = block1[ 1];
4571     w0_t[2] = block1[ 2];
4572     w0_t[3] = block1[ 3];
4573
4574     w1_t[0] = block1[ 4];
4575     w1_t[1] = block1[ 5];
4576     w1_t[2] = block1[ 6];
4577     w1_t[3] = block1[ 7];
4578
4579     w2_t[0] = block1[ 8];
4580     w2_t[1] = block1[ 9];
4581     w2_t[2] = block1[10];
4582     w2_t[3] = block1[11];
4583
4584     w3_t[0] = block1[12];
4585     w3_t[1] = block1[13];
4586     w3_t[2] = pw_salt_len * 8;
4587     w3_t[3] = 0;
4588
4589     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4590     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4591     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4592     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4593     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4594     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4595     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4596     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4597     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4598     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4599     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4600     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4601     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4602     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4603     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4604     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4605
4606     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4607     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4608     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4609     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4610     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4611     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4612     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4613     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4614     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4615     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4616     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4617     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4618     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4619     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4620     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4621     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4622
4623     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4624     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4625     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4626     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4627     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4628     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4629     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4630     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4631     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4632     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4633     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4634     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4635     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4636     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4637     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4638     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4639
4640     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4641     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4642     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4643     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4644     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4645     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4646     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4647     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4648     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4649     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4650     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4651     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4652     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4653     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4654     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4655     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4656
4657     a += r_a;
4658     b += r_b;
4659     c += r_c;
4660     d += r_d;
4661
4662     /*
4663      * final = md5 ($HA1 . $esalt)
4664      * we have at least 2 MD5 blocks/transformations, but we might need 3
4665      */
4666
4667     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
4668             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
4669     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
4670             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
4671     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
4672             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
4673     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
4674             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
4675     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
4676             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
4677     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
4678             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
4679     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
4680             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
4681     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
4682             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
4683
4684     w2_t[0] = esalt_buf0[0];
4685     w2_t[1] = esalt_buf0[1];
4686     w2_t[2] = esalt_buf0[2];
4687     w2_t[3] = esalt_buf0[3];
4688
4689     w3_t[0] = esalt_buf0[4];
4690     w3_t[1] = esalt_buf0[5];
4691     w3_t[2] = esalt_buf0[6];
4692     w3_t[3] = esalt_buf0[7];
4693
4694     // md5
4695     // 1st transform
4696
4697     a = MD5M_A;
4698     b = MD5M_B;
4699     c = MD5M_C;
4700     d = MD5M_D;
4701
4702     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4703     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4704     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4705     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4706     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4707     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4708     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4709     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4710     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4711     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4712     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4713     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4714     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4715     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4716     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4717     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4718
4719     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4720     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4721     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4722     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4723     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4724     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4725     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4726     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4727     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4728     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4729     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4730     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4731     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4732     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4733     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4734     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4735
4736     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4737     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4738     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4739     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4740     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4741     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4742     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4743     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4744     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4745     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4746     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4747     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4748     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4749     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4750     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4751     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4752
4753     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4754     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4755     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4756     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4757     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4758     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4759     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4760     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4761     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4762     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4763     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4764     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4765     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4766     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4767     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4768     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4769
4770     a += MD5M_A;
4771     b += MD5M_B;
4772     c += MD5M_C;
4773     d += MD5M_D;
4774
4775     r_a = a;
4776     r_b = b;
4777     r_c = c;
4778     r_d = d;
4779
4780     // 2nd transform
4781
4782     w0_t[0] = esalt_buf0[ 8];
4783     w0_t[1] = esalt_buf0[ 9];
4784     w0_t[2] = esalt_buf0[10];
4785     w0_t[3] = esalt_buf0[11];
4786
4787     w1_t[0] = esalt_buf0[12];
4788     w1_t[1] = esalt_buf0[13];
4789     w1_t[2] = esalt_buf0[14];
4790     w1_t[3] = esalt_buf0[15];
4791
4792     w2_t[0] = esalt_buf1[ 0];
4793     w2_t[1] = esalt_buf1[ 1];
4794     w2_t[2] = esalt_buf1[ 2];
4795     w2_t[3] = esalt_buf1[ 3];
4796
4797     w3_t[0] = esalt_buf1[ 4];
4798     w3_t[1] = esalt_buf1[ 5];
4799     w3_t[2] = digest_esalt_len * 8;
4800     w3_t[3] = 0;
4801
4802     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
4803     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
4804     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
4805     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
4806     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
4807     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
4808     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
4809     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
4810     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
4811     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
4812     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
4813     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
4814     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
4815     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
4816     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
4817     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
4818
4819     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
4820     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
4821     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
4822     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
4823     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
4824     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
4825     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
4826     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
4827     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
4828     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
4829     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
4830     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
4831     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
4832     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
4833     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
4834     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
4835
4836     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
4837     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
4838     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
4839     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
4840     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
4841     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
4842     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
4843     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
4844     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
4845     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
4846     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
4847     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
4848     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
4849     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
4850     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
4851     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
4852
4853     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
4854     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
4855     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
4856     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
4857     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
4858     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
4859     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
4860     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
4861     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
4862     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
4863     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
4864     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
4865     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
4866     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
4867     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
4868     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
4869
4870     a += r_a;
4871     b += r_b;
4872     c += r_c;
4873     d += r_d;
4874
4875     const u32x r0 = a;
4876     const u32x r1 = d;
4877     const u32x r2 = c;
4878     const u32x r3 = b;
4879
4880     #include VECT_COMPARE_S
4881   }
4882 }
4883
4884 __device__ static void m11400s_1_1 (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], const u32 pw_len, const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
4885 {
4886   /**
4887    * modifier
4888    */
4889
4890   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
4891   const u32 lid = threadIdx.x;
4892
4893   /**
4894    * digest
4895    */
4896
4897   const u32 search[4] =
4898   {
4899     digests_buf[digests_offset].digest_buf[DGST_R0],
4900     digests_buf[digests_offset].digest_buf[DGST_R1],
4901     digests_buf[digests_offset].digest_buf[DGST_R2],
4902     digests_buf[digests_offset].digest_buf[DGST_R3]
4903   };
4904
4905   /**
4906    * salt
4907    */
4908
4909   const u32 salt_len = esalt_bufs[salt_pos].salt_len; // not a bug, we need to get it from the esalt
4910
4911   const u32 pw_salt_len = salt_len + pw_len;
4912
4913   u32 salt_buf0[16];
4914
4915   salt_buf0[ 0] = esalt_bufs[salt_pos].salt_buf[ 0];
4916   salt_buf0[ 1] = esalt_bufs[salt_pos].salt_buf[ 1];
4917   salt_buf0[ 2] = esalt_bufs[salt_pos].salt_buf[ 2];
4918   salt_buf0[ 3] = esalt_bufs[salt_pos].salt_buf[ 3];
4919   salt_buf0[ 4] = esalt_bufs[salt_pos].salt_buf[ 4];
4920   salt_buf0[ 5] = esalt_bufs[salt_pos].salt_buf[ 5];
4921   salt_buf0[ 6] = esalt_bufs[salt_pos].salt_buf[ 6];
4922   salt_buf0[ 7] = esalt_bufs[salt_pos].salt_buf[ 7];
4923   salt_buf0[ 8] = esalt_bufs[salt_pos].salt_buf[ 8];
4924   salt_buf0[ 9] = esalt_bufs[salt_pos].salt_buf[ 9];
4925   salt_buf0[10] = esalt_bufs[salt_pos].salt_buf[10];
4926   salt_buf0[11] = esalt_bufs[salt_pos].salt_buf[11];
4927   salt_buf0[12] = esalt_bufs[salt_pos].salt_buf[12];
4928   salt_buf0[13] = esalt_bufs[salt_pos].salt_buf[13];
4929   salt_buf0[14] = esalt_bufs[salt_pos].salt_buf[14];
4930   salt_buf0[15] = esalt_bufs[salt_pos].salt_buf[15];
4931
4932   u32 salt_buf1[16];
4933
4934   salt_buf1[ 0] = esalt_bufs[salt_pos].salt_buf[16];
4935   salt_buf1[ 1] = esalt_bufs[salt_pos].salt_buf[17];
4936   salt_buf1[ 2] = esalt_bufs[salt_pos].salt_buf[18];
4937   salt_buf1[ 3] = esalt_bufs[salt_pos].salt_buf[19];
4938   salt_buf1[ 4] = esalt_bufs[salt_pos].salt_buf[20];
4939   salt_buf1[ 5] = esalt_bufs[salt_pos].salt_buf[21];
4940   salt_buf1[ 6] = esalt_bufs[salt_pos].salt_buf[22];
4941   salt_buf1[ 7] = esalt_bufs[salt_pos].salt_buf[23];
4942   salt_buf1[ 8] = esalt_bufs[salt_pos].salt_buf[24];
4943   salt_buf1[ 9] = esalt_bufs[salt_pos].salt_buf[25];
4944   salt_buf1[10] = esalt_bufs[salt_pos].salt_buf[26];
4945   salt_buf1[11] = esalt_bufs[salt_pos].salt_buf[27];
4946   salt_buf1[12] = esalt_bufs[salt_pos].salt_buf[28];
4947   salt_buf1[13] = esalt_bufs[salt_pos].salt_buf[29];
4948   salt_buf1[14] = 0;
4949   salt_buf1[15] = 0;
4950
4951   /**
4952    * esalt
4953    */
4954
4955   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
4956
4957   u32 esalt_buf0[16];
4958
4959   esalt_buf0[ 0] = esalt_bufs[salt_pos].esalt_buf[ 0];
4960   esalt_buf0[ 1] = esalt_bufs[salt_pos].esalt_buf[ 1];
4961   esalt_buf0[ 2] = esalt_bufs[salt_pos].esalt_buf[ 2];
4962   esalt_buf0[ 3] = esalt_bufs[salt_pos].esalt_buf[ 3];
4963   esalt_buf0[ 4] = esalt_bufs[salt_pos].esalt_buf[ 4];
4964   esalt_buf0[ 5] = esalt_bufs[salt_pos].esalt_buf[ 5];
4965   esalt_buf0[ 6] = esalt_bufs[salt_pos].esalt_buf[ 6];
4966   esalt_buf0[ 7] = esalt_bufs[salt_pos].esalt_buf[ 7];
4967   esalt_buf0[ 8] = esalt_bufs[salt_pos].esalt_buf[ 8];
4968   esalt_buf0[ 9] = esalt_bufs[salt_pos].esalt_buf[ 9];
4969   esalt_buf0[10] = esalt_bufs[salt_pos].esalt_buf[10];
4970   esalt_buf0[11] = esalt_bufs[salt_pos].esalt_buf[11];
4971   esalt_buf0[12] = esalt_bufs[salt_pos].esalt_buf[12];
4972   esalt_buf0[13] = esalt_bufs[salt_pos].esalt_buf[13];
4973   esalt_buf0[14] = esalt_bufs[salt_pos].esalt_buf[14];
4974   esalt_buf0[15] = esalt_bufs[salt_pos].esalt_buf[15];
4975
4976   u32 esalt_buf1[16];
4977
4978   esalt_buf1[ 0] = esalt_bufs[salt_pos].esalt_buf[16];
4979   esalt_buf1[ 1] = esalt_bufs[salt_pos].esalt_buf[17];
4980   esalt_buf1[ 2] = esalt_bufs[salt_pos].esalt_buf[18];
4981   esalt_buf1[ 3] = esalt_bufs[salt_pos].esalt_buf[19];
4982   esalt_buf1[ 4] = esalt_bufs[salt_pos].esalt_buf[20];
4983   esalt_buf1[ 5] = esalt_bufs[salt_pos].esalt_buf[21];
4984   esalt_buf1[ 6] = esalt_bufs[salt_pos].esalt_buf[22];
4985   esalt_buf1[ 7] = esalt_bufs[salt_pos].esalt_buf[23];
4986   esalt_buf1[ 8] = esalt_bufs[salt_pos].esalt_buf[24];
4987   esalt_buf1[ 9] = esalt_bufs[salt_pos].esalt_buf[25];
4988   esalt_buf1[10] = esalt_bufs[salt_pos].esalt_buf[26];
4989   esalt_buf1[11] = esalt_bufs[salt_pos].esalt_buf[27];
4990   esalt_buf1[12] = esalt_bufs[salt_pos].esalt_buf[28];
4991   esalt_buf1[13] = esalt_bufs[salt_pos].esalt_buf[29];
4992   esalt_buf1[14] = esalt_bufs[salt_pos].esalt_buf[30];
4993   esalt_buf1[15] = esalt_bufs[salt_pos].esalt_buf[31];
4994
4995   u32 esalt_buf2[16];
4996
4997   esalt_buf2[ 0] = esalt_bufs[salt_pos].esalt_buf[32];
4998   esalt_buf2[ 1] = esalt_bufs[salt_pos].esalt_buf[33];
4999   esalt_buf2[ 2] = esalt_bufs[salt_pos].esalt_buf[34];
5000   esalt_buf2[ 3] = esalt_bufs[salt_pos].esalt_buf[35];
5001   esalt_buf2[ 4] = esalt_bufs[salt_pos].esalt_buf[36];
5002   esalt_buf2[ 5] = esalt_bufs[salt_pos].esalt_buf[37];
5003   esalt_buf2[ 6] = 0;
5004   esalt_buf2[ 7] = 0;
5005   esalt_buf2[ 8] = 0;
5006   esalt_buf2[ 9] = 0;
5007   esalt_buf2[10] = 0;
5008   esalt_buf2[11] = 0;
5009   esalt_buf2[12] = 0;
5010   esalt_buf2[13] = 0;
5011   esalt_buf2[14] = 0;
5012   esalt_buf2[15] = 0;
5013
5014   const u32 digest_esalt_len = 32 + esalt_len;
5015
5016   /**
5017    * loop
5018    */
5019
5020   u32x w0l = w0[0];
5021
5022   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
5023   {
5024     const u32 w0r = c_bfs[il_pos].i;
5025
5026     w0[0] = w0l | w0r;
5027
5028     /*
5029      * HA1 = md5 ($salt . $pass)
5030      */
5031
5032     // append the pass to the salt
5033
5034     u32x block0[16];
5035
5036     block0[ 0] = salt_buf0[ 0];
5037     block0[ 1] = salt_buf0[ 1];
5038     block0[ 2] = salt_buf0[ 2];
5039     block0[ 3] = salt_buf0[ 3];
5040     block0[ 4] = salt_buf0[ 4];
5041     block0[ 5] = salt_buf0[ 5];
5042     block0[ 6] = salt_buf0[ 6];
5043     block0[ 7] = salt_buf0[ 7];
5044     block0[ 8] = salt_buf0[ 8];
5045     block0[ 9] = salt_buf0[ 9];
5046     block0[10] = salt_buf0[10];
5047     block0[11] = salt_buf0[11];
5048     block0[12] = salt_buf0[12];
5049     block0[13] = salt_buf0[13];
5050     block0[14] = salt_buf0[14];
5051     block0[15] = salt_buf0[15];
5052
5053     u32x block1[16];
5054
5055     block1[ 0] = salt_buf1[ 0];
5056     block1[ 1] = salt_buf1[ 1];
5057     block1[ 2] = salt_buf1[ 2];
5058     block1[ 3] = salt_buf1[ 3];
5059     block1[ 4] = salt_buf1[ 4];
5060     block1[ 5] = salt_buf1[ 5];
5061     block1[ 6] = salt_buf1[ 6];
5062     block1[ 7] = salt_buf1[ 7];
5063     block1[ 8] = salt_buf1[ 8];
5064     block1[ 9] = salt_buf1[ 9];
5065     block1[10] = salt_buf1[10];
5066     block1[11] = salt_buf1[11];
5067     block1[12] = salt_buf1[12];
5068     block1[13] = salt_buf1[13];
5069     block1[14] = salt_buf1[14];
5070     block1[15] = salt_buf1[15];
5071
5072     memcat32 (block0, block1, salt_len, w0, w1, w2, w3, pw_len);
5073
5074     u32x w0_t[4];
5075
5076     w0_t[0] = block0[ 0];
5077     w0_t[1] = block0[ 1];
5078     w0_t[2] = block0[ 2];
5079     w0_t[3] = block0[ 3];
5080
5081     u32x w1_t[4];
5082
5083     w1_t[0] = block0[ 4];
5084     w1_t[1] = block0[ 5];
5085     w1_t[2] = block0[ 6];
5086     w1_t[3] = block0[ 7];
5087
5088     u32x w2_t[4];
5089
5090     w2_t[0] = block0[ 8];
5091     w2_t[1] = block0[ 9];
5092     w2_t[2] = block0[10];
5093     w2_t[3] = block0[11];
5094
5095     u32x w3_t[4];
5096
5097     w3_t[0] = block0[12];
5098     w3_t[1] = block0[13];
5099     w3_t[2] = block0[14];
5100     w3_t[3] = block0[15];
5101
5102     // md5
5103
5104     u32x tmp2;
5105
5106     u32x a = MD5M_A;
5107     u32x b = MD5M_B;
5108     u32x c = MD5M_C;
5109     u32x d = MD5M_D;
5110
5111     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
5112     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
5113     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
5114     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
5115     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
5116     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
5117     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
5118     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
5119     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
5120     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
5121     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
5122     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
5123     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
5124     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
5125     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
5126     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
5127
5128     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
5129     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
5130     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
5131     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
5132     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
5133     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
5134     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
5135     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
5136     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
5137     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
5138     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
5139     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
5140     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
5141     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
5142     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
5143     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
5144
5145     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
5146     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
5147     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
5148     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
5149     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
5150     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
5151     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
5152     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
5153     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
5154     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
5155     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
5156     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
5157     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
5158     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
5159     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
5160     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
5161
5162     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
5163     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
5164     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
5165     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
5166     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
5167     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
5168     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
5169     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
5170     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
5171     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
5172     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
5173     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
5174     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
5175     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
5176     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
5177     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
5178
5179     a += MD5M_A;
5180     b += MD5M_B;
5181     c += MD5M_C;
5182     d += MD5M_D;
5183
5184     u32x r_a = a;
5185     u32x r_b = b;
5186     u32x r_c = c;
5187     u32x r_d = d;
5188
5189     w0_t[0] = block1[ 0];
5190     w0_t[1] = block1[ 1];
5191     w0_t[2] = block1[ 2];
5192     w0_t[3] = block1[ 3];
5193
5194     w1_t[0] = block1[ 4];
5195     w1_t[1] = block1[ 5];
5196     w1_t[2] = block1[ 6];
5197     w1_t[3] = block1[ 7];
5198
5199     w2_t[0] = block1[ 8];
5200     w2_t[1] = block1[ 9];
5201     w2_t[2] = block1[10];
5202     w2_t[3] = block1[11];
5203
5204     w3_t[0] = block1[12];
5205     w3_t[1] = block1[13];
5206     w3_t[2] = pw_salt_len * 8;
5207     w3_t[3] = 0;
5208
5209     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
5210     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
5211     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
5212     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
5213     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
5214     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
5215     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
5216     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
5217     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
5218     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
5219     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
5220     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
5221     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
5222     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
5223     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
5224     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
5225
5226     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
5227     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
5228     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
5229     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
5230     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
5231     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
5232     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
5233     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
5234     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
5235     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
5236     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
5237     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
5238     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
5239     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
5240     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
5241     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
5242
5243     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
5244     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
5245     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
5246     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
5247     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
5248     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
5249     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
5250     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
5251     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
5252     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
5253     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
5254     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
5255     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
5256     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
5257     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
5258     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
5259
5260     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
5261     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
5262     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
5263     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
5264     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
5265     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
5266     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
5267     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
5268     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
5269     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
5270     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
5271     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
5272     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
5273     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
5274     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
5275     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
5276
5277     a += r_a;
5278     b += r_b;
5279     c += r_c;
5280     d += r_d;
5281
5282     /*
5283      * final = md5 ($HA1 . $esalt)
5284      * we have at least 2 MD5 blocks/transformations, but we might need 3
5285      */
5286
5287     w0_t[0] = uint_to_hex_lower8 ((a >>  0) & 255) <<  0
5288             | uint_to_hex_lower8 ((a >>  8) & 255) << 16;
5289     w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) <<  0
5290             | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
5291     w0_t[2] = uint_to_hex_lower8 ((b >>  0) & 255) <<  0
5292             | uint_to_hex_lower8 ((b >>  8) & 255) << 16;
5293     w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) <<  0
5294             | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
5295     w1_t[0] = uint_to_hex_lower8 ((c >>  0) & 255) <<  0
5296             | uint_to_hex_lower8 ((c >>  8) & 255) << 16;
5297     w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) <<  0
5298             | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
5299     w1_t[2] = uint_to_hex_lower8 ((d >>  0) & 255) <<  0
5300             | uint_to_hex_lower8 ((d >>  8) & 255) << 16;
5301     w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) <<  0
5302             | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
5303
5304     w2_t[0] = esalt_buf0[0];
5305     w2_t[1] = esalt_buf0[1];
5306     w2_t[2] = esalt_buf0[2];
5307     w2_t[3] = esalt_buf0[3];
5308
5309     w3_t[0] = esalt_buf0[4];
5310     w3_t[1] = esalt_buf0[5];
5311     w3_t[2] = esalt_buf0[6];
5312     w3_t[3] = esalt_buf0[7];
5313
5314     // md5
5315     // 1st transform
5316
5317     a = MD5M_A;
5318     b = MD5M_B;
5319     c = MD5M_C;
5320     d = MD5M_D;
5321
5322     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
5323     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
5324     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
5325     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
5326     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
5327     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
5328     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
5329     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
5330     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
5331     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
5332     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
5333     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
5334     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
5335     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
5336     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
5337     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
5338
5339     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
5340     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
5341     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
5342     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
5343     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
5344     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
5345     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
5346     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
5347     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
5348     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
5349     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
5350     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
5351     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
5352     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
5353     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
5354     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
5355
5356     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
5357     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
5358     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
5359     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
5360     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
5361     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
5362     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
5363     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
5364     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
5365     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
5366     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
5367     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
5368     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
5369     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
5370     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
5371     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
5372
5373     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
5374     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
5375     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
5376     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
5377     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
5378     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
5379     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
5380     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
5381     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
5382     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
5383     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
5384     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
5385     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
5386     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
5387     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
5388     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
5389
5390     a += MD5M_A;
5391     b += MD5M_B;
5392     c += MD5M_C;
5393     d += MD5M_D;
5394
5395     r_a = a;
5396     r_b = b;
5397     r_c = c;
5398     r_d = d;
5399
5400     // 2nd transform
5401
5402     w0_t[0] = esalt_buf0[ 8];
5403     w0_t[1] = esalt_buf0[ 9];
5404     w0_t[2] = esalt_buf0[10];
5405     w0_t[3] = esalt_buf0[11];
5406
5407     w1_t[0] = esalt_buf0[12];
5408     w1_t[1] = esalt_buf0[13];
5409     w1_t[2] = esalt_buf0[14];
5410     w1_t[3] = esalt_buf0[15];
5411
5412     w2_t[0] = esalt_buf1[ 0];
5413     w2_t[1] = esalt_buf1[ 1];
5414     w2_t[2] = esalt_buf1[ 2];
5415     w2_t[3] = esalt_buf1[ 3];
5416
5417     w3_t[0] = esalt_buf1[ 4];
5418     w3_t[1] = esalt_buf1[ 5];
5419     w3_t[2] = esalt_buf1[ 6];
5420     w3_t[3] = esalt_buf1[ 7];
5421
5422     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
5423     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
5424     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
5425     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
5426     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
5427     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
5428     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
5429     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
5430     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
5431     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
5432     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
5433     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
5434     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
5435     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
5436     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
5437     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
5438
5439     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
5440     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
5441     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
5442     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
5443     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
5444     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
5445     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
5446     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
5447     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
5448     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
5449     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
5450     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
5451     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
5452     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
5453     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
5454     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
5455
5456     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
5457     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
5458     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
5459     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
5460     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
5461     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
5462     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
5463     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
5464     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
5465     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
5466     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
5467     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
5468     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
5469     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
5470     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
5471     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
5472
5473     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
5474     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
5475     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
5476     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
5477     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
5478     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
5479     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
5480     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
5481     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
5482     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
5483     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
5484     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
5485     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
5486     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
5487     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
5488     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
5489
5490     // this is for sure the final block
5491
5492     a += r_a;
5493     b += r_b;
5494     c += r_c;
5495     d += r_d;
5496
5497     r_a = a;
5498     r_b = b;
5499     r_c = c;
5500     r_d = d;
5501
5502     w0_t[0] = esalt_buf1[ 8];
5503     w0_t[1] = esalt_buf1[ 9];
5504     w0_t[2] = esalt_buf1[10];
5505     w0_t[3] = esalt_buf1[11];
5506
5507     w1_t[0] = esalt_buf1[12];
5508     w1_t[1] = esalt_buf1[13];
5509     w1_t[2] = esalt_buf1[14];
5510     w1_t[3] = esalt_buf1[15];
5511
5512     w2_t[0] = esalt_buf2[ 0];
5513     w2_t[1] = esalt_buf2[ 1];
5514     w2_t[2] = esalt_buf2[ 2];
5515     w2_t[3] = esalt_buf2[ 3];
5516
5517     w3_t[0] = esalt_buf2[ 4];
5518     w3_t[1] = esalt_buf2[ 5];
5519     w3_t[2] = digest_esalt_len * 8;
5520     w3_t[3] = 0;
5521
5522     MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
5523     MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
5524     MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
5525     MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
5526     MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
5527     MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
5528     MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
5529     MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
5530     MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
5531     MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
5532     MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
5533     MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
5534     MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
5535     MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
5536     MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
5537     MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
5538
5539     MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
5540     MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
5541     MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
5542     MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
5543     MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
5544     MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
5545     MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
5546     MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
5547     MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
5548     MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
5549     MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
5550     MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
5551     MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
5552     MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
5553     MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
5554     MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
5555
5556     MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20);
5557     MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21);
5558     MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22);
5559     MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23);
5560     MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20);
5561     MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21);
5562     MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22);
5563     MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23);
5564     MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20);
5565     MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21);
5566     MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22);
5567     MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23);
5568     MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20);
5569     MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21);
5570     MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22);
5571     MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23);
5572
5573     MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
5574     MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
5575     MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
5576     MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
5577     MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
5578     MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
5579     MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
5580     MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
5581     MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
5582     MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
5583     MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
5584     MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
5585     MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
5586     MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
5587     MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
5588     MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
5589
5590     a += r_a;
5591     b += r_b;
5592     c += r_c;
5593     d += r_d;
5594
5595     const u32x r0 = a;
5596     const u32x r1 = d;
5597     const u32x r2 = c;
5598     const u32x r3 = b;
5599
5600     #include VECT_COMPARE_S
5601   }
5602 }
5603
5604 extern "C" __global__ void __launch_bounds__ (256, 1) m11400_m04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
5605 {
5606   /**
5607    * base
5608    */
5609
5610   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
5611
5612   /**
5613    * modifier
5614    */
5615
5616   const u32 lid = threadIdx.x;
5617
5618
5619   u32x w0[4];
5620
5621   w0[0] = pws[gid].i[ 0];
5622   w0[1] = pws[gid].i[ 1];
5623   w0[2] = pws[gid].i[ 2];
5624   w0[3] = pws[gid].i[ 3];
5625
5626   u32x w1[4];
5627
5628   w1[0] = 0;
5629   w1[1] = 0;
5630   w1[2] = 0;
5631   w1[3] = 0;
5632
5633   u32x w2[4];
5634
5635   w2[0] = 0;
5636   w2[1] = 0;
5637   w2[2] = 0;
5638   w2[3] = 0;
5639
5640   u32x w3[4];
5641
5642   w3[0] = 0;
5643   w3[1] = 0;
5644   w3[2] = pws[gid].i[14];
5645   w3[3] = 0;
5646
5647   const u32 pw_len = pws[gid].pw_len;
5648
5649   /**
5650    * bin2asc table
5651    */
5652
5653   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
5654                  | c_bin2asc[(lid >> 4) & 15] << 0;
5655
5656   __syncthreads ();
5657
5658   if (gid >= gid_max) return;
5659
5660   /**
5661    * main
5662    */
5663
5664   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
5665   const u32 salt_len  = esalt_bufs[salt_pos].salt_len;
5666
5667   const u32 sw_1 = ((32 + esalt_len + 1) > 119);
5668   const u32 sw_2 = ((pw_len + salt_len)  >  55) << 1;
5669
5670   switch (sw_1 | sw_2)
5671   {
5672     case 0:
5673       m11400m_0_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5674       break;
5675     case 1:
5676       m11400m_0_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5677       break;
5678     case 2:
5679       m11400m_1_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5680       break;
5681     case 3:
5682       m11400m_1_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5683       break;
5684   }
5685 }
5686
5687 extern "C" __global__ void __launch_bounds__ (256, 1) m11400_m08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
5688 {
5689   /**
5690    * base
5691    */
5692
5693   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
5694
5695   /**
5696    * modifier
5697    */
5698
5699   const u32 lid = threadIdx.x;
5700
5701   u32x w0[4];
5702
5703   w0[0] = pws[gid].i[ 0];
5704   w0[1] = pws[gid].i[ 1];
5705   w0[2] = pws[gid].i[ 2];
5706   w0[3] = pws[gid].i[ 3];
5707
5708   u32x w1[4];
5709
5710   w1[0] = pws[gid].i[ 4];
5711   w1[1] = pws[gid].i[ 5];
5712   w1[2] = pws[gid].i[ 6];
5713   w1[3] = pws[gid].i[ 7];
5714
5715   u32x w2[4];
5716
5717   w2[0] = 0;
5718   w2[1] = 0;
5719   w2[2] = 0;
5720   w2[3] = 0;
5721
5722   u32x w3[4];
5723
5724   w3[0] = 0;
5725   w3[1] = 0;
5726   w3[2] = pws[gid].i[14];
5727   w3[3] = 0;
5728
5729   const u32 pw_len = pws[gid].pw_len;
5730
5731   /**
5732    * bin2asc table
5733    */
5734
5735   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
5736                  | c_bin2asc[(lid >> 4) & 15] << 0;
5737
5738   __syncthreads ();
5739
5740   if (gid >= gid_max) return;
5741
5742   /**
5743    * main
5744    */
5745
5746   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
5747   const u32 salt_len  = esalt_bufs[salt_pos].salt_len;
5748
5749   const u32 sw_1 = ((32 + esalt_len + 1) > 119);
5750   const u32 sw_2 = ((pw_len + salt_len)  >  55) << 1;
5751
5752   switch (sw_1 | sw_2)
5753   {
5754     case 0:
5755       m11400m_0_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5756       break;
5757     case 1:
5758       m11400m_0_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5759       break;
5760     case 2:
5761       m11400m_1_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5762       break;
5763     case 3:
5764       m11400m_1_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5765       break;
5766   }
5767 }
5768
5769 extern "C" __global__ void __launch_bounds__ (256, 1) m11400_m16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
5770 {
5771   /**
5772    * base
5773    */
5774
5775   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
5776
5777   /**
5778    * modifier
5779    */
5780
5781   const u32 lid = threadIdx.x;
5782
5783   u32x w0[4];
5784
5785   w0[0] = pws[gid].i[ 0];
5786   w0[1] = pws[gid].i[ 1];
5787   w0[2] = pws[gid].i[ 2];
5788   w0[3] = pws[gid].i[ 3];
5789
5790   u32x w1[4];
5791
5792   w1[0] = pws[gid].i[ 4];
5793   w1[1] = pws[gid].i[ 5];
5794   w1[2] = pws[gid].i[ 6];
5795   w1[3] = pws[gid].i[ 7];
5796
5797   u32x w2[4];
5798
5799   w2[0] = pws[gid].i[ 8];
5800   w2[1] = pws[gid].i[ 9];
5801   w2[2] = pws[gid].i[10];
5802   w2[3] = pws[gid].i[11];
5803
5804   u32x w3[4];
5805
5806   w3[0] = pws[gid].i[12];
5807   w3[1] = pws[gid].i[13];
5808   w3[2] = pws[gid].i[14];
5809   w3[3] = pws[gid].i[15];
5810
5811   const u32 pw_len = pws[gid].pw_len;
5812
5813   /**
5814    * bin2asc table
5815    */
5816
5817   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
5818                  | c_bin2asc[(lid >> 4) & 15] << 0;
5819
5820   __syncthreads ();
5821
5822   if (gid >= gid_max) return;
5823
5824   /**
5825    * main
5826    */
5827
5828   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
5829   const u32 salt_len  = esalt_bufs[salt_pos].salt_len;
5830
5831   const u32 sw_1 = ((32 + esalt_len + 1) > 119);
5832   const u32 sw_2 = ((pw_len + salt_len)  >  55) << 1;
5833
5834   switch (sw_1 | sw_2)
5835   {
5836     case 0:
5837       m11400m_0_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5838       break;
5839     case 1:
5840       m11400m_0_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5841       break;
5842     case 2:
5843       m11400m_1_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5844       break;
5845     case 3:
5846       m11400m_1_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5847       break;
5848   }
5849 }
5850
5851 extern "C" __global__ void __launch_bounds__ (256, 1) m11400_s04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
5852 {
5853   /**
5854    * base
5855    */
5856
5857   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
5858
5859   /**
5860    * modifier
5861    */
5862
5863   const u32 lid = threadIdx.x;
5864
5865   u32x w0[4];
5866
5867   w0[0] = pws[gid].i[ 0];
5868   w0[1] = pws[gid].i[ 1];
5869   w0[2] = pws[gid].i[ 2];
5870   w0[3] = pws[gid].i[ 3];
5871
5872   u32x w1[4];
5873
5874   w1[0] = 0;
5875   w1[1] = 0;
5876   w1[2] = 0;
5877   w1[3] = 0;
5878
5879   u32x w2[4];
5880
5881   w2[0] = 0;
5882   w2[1] = 0;
5883   w2[2] = 0;
5884   w2[3] = 0;
5885
5886   u32x w3[4];
5887
5888   w3[0] = 0;
5889   w3[1] = 0;
5890   w3[2] = pws[gid].i[14];
5891   w3[3] = 0;
5892
5893   const u32 pw_len = pws[gid].pw_len;
5894
5895   /**
5896    * bin2asc table
5897    */
5898
5899   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
5900                  | c_bin2asc[(lid >> 4) & 15] << 0;
5901
5902   __syncthreads ();
5903
5904   if (gid >= gid_max) return;
5905
5906   /**
5907    * main
5908    */
5909
5910   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
5911   const u32 salt_len  = esalt_bufs[salt_pos].salt_len;
5912
5913   const u32 sw_1 = ((32 + esalt_len + 1) > 119);
5914   const u32 sw_2 = ((pw_len + salt_len)  >  55) << 1;
5915
5916   switch (sw_1 | sw_2)
5917   {
5918     case 0:
5919       m11400s_0_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5920       break;
5921     case 1:
5922       m11400s_0_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5923       break;
5924     case 2:
5925       m11400s_1_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5926       break;
5927     case 3:
5928       m11400s_1_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
5929       break;
5930   }
5931 }
5932
5933 extern "C" __global__ void __launch_bounds__ (256, 1) m11400_s08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
5934 {
5935   /**
5936    * base
5937    */
5938
5939   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
5940
5941   /**
5942    * modifier
5943    */
5944
5945   const u32 lid = threadIdx.x;
5946
5947   u32x w0[4];
5948
5949   w0[0] = pws[gid].i[ 0];
5950   w0[1] = pws[gid].i[ 1];
5951   w0[2] = pws[gid].i[ 2];
5952   w0[3] = pws[gid].i[ 3];
5953
5954   u32x w1[4];
5955
5956   w1[0] = pws[gid].i[ 4];
5957   w1[1] = pws[gid].i[ 5];
5958   w1[2] = pws[gid].i[ 6];
5959   w1[3] = pws[gid].i[ 7];
5960
5961   u32x w2[4];
5962
5963   w2[0] = 0;
5964   w2[1] = 0;
5965   w2[2] = 0;
5966   w2[3] = 0;
5967
5968   u32x w3[4];
5969
5970   w3[0] = 0;
5971   w3[1] = 0;
5972   w3[2] = pws[gid].i[14];
5973   w3[3] = 0;
5974
5975   const u32 pw_len = pws[gid].pw_len;
5976
5977   /**
5978    * bin2asc table
5979    */
5980
5981   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
5982                  | c_bin2asc[(lid >> 4) & 15] << 0;
5983
5984   __syncthreads ();
5985
5986   if (gid >= gid_max) return;
5987
5988   /**
5989    * main
5990    */
5991
5992   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
5993   const u32 salt_len  = esalt_bufs[salt_pos].salt_len;
5994
5995   const u32 sw_1 = ((32 + esalt_len + 1) > 119);
5996   const u32 sw_2 = ((pw_len + salt_len)  >  55) << 1;
5997
5998   switch (sw_1 | sw_2)
5999   {
6000     case 0:
6001       m11400s_0_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6002       break;
6003     case 1:
6004       m11400s_0_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6005       break;
6006     case 2:
6007       m11400s_1_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6008       break;
6009     case 3:
6010       m11400s_1_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6011       break;
6012   }
6013 }
6014
6015 extern "C" __global__ void __launch_bounds__ (256, 1) m11400_s16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const sip_t *esalt_bufs, u32 *d_return_buf, u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
6016 {
6017   /**
6018    * base
6019    */
6020
6021   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
6022
6023   /**
6024    * modifier
6025    */
6026
6027   const u32 lid = threadIdx.x;
6028
6029   u32x w0[4];
6030
6031   w0[0] = pws[gid].i[ 0];
6032   w0[1] = pws[gid].i[ 1];
6033   w0[2] = pws[gid].i[ 2];
6034   w0[3] = pws[gid].i[ 3];
6035
6036   u32x w1[4];
6037
6038   w1[0] = pws[gid].i[ 4];
6039   w1[1] = pws[gid].i[ 5];
6040   w1[2] = pws[gid].i[ 6];
6041   w1[3] = pws[gid].i[ 7];
6042
6043   u32x w2[4];
6044
6045   w2[0] = pws[gid].i[ 8];
6046   w2[1] = pws[gid].i[ 9];
6047   w2[2] = pws[gid].i[10];
6048   w2[3] = pws[gid].i[11];
6049
6050   u32x w3[4];
6051
6052   w3[0] = pws[gid].i[12];
6053   w3[1] = pws[gid].i[13];
6054   w3[2] = pws[gid].i[14];
6055   w3[3] = pws[gid].i[15];
6056
6057   const u32 pw_len = pws[gid].pw_len;
6058
6059   /**
6060    * bin2asc table
6061    */
6062
6063   l_bin2asc[lid] = c_bin2asc[(lid >> 0) & 15] << 8
6064                  | c_bin2asc[(lid >> 4) & 15] << 0;
6065
6066   __syncthreads ();
6067
6068   if (gid >= gid_max) return;
6069
6070   /**
6071    * main
6072    */
6073
6074   const u32 esalt_len = esalt_bufs[salt_pos].esalt_len;
6075   const u32 salt_len  = esalt_bufs[salt_pos].salt_len;
6076
6077   const u32 sw_1 = ((32 + esalt_len + 1) > 119);
6078   const u32 sw_2 = ((pw_len + salt_len)  >  55) << 1;
6079
6080   switch (sw_1 | sw_2)
6081   {
6082     case 0:
6083       m11400s_0_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6084       break;
6085     case 1:
6086       m11400s_0_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6087       break;
6088     case 2:
6089       m11400s_1_0 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6090       break;
6091     case 3:
6092       m11400s_1_1 (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
6093       break;
6094   }
6095 }