Fixed two major problems
[hashcat.git] / OpenCL / m09720_a3.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _OLDOFFICE01_
7
8 #define NEW_SIMD_CODE
9
10 #include "include/constants.h"
11 #include "include/kernel_vendor.h"
12
13 #define DGST_R0 0
14 #define DGST_R1 1
15 #define DGST_R2 2
16 #define DGST_R3 3
17
18 #include "include/kernel_functions.c"
19 #include "OpenCL/types_ocl.c"
20 #include "OpenCL/common.c"
21 #include "OpenCL/simd.c"
22
23 static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
24 {
25   u32x a = digest[0];
26   u32x b = digest[1];
27   u32x c = digest[2];
28   u32x d = digest[3];
29
30   u32x w0_t = w0[0];
31   u32x w1_t = w0[1];
32   u32x w2_t = w0[2];
33   u32x w3_t = w0[3];
34   u32x w4_t = w1[0];
35   u32x w5_t = w1[1];
36   u32x w6_t = w1[2];
37   u32x w7_t = w1[3];
38   u32x w8_t = w2[0];
39   u32x w9_t = w2[1];
40   u32x wa_t = w2[2];
41   u32x wb_t = w2[3];
42   u32x wc_t = w3[0];
43   u32x wd_t = w3[1];
44   u32x we_t = w3[2];
45   u32x wf_t = w3[3];
46
47   MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
48   MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
49   MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
50   MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
51   MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
52   MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
53   MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
54   MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
55   MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
56   MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
57   MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
58   MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
59   MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
60   MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
61   MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
62   MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
63
64   MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
65   MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
66   MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
67   MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
68   MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
69   MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
70   MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
71   MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
72   MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
73   MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
74   MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
75   MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
76   MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
77   MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
78   MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
79   MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
80
81   MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
82   MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
83   MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
84   MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
85   MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
86   MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
87   MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
88   MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
89   MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
90   MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
91   MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
92   MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
93   MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
94   MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
95   MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
96   MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
97
98   MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
99   MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
100   MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
101   MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
102   MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
103   MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
104   MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
105   MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
106   MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
107   MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
108   MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
109   MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
110   MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
111   MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
112   MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
113   MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
114
115   digest[0] += a;
116   digest[1] += b;
117   digest[2] += c;
118   digest[3] += d;
119 }
120
121 static void gen336 (u32x digest_pre[4], u32 salt_buf[4], u32x digest[4])
122 {
123   u32x digest_t0[2];
124   u32x digest_t1[2];
125   u32x digest_t2[2];
126   u32x digest_t3[2];
127
128   digest_t0[0] = digest_pre[0];
129   digest_t0[1] = digest_pre[1] & 0xff;
130
131   digest_t1[0] =                       digest_pre[0] <<  8;
132   digest_t1[1] = digest_pre[0] >> 24 | digest_pre[1] <<  8;
133
134   digest_t2[0] =                       digest_pre[0] << 16;
135   digest_t2[1] = digest_pre[0] >> 16 | digest_pre[1] << 16;
136
137   digest_t3[0] =                       digest_pre[0] << 24;
138   digest_t3[1] = digest_pre[0] >>  8 | digest_pre[1] << 24;
139
140   u32x salt_buf_t0[4];
141   u32x salt_buf_t1[5];
142   u32x salt_buf_t2[5];
143   u32x salt_buf_t3[5];
144
145   salt_buf_t0[0] = salt_buf[0];
146   salt_buf_t0[1] = salt_buf[1];
147   salt_buf_t0[2] = salt_buf[2];
148   salt_buf_t0[3] = salt_buf[3];
149
150   salt_buf_t1[0] =                     salt_buf[0] <<  8;
151   salt_buf_t1[1] = salt_buf[0] >> 24 | salt_buf[1] <<  8;
152   salt_buf_t1[2] = salt_buf[1] >> 24 | salt_buf[2] <<  8;
153   salt_buf_t1[3] = salt_buf[2] >> 24 | salt_buf[3] <<  8;
154   salt_buf_t1[4] = salt_buf[3] >> 24;
155
156   salt_buf_t2[0] =                     salt_buf[0] << 16;
157   salt_buf_t2[1] = salt_buf[0] >> 16 | salt_buf[1] << 16;
158   salt_buf_t2[2] = salt_buf[1] >> 16 | salt_buf[2] << 16;
159   salt_buf_t2[3] = salt_buf[2] >> 16 | salt_buf[3] << 16;
160   salt_buf_t2[4] = salt_buf[3] >> 16;
161
162   salt_buf_t3[0] =                     salt_buf[0] << 24;
163   salt_buf_t3[1] = salt_buf[0] >>  8 | salt_buf[1] << 24;
164   salt_buf_t3[2] = salt_buf[1] >>  8 | salt_buf[2] << 24;
165   salt_buf_t3[3] = salt_buf[2] >>  8 | salt_buf[3] << 24;
166   salt_buf_t3[4] = salt_buf[3] >>  8;
167
168   u32x w0_t[4];
169   u32x w1_t[4];
170   u32x w2_t[4];
171   u32x w3_t[4];
172
173   // generate the 16 * 21 buffer
174
175   w0_t[0] = 0;
176   w0_t[1] = 0;
177   w0_t[2] = 0;
178   w0_t[3] = 0;
179   w1_t[0] = 0;
180   w1_t[1] = 0;
181   w1_t[2] = 0;
182   w1_t[3] = 0;
183   w2_t[0] = 0;
184   w2_t[1] = 0;
185   w2_t[2] = 0;
186   w2_t[3] = 0;
187   w3_t[0] = 0;
188   w3_t[1] = 0;
189   w3_t[2] = 0;
190   w3_t[3] = 0;
191
192   // 0..5
193   w0_t[0]  = digest_t0[0];
194   w0_t[1]  = digest_t0[1];
195
196   // 5..21
197   w0_t[1] |= salt_buf_t1[0];
198   w0_t[2]  = salt_buf_t1[1];
199   w0_t[3]  = salt_buf_t1[2];
200   w1_t[0]  = salt_buf_t1[3];
201   w1_t[1]  = salt_buf_t1[4];
202
203   // 21..26
204   w1_t[1] |= digest_t1[0];
205   w1_t[2]  = digest_t1[1];
206
207   // 26..42
208   w1_t[2] |= salt_buf_t2[0];
209   w1_t[3]  = salt_buf_t2[1];
210   w2_t[0]  = salt_buf_t2[2];
211   w2_t[1]  = salt_buf_t2[3];
212   w2_t[2]  = salt_buf_t2[4];
213
214   // 42..47
215   w2_t[2] |= digest_t2[0];
216   w2_t[3]  = digest_t2[1];
217
218   // 47..63
219   w2_t[3] |= salt_buf_t3[0];
220   w3_t[0]  = salt_buf_t3[1];
221   w3_t[1]  = salt_buf_t3[2];
222   w3_t[2]  = salt_buf_t3[3];
223   w3_t[3]  = salt_buf_t3[4];
224
225   // 63..
226
227   w3_t[3] |= digest_t3[0];
228
229   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
230
231   w0_t[0] = 0;
232   w0_t[1] = 0;
233   w0_t[2] = 0;
234   w0_t[3] = 0;
235   w1_t[0] = 0;
236   w1_t[1] = 0;
237   w1_t[2] = 0;
238   w1_t[3] = 0;
239   w2_t[0] = 0;
240   w2_t[1] = 0;
241   w2_t[2] = 0;
242   w2_t[3] = 0;
243   w3_t[0] = 0;
244   w3_t[1] = 0;
245   w3_t[2] = 0;
246   w3_t[3] = 0;
247
248   // 0..4
249   w0_t[0]  = digest_t3[1];
250
251   // 4..20
252   w0_t[1]  = salt_buf_t0[0];
253   w0_t[2]  = salt_buf_t0[1];
254   w0_t[3]  = salt_buf_t0[2];
255   w1_t[0]  = salt_buf_t0[3];
256
257   // 20..25
258   w1_t[1]  = digest_t0[0];
259   w1_t[2]  = digest_t0[1];
260
261   // 25..41
262   w1_t[2] |= salt_buf_t1[0];
263   w1_t[3]  = salt_buf_t1[1];
264   w2_t[0]  = salt_buf_t1[2];
265   w2_t[1]  = salt_buf_t1[3];
266   w2_t[2]  = salt_buf_t1[4];
267
268   // 41..46
269   w2_t[2] |= digest_t1[0];
270   w2_t[3]  = digest_t1[1];
271
272   // 46..62
273   w2_t[3] |= salt_buf_t2[0];
274   w3_t[0]  = salt_buf_t2[1];
275   w3_t[1]  = salt_buf_t2[2];
276   w3_t[2]  = salt_buf_t2[3];
277   w3_t[3]  = salt_buf_t2[4];
278
279   // 62..
280   w3_t[3] |= digest_t2[0];
281
282   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
283
284   w0_t[0] = 0;
285   w0_t[1] = 0;
286   w0_t[2] = 0;
287   w0_t[3] = 0;
288   w1_t[0] = 0;
289   w1_t[1] = 0;
290   w1_t[2] = 0;
291   w1_t[3] = 0;
292   w2_t[0] = 0;
293   w2_t[1] = 0;
294   w2_t[2] = 0;
295   w2_t[3] = 0;
296   w3_t[0] = 0;
297   w3_t[1] = 0;
298   w3_t[2] = 0;
299   w3_t[3] = 0;
300
301   // 0..3
302   w0_t[0]  = digest_t2[1];
303
304   // 3..19
305   w0_t[0] |= salt_buf_t3[0];
306   w0_t[1]  = salt_buf_t3[1];
307   w0_t[2]  = salt_buf_t3[2];
308   w0_t[3]  = salt_buf_t3[3];
309   w1_t[0]  = salt_buf_t3[4];
310
311   // 19..24
312   w1_t[0] |= digest_t3[0];
313   w1_t[1]  = digest_t3[1];
314
315   // 24..40
316   w1_t[2]  = salt_buf_t0[0];
317   w1_t[3]  = salt_buf_t0[1];
318   w2_t[0]  = salt_buf_t0[2];
319   w2_t[1]  = salt_buf_t0[3];
320
321   // 40..45
322   w2_t[2]  = digest_t0[0];
323   w2_t[3]  = digest_t0[1];
324
325   // 45..61
326   w2_t[3] |= salt_buf_t1[0];
327   w3_t[0]  = salt_buf_t1[1];
328   w3_t[1]  = salt_buf_t1[2];
329   w3_t[2]  = salt_buf_t1[3];
330   w3_t[3]  = salt_buf_t1[4];
331
332   // 61..
333   w3_t[3] |= digest_t1[0];
334
335   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
336
337   w0_t[0] = 0;
338   w0_t[1] = 0;
339   w0_t[2] = 0;
340   w0_t[3] = 0;
341   w1_t[0] = 0;
342   w1_t[1] = 0;
343   w1_t[2] = 0;
344   w1_t[3] = 0;
345   w2_t[0] = 0;
346   w2_t[1] = 0;
347   w2_t[2] = 0;
348   w2_t[3] = 0;
349   w3_t[0] = 0;
350   w3_t[1] = 0;
351   w3_t[2] = 0;
352   w3_t[3] = 0;
353
354   // 0..2
355   w0_t[0]  = digest_t1[1];
356
357   // 2..18
358   w0_t[0] |= salt_buf_t2[0];
359   w0_t[1]  = salt_buf_t2[1];
360   w0_t[2]  = salt_buf_t2[2];
361   w0_t[3]  = salt_buf_t2[3];
362   w1_t[0]  = salt_buf_t2[4];
363
364   // 18..23
365   w1_t[0] |= digest_t2[0];
366   w1_t[1]  = digest_t2[1];
367
368   // 23..39
369   w1_t[1] |= salt_buf_t3[0];
370   w1_t[2]  = salt_buf_t3[1];
371   w1_t[3]  = salt_buf_t3[2];
372   w2_t[0]  = salt_buf_t3[3];
373   w2_t[1]  = salt_buf_t3[4];
374
375   // 39..44
376   w2_t[1] |= digest_t3[0];
377   w2_t[2]  = digest_t3[1];
378
379   // 44..60
380   w2_t[3]  = salt_buf_t0[0];
381   w3_t[0]  = salt_buf_t0[1];
382   w3_t[1]  = salt_buf_t0[2];
383   w3_t[2]  = salt_buf_t0[3];
384
385   // 60..
386   w3_t[3]  = digest_t0[0];
387
388   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
389
390   w0_t[0] = 0;
391   w0_t[1] = 0;
392   w0_t[2] = 0;
393   w0_t[3] = 0;
394   w1_t[0] = 0;
395   w1_t[1] = 0;
396   w1_t[2] = 0;
397   w1_t[3] = 0;
398   w2_t[0] = 0;
399   w2_t[1] = 0;
400   w2_t[2] = 0;
401   w2_t[3] = 0;
402   w3_t[0] = 0;
403   w3_t[1] = 0;
404   w3_t[2] = 0;
405   w3_t[3] = 0;
406
407   // 0..1
408   w0_t[0]  = digest_t0[1];
409
410   // 1..17
411   w0_t[0] |= salt_buf_t1[0];
412   w0_t[1]  = salt_buf_t1[1];
413   w0_t[2]  = salt_buf_t1[2];
414   w0_t[3]  = salt_buf_t1[3];
415   w1_t[0]  = salt_buf_t1[4];
416
417   // 17..22
418   w1_t[0] |= digest_t1[0];
419   w1_t[1]  = digest_t1[1];
420
421   // 22..38
422   w1_t[1] |= salt_buf_t2[0];
423   w1_t[2]  = salt_buf_t2[1];
424   w1_t[3]  = salt_buf_t2[2];
425   w2_t[0]  = salt_buf_t2[3];
426   w2_t[1]  = salt_buf_t2[4];
427
428   // 38..43
429   w2_t[1] |= digest_t2[0];
430   w2_t[2]  = digest_t2[1];
431
432   // 43..59
433   w2_t[2] |= salt_buf_t3[0];
434   w2_t[3]  = salt_buf_t3[1];
435   w3_t[0]  = salt_buf_t3[2];
436   w3_t[1]  = salt_buf_t3[3];
437   w3_t[2]  = salt_buf_t3[4];
438
439   // 59..
440   w3_t[2] |= digest_t3[0];
441   w3_t[3]  = digest_t3[1];
442
443   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
444
445   w0_t[0]  = salt_buf_t0[0];
446   w0_t[1]  = salt_buf_t0[1];
447   w0_t[2]  = salt_buf_t0[2];
448   w0_t[3]  = salt_buf_t0[3];
449   w1_t[0]  = 0x80;
450   w1_t[1]  = 0;
451   w1_t[2]  = 0;
452   w1_t[3]  = 0;
453   w2_t[0]  = 0;
454   w2_t[1]  = 0;
455   w2_t[2]  = 0;
456   w2_t[3]  = 0;
457   w3_t[0]  = 0;
458   w3_t[1]  = 0;
459   w3_t[2]  = 21 * 16 * 8;
460   w3_t[3]  = 0;
461
462   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
463 }
464
465 static void m09720m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset)
466 {
467   /**
468    * modifier
469    */
470
471   const u32 gid = get_global_id (0);
472   const u32 lid = get_local_id (0);
473
474   /**
475    * salt
476    */
477
478   u32 salt_buf[4];
479
480   salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
481   salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
482   salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
483   salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
484
485   /**
486    * loop
487    */
488
489   u32 w0l = w0[0];
490
491   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
492   {
493     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
494
495     const u32x w0lr = w0l | w0r;
496
497     u32x w0_t[4];
498     u32x w1_t[4];
499     u32x w2_t[4];
500     u32x w3_t[4];
501
502     w0_t[0] = w0lr;
503     w0_t[1] = w0[1];
504     w0_t[2] = w0[2];
505     w0_t[3] = w0[3];
506     w1_t[0] = w1[0];
507     w1_t[1] = w1[1];
508     w1_t[2] = w1[2];
509     w1_t[3] = w1[3];
510     w2_t[0] = w2[0];
511     w2_t[1] = w2[1];
512     w2_t[2] = w2[2];
513     w2_t[3] = w2[3];
514     w3_t[0] = w3[0];
515     w3_t[1] = w3[1];
516     w3_t[2] = pw_len * 8;
517     w3_t[3] = 0;
518
519     u32x digest_pre[4];
520
521     digest_pre[0] = MD5M_A;
522     digest_pre[1] = MD5M_B;
523     digest_pre[2] = MD5M_C;
524     digest_pre[3] = MD5M_D;
525
526     md5_transform (w0_t, w1_t, w2_t, w3_t, digest_pre);
527
528     digest_pre[0] &= 0xffffffff;
529     digest_pre[1] &= 0x000000ff;
530     digest_pre[2] &= 0x00000000;
531     digest_pre[3] &= 0x00000000;
532
533     u32x digest[4];
534
535     digest[0] = MD5M_A;
536     digest[1] = MD5M_B;
537     digest[2] = MD5M_C;
538     digest[3] = MD5M_D;
539
540     gen336 (digest_pre, salt_buf, digest);
541
542     u32x a = digest[0];
543     u32x b = digest[1] & 0xff;
544     u32x c = 0;
545     u32x d = 0;
546
547     COMPARE_M_SIMD (a, b, c, d);
548   }
549 }
550
551 static void m09720s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset)
552 {
553   /**
554    * modifier
555    */
556
557   const u32 gid = get_global_id (0);
558   const u32 lid = get_local_id (0);
559
560   /**
561    * digest
562    */
563
564   const u32 search[4] =
565   {
566     digests_buf[digests_offset].digest_buf[DGST_R0],
567     digests_buf[digests_offset].digest_buf[DGST_R1],
568     digests_buf[digests_offset].digest_buf[DGST_R2],
569     digests_buf[digests_offset].digest_buf[DGST_R3]
570   };
571
572   /**
573    * salt
574    */
575
576   u32 salt_buf[4];
577
578   salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
579   salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
580   salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
581   salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
582
583   /**
584    * loop
585    */
586
587   u32 w0l = w0[0];
588
589   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
590   {
591     const u32x w0r = ix_create_bft (bfs_buf, il_pos);
592
593     const u32x w0lr = w0l | w0r;
594
595     u32x w0_t[4];
596     u32x w1_t[4];
597     u32x w2_t[4];
598     u32x w3_t[4];
599
600     w0_t[0] = w0lr;
601     w0_t[1] = w0[1];
602     w0_t[2] = w0[2];
603     w0_t[3] = w0[3];
604     w1_t[0] = w1[0];
605     w1_t[1] = w1[1];
606     w1_t[2] = w1[2];
607     w1_t[3] = w1[3];
608     w2_t[0] = w2[0];
609     w2_t[1] = w2[1];
610     w2_t[2] = w2[2];
611     w2_t[3] = w2[3];
612     w3_t[0] = w3[0];
613     w3_t[1] = w3[1];
614     w3_t[2] = pw_len * 8;
615     w3_t[3] = 0;
616
617     u32x digest_pre[4];
618
619     digest_pre[0] = MD5M_A;
620     digest_pre[1] = MD5M_B;
621     digest_pre[2] = MD5M_C;
622     digest_pre[3] = MD5M_D;
623
624     md5_transform (w0_t, w1_t, w2_t, w3_t, digest_pre);
625
626     digest_pre[0] &= 0xffffffff;
627     digest_pre[1] &= 0x000000ff;
628     digest_pre[2] &= 0x00000000;
629     digest_pre[3] &= 0x00000000;
630
631     u32x digest[4];
632
633     digest[0] = MD5M_A;
634     digest[1] = MD5M_B;
635     digest[2] = MD5M_C;
636     digest[3] = MD5M_D;
637
638     gen336 (digest_pre, salt_buf, digest);
639
640     u32x a = digest[0];
641     u32x b = digest[1] & 0xff;
642     u32x c = 0;
643     u32x d = 0;
644
645     COMPARE_S_SIMD (a, b, c, d);
646   }
647 }
648
649 __kernel void m09720_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
650 {
651   /**
652    * base
653    */
654
655   const u32 gid = get_global_id (0);
656
657   if (gid >= gid_max) return;
658
659   u32 w0[4];
660
661   w0[0] = pws[gid].i[ 0];
662   w0[1] = pws[gid].i[ 1];
663   w0[2] = pws[gid].i[ 2];
664   w0[3] = pws[gid].i[ 3];
665
666   u32 w1[4];
667
668   w1[0] = 0;
669   w1[1] = 0;
670   w1[2] = 0;
671   w1[3] = 0;
672
673   u32 w2[4];
674
675   w2[0] = 0;
676   w2[1] = 0;
677   w2[2] = 0;
678   w2[3] = 0;
679
680   u32 w3[4];
681
682   w3[0] = 0;
683   w3[1] = 0;
684   w3[2] = 0;
685   w3[3] = 0;
686
687   const u32 pw_len = pws[gid].pw_len;
688
689   /**
690    * main
691    */
692
693   m09720m (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, oldoffice01_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
694 }
695
696 __kernel void m09720_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
697 {
698   /**
699    * base
700    */
701
702   const u32 gid = get_global_id (0);
703
704   if (gid >= gid_max) return;
705
706   u32 w0[4];
707
708   w0[0] = pws[gid].i[ 0];
709   w0[1] = pws[gid].i[ 1];
710   w0[2] = pws[gid].i[ 2];
711   w0[3] = pws[gid].i[ 3];
712
713   u32 w1[4];
714
715   w1[0] = pws[gid].i[ 4];
716   w1[1] = pws[gid].i[ 5];
717   w1[2] = pws[gid].i[ 6];
718   w1[3] = pws[gid].i[ 7];
719
720   u32 w2[4];
721
722   w2[0] = 0;
723   w2[1] = 0;
724   w2[2] = 0;
725   w2[3] = 0;
726
727   u32 w3[4];
728
729   w3[0] = 0;
730   w3[1] = 0;
731   w3[2] = 0;
732   w3[3] = 0;
733
734   const u32 pw_len = pws[gid].pw_len;
735
736   /**
737    * main
738    */
739
740   m09720m (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, oldoffice01_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
741 }
742
743 __kernel void m09720_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
744 {
745   /**
746    * base
747    */
748
749   const u32 gid = get_global_id (0);
750
751   if (gid >= gid_max) return;
752
753   u32 w0[4];
754
755   w0[0] = pws[gid].i[ 0];
756   w0[1] = pws[gid].i[ 1];
757   w0[2] = pws[gid].i[ 2];
758   w0[3] = pws[gid].i[ 3];
759
760   u32 w1[4];
761
762   w1[0] = pws[gid].i[ 4];
763   w1[1] = pws[gid].i[ 5];
764   w1[2] = pws[gid].i[ 6];
765   w1[3] = pws[gid].i[ 7];
766
767   u32 w2[4];
768
769   w2[0] = pws[gid].i[ 8];
770   w2[1] = pws[gid].i[ 9];
771   w2[2] = pws[gid].i[10];
772   w2[3] = pws[gid].i[11];
773
774   u32 w3[4];
775
776   w3[0] = pws[gid].i[12];
777   w3[1] = pws[gid].i[13];
778   w3[2] = 0;
779   w3[3] = 0;
780
781   const u32 pw_len = pws[gid].pw_len;
782
783   /**
784    * main
785    */
786
787   m09720m (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, oldoffice01_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
788 }
789
790 __kernel void m09720_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
791 {
792   /**
793    * base
794    */
795
796   const u32 gid = get_global_id (0);
797
798   if (gid >= gid_max) return;
799
800   u32 w0[4];
801
802   w0[0] = pws[gid].i[ 0];
803   w0[1] = pws[gid].i[ 1];
804   w0[2] = pws[gid].i[ 2];
805   w0[3] = pws[gid].i[ 3];
806
807   u32 w1[4];
808
809   w1[0] = 0;
810   w1[1] = 0;
811   w1[2] = 0;
812   w1[3] = 0;
813
814   u32 w2[4];
815
816   w2[0] = 0;
817   w2[1] = 0;
818   w2[2] = 0;
819   w2[3] = 0;
820
821   u32 w3[4];
822
823   w3[0] = 0;
824   w3[1] = 0;
825   w3[2] = 0;
826   w3[3] = 0;
827
828   const u32 pw_len = pws[gid].pw_len;
829
830   /**
831    * main
832    */
833
834   m09720s (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, oldoffice01_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
835 }
836
837 __kernel void m09720_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
838 {
839   /**
840    * base
841    */
842
843   const u32 gid = get_global_id (0);
844
845   if (gid >= gid_max) return;
846
847   u32 w0[4];
848
849   w0[0] = pws[gid].i[ 0];
850   w0[1] = pws[gid].i[ 1];
851   w0[2] = pws[gid].i[ 2];
852   w0[3] = pws[gid].i[ 3];
853
854   u32 w1[4];
855
856   w1[0] = pws[gid].i[ 4];
857   w1[1] = pws[gid].i[ 5];
858   w1[2] = pws[gid].i[ 6];
859   w1[3] = pws[gid].i[ 7];
860
861   u32 w2[4];
862
863   w2[0] = 0;
864   w2[1] = 0;
865   w2[2] = 0;
866   w2[3] = 0;
867
868   u32 w3[4];
869
870   w3[0] = 0;
871   w3[1] = 0;
872   w3[2] = 0;
873   w3[3] = 0;
874
875   const u32 pw_len = pws[gid].pw_len;
876
877   /**
878    * main
879    */
880
881   m09720s (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, oldoffice01_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
882 }
883
884 __kernel void m09720_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global oldoffice01_t *oldoffice01_bufs, __global u32 *d_return_buf, __global 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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
885 {
886   /**
887    * base
888    */
889
890   const u32 gid = get_global_id (0);
891
892   if (gid >= gid_max) return;
893
894   u32 w0[4];
895
896   w0[0] = pws[gid].i[ 0];
897   w0[1] = pws[gid].i[ 1];
898   w0[2] = pws[gid].i[ 2];
899   w0[3] = pws[gid].i[ 3];
900
901   u32 w1[4];
902
903   w1[0] = pws[gid].i[ 4];
904   w1[1] = pws[gid].i[ 5];
905   w1[2] = pws[gid].i[ 6];
906   w1[3] = pws[gid].i[ 7];
907
908   u32 w2[4];
909
910   w2[0] = pws[gid].i[ 8];
911   w2[1] = pws[gid].i[ 9];
912   w2[2] = pws[gid].i[10];
913   w2[3] = pws[gid].i[11];
914
915   u32 w3[4];
916
917   w3[0] = pws[gid].i[12];
918   w3[1] = pws[gid].i[13];
919   w3[2] = 0;
920   w3[3] = 0;
921
922   const u32 pw_len = pws[gid].pw_len;
923
924   /**
925    * main
926    */
927
928   m09720s (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, oldoffice01_bufs, d_return_buf, d_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
929 }