Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m09720_a0.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 "inc_vendor.cl"
11 #include "inc_hash_constants.h"
12 #include "inc_hash_functions.cl"
13 #include "inc_types.cl"
14 #include "inc_common.cl"
15 #include "inc_rp.h"
16 #include "inc_rp.cl"
17 #include "inc_simd.cl"
18
19 void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
20 {
21   u32x a = digest[0];
22   u32x b = digest[1];
23   u32x c = digest[2];
24   u32x d = digest[3];
25
26   u32x w0_t = w0[0];
27   u32x w1_t = w0[1];
28   u32x w2_t = w0[2];
29   u32x w3_t = w0[3];
30   u32x w4_t = w1[0];
31   u32x w5_t = w1[1];
32   u32x w6_t = w1[2];
33   u32x w7_t = w1[3];
34   u32x w8_t = w2[0];
35   u32x w9_t = w2[1];
36   u32x wa_t = w2[2];
37   u32x wb_t = w2[3];
38   u32x wc_t = w3[0];
39   u32x wd_t = w3[1];
40   u32x we_t = w3[2];
41   u32x wf_t = w3[3];
42
43   MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
44   MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
45   MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
46   MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
47   MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
48   MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
49   MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
50   MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
51   MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
52   MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
53   MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
54   MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
55   MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
56   MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
57   MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
58   MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
59
60   MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
61   MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
62   MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
63   MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
64   MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
65   MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
66   MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
67   MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
68   MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
69   MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
70   MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
71   MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
72   MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
73   MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
74   MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
75   MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
76
77   MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
78   MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
79   MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
80   MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
81   MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
82   MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
83   MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
84   MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
85   MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
86   MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
87   MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
88   MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
89   MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
90   MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
91   MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
92   MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
93
94   MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
95   MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
96   MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
97   MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
98   MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
99   MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
100   MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
101   MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
102   MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
103   MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
104   MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
105   MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
106   MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
107   MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
108   MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
109   MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
110
111   digest[0] += a;
112   digest[1] += b;
113   digest[2] += c;
114   digest[3] += d;
115 }
116
117 void gen336 (u32x digest_pre[4], u32 salt_buf[4], u32x digest[4])
118 {
119   u32x digest_t0[2];
120   u32x digest_t1[2];
121   u32x digest_t2[2];
122   u32x digest_t3[2];
123
124   digest_t0[0] = digest_pre[0];
125   digest_t0[1] = digest_pre[1] & 0xff;
126
127   digest_t1[0] =                       digest_pre[0] <<  8;
128   digest_t1[1] = digest_pre[0] >> 24 | digest_pre[1] <<  8;
129
130   digest_t2[0] =                       digest_pre[0] << 16;
131   digest_t2[1] = digest_pre[0] >> 16 | digest_pre[1] << 16;
132
133   digest_t3[0] =                       digest_pre[0] << 24;
134   digest_t3[1] = digest_pre[0] >>  8 | digest_pre[1] << 24;
135
136   u32x salt_buf_t0[4];
137   u32x salt_buf_t1[5];
138   u32x salt_buf_t2[5];
139   u32x salt_buf_t3[5];
140
141   salt_buf_t0[0] = salt_buf[0];
142   salt_buf_t0[1] = salt_buf[1];
143   salt_buf_t0[2] = salt_buf[2];
144   salt_buf_t0[3] = salt_buf[3];
145
146   salt_buf_t1[0] =                     salt_buf[0] <<  8;
147   salt_buf_t1[1] = salt_buf[0] >> 24 | salt_buf[1] <<  8;
148   salt_buf_t1[2] = salt_buf[1] >> 24 | salt_buf[2] <<  8;
149   salt_buf_t1[3] = salt_buf[2] >> 24 | salt_buf[3] <<  8;
150   salt_buf_t1[4] = salt_buf[3] >> 24;
151
152   salt_buf_t2[0] =                     salt_buf[0] << 16;
153   salt_buf_t2[1] = salt_buf[0] >> 16 | salt_buf[1] << 16;
154   salt_buf_t2[2] = salt_buf[1] >> 16 | salt_buf[2] << 16;
155   salt_buf_t2[3] = salt_buf[2] >> 16 | salt_buf[3] << 16;
156   salt_buf_t2[4] = salt_buf[3] >> 16;
157
158   salt_buf_t3[0] =                     salt_buf[0] << 24;
159   salt_buf_t3[1] = salt_buf[0] >>  8 | salt_buf[1] << 24;
160   salt_buf_t3[2] = salt_buf[1] >>  8 | salt_buf[2] << 24;
161   salt_buf_t3[3] = salt_buf[2] >>  8 | salt_buf[3] << 24;
162   salt_buf_t3[4] = salt_buf[3] >>  8;
163
164   u32x w0_t[4];
165   u32x w1_t[4];
166   u32x w2_t[4];
167   u32x w3_t[4];
168
169   // generate the 16 * 21 buffer
170
171   w0_t[0] = 0;
172   w0_t[1] = 0;
173   w0_t[2] = 0;
174   w0_t[3] = 0;
175   w1_t[0] = 0;
176   w1_t[1] = 0;
177   w1_t[2] = 0;
178   w1_t[3] = 0;
179   w2_t[0] = 0;
180   w2_t[1] = 0;
181   w2_t[2] = 0;
182   w2_t[3] = 0;
183   w3_t[0] = 0;
184   w3_t[1] = 0;
185   w3_t[2] = 0;
186   w3_t[3] = 0;
187
188   // 0..5
189   w0_t[0]  = digest_t0[0];
190   w0_t[1]  = digest_t0[1];
191
192   // 5..21
193   w0_t[1] |= salt_buf_t1[0];
194   w0_t[2]  = salt_buf_t1[1];
195   w0_t[3]  = salt_buf_t1[2];
196   w1_t[0]  = salt_buf_t1[3];
197   w1_t[1]  = salt_buf_t1[4];
198
199   // 21..26
200   w1_t[1] |= digest_t1[0];
201   w1_t[2]  = digest_t1[1];
202
203   // 26..42
204   w1_t[2] |= salt_buf_t2[0];
205   w1_t[3]  = salt_buf_t2[1];
206   w2_t[0]  = salt_buf_t2[2];
207   w2_t[1]  = salt_buf_t2[3];
208   w2_t[2]  = salt_buf_t2[4];
209
210   // 42..47
211   w2_t[2] |= digest_t2[0];
212   w2_t[3]  = digest_t2[1];
213
214   // 47..63
215   w2_t[3] |= salt_buf_t3[0];
216   w3_t[0]  = salt_buf_t3[1];
217   w3_t[1]  = salt_buf_t3[2];
218   w3_t[2]  = salt_buf_t3[3];
219   w3_t[3]  = salt_buf_t3[4];
220
221   // 63..
222
223   w3_t[3] |= digest_t3[0];
224
225   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
226
227   w0_t[0] = 0;
228   w0_t[1] = 0;
229   w0_t[2] = 0;
230   w0_t[3] = 0;
231   w1_t[0] = 0;
232   w1_t[1] = 0;
233   w1_t[2] = 0;
234   w1_t[3] = 0;
235   w2_t[0] = 0;
236   w2_t[1] = 0;
237   w2_t[2] = 0;
238   w2_t[3] = 0;
239   w3_t[0] = 0;
240   w3_t[1] = 0;
241   w3_t[2] = 0;
242   w3_t[3] = 0;
243
244   // 0..4
245   w0_t[0]  = digest_t3[1];
246
247   // 4..20
248   w0_t[1]  = salt_buf_t0[0];
249   w0_t[2]  = salt_buf_t0[1];
250   w0_t[3]  = salt_buf_t0[2];
251   w1_t[0]  = salt_buf_t0[3];
252
253   // 20..25
254   w1_t[1]  = digest_t0[0];
255   w1_t[2]  = digest_t0[1];
256
257   // 25..41
258   w1_t[2] |= salt_buf_t1[0];
259   w1_t[3]  = salt_buf_t1[1];
260   w2_t[0]  = salt_buf_t1[2];
261   w2_t[1]  = salt_buf_t1[3];
262   w2_t[2]  = salt_buf_t1[4];
263
264   // 41..46
265   w2_t[2] |= digest_t1[0];
266   w2_t[3]  = digest_t1[1];
267
268   // 46..62
269   w2_t[3] |= salt_buf_t2[0];
270   w3_t[0]  = salt_buf_t2[1];
271   w3_t[1]  = salt_buf_t2[2];
272   w3_t[2]  = salt_buf_t2[3];
273   w3_t[3]  = salt_buf_t2[4];
274
275   // 62..
276   w3_t[3] |= digest_t2[0];
277
278   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
279
280   w0_t[0] = 0;
281   w0_t[1] = 0;
282   w0_t[2] = 0;
283   w0_t[3] = 0;
284   w1_t[0] = 0;
285   w1_t[1] = 0;
286   w1_t[2] = 0;
287   w1_t[3] = 0;
288   w2_t[0] = 0;
289   w2_t[1] = 0;
290   w2_t[2] = 0;
291   w2_t[3] = 0;
292   w3_t[0] = 0;
293   w3_t[1] = 0;
294   w3_t[2] = 0;
295   w3_t[3] = 0;
296
297   // 0..3
298   w0_t[0]  = digest_t2[1];
299
300   // 3..19
301   w0_t[0] |= salt_buf_t3[0];
302   w0_t[1]  = salt_buf_t3[1];
303   w0_t[2]  = salt_buf_t3[2];
304   w0_t[3]  = salt_buf_t3[3];
305   w1_t[0]  = salt_buf_t3[4];
306
307   // 19..24
308   w1_t[0] |= digest_t3[0];
309   w1_t[1]  = digest_t3[1];
310
311   // 24..40
312   w1_t[2]  = salt_buf_t0[0];
313   w1_t[3]  = salt_buf_t0[1];
314   w2_t[0]  = salt_buf_t0[2];
315   w2_t[1]  = salt_buf_t0[3];
316
317   // 40..45
318   w2_t[2]  = digest_t0[0];
319   w2_t[3]  = digest_t0[1];
320
321   // 45..61
322   w2_t[3] |= salt_buf_t1[0];
323   w3_t[0]  = salt_buf_t1[1];
324   w3_t[1]  = salt_buf_t1[2];
325   w3_t[2]  = salt_buf_t1[3];
326   w3_t[3]  = salt_buf_t1[4];
327
328   // 61..
329   w3_t[3] |= digest_t1[0];
330
331   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
332
333   w0_t[0] = 0;
334   w0_t[1] = 0;
335   w0_t[2] = 0;
336   w0_t[3] = 0;
337   w1_t[0] = 0;
338   w1_t[1] = 0;
339   w1_t[2] = 0;
340   w1_t[3] = 0;
341   w2_t[0] = 0;
342   w2_t[1] = 0;
343   w2_t[2] = 0;
344   w2_t[3] = 0;
345   w3_t[0] = 0;
346   w3_t[1] = 0;
347   w3_t[2] = 0;
348   w3_t[3] = 0;
349
350   // 0..2
351   w0_t[0]  = digest_t1[1];
352
353   // 2..18
354   w0_t[0] |= salt_buf_t2[0];
355   w0_t[1]  = salt_buf_t2[1];
356   w0_t[2]  = salt_buf_t2[2];
357   w0_t[3]  = salt_buf_t2[3];
358   w1_t[0]  = salt_buf_t2[4];
359
360   // 18..23
361   w1_t[0] |= digest_t2[0];
362   w1_t[1]  = digest_t2[1];
363
364   // 23..39
365   w1_t[1] |= salt_buf_t3[0];
366   w1_t[2]  = salt_buf_t3[1];
367   w1_t[3]  = salt_buf_t3[2];
368   w2_t[0]  = salt_buf_t3[3];
369   w2_t[1]  = salt_buf_t3[4];
370
371   // 39..44
372   w2_t[1] |= digest_t3[0];
373   w2_t[2]  = digest_t3[1];
374
375   // 44..60
376   w2_t[3]  = salt_buf_t0[0];
377   w3_t[0]  = salt_buf_t0[1];
378   w3_t[1]  = salt_buf_t0[2];
379   w3_t[2]  = salt_buf_t0[3];
380
381   // 60..
382   w3_t[3]  = digest_t0[0];
383
384   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
385
386   w0_t[0] = 0;
387   w0_t[1] = 0;
388   w0_t[2] = 0;
389   w0_t[3] = 0;
390   w1_t[0] = 0;
391   w1_t[1] = 0;
392   w1_t[2] = 0;
393   w1_t[3] = 0;
394   w2_t[0] = 0;
395   w2_t[1] = 0;
396   w2_t[2] = 0;
397   w2_t[3] = 0;
398   w3_t[0] = 0;
399   w3_t[1] = 0;
400   w3_t[2] = 0;
401   w3_t[3] = 0;
402
403   // 0..1
404   w0_t[0]  = digest_t0[1];
405
406   // 1..17
407   w0_t[0] |= salt_buf_t1[0];
408   w0_t[1]  = salt_buf_t1[1];
409   w0_t[2]  = salt_buf_t1[2];
410   w0_t[3]  = salt_buf_t1[3];
411   w1_t[0]  = salt_buf_t1[4];
412
413   // 17..22
414   w1_t[0] |= digest_t1[0];
415   w1_t[1]  = digest_t1[1];
416
417   // 22..38
418   w1_t[1] |= salt_buf_t2[0];
419   w1_t[2]  = salt_buf_t2[1];
420   w1_t[3]  = salt_buf_t2[2];
421   w2_t[0]  = salt_buf_t2[3];
422   w2_t[1]  = salt_buf_t2[4];
423
424   // 38..43
425   w2_t[1] |= digest_t2[0];
426   w2_t[2]  = digest_t2[1];
427
428   // 43..59
429   w2_t[2] |= salt_buf_t3[0];
430   w2_t[3]  = salt_buf_t3[1];
431   w3_t[0]  = salt_buf_t3[2];
432   w3_t[1]  = salt_buf_t3[3];
433   w3_t[2]  = salt_buf_t3[4];
434
435   // 59..
436   w3_t[2] |= digest_t3[0];
437   w3_t[3]  = digest_t3[1];
438
439   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
440
441   w0_t[0]  = salt_buf_t0[0];
442   w0_t[1]  = salt_buf_t0[1];
443   w0_t[2]  = salt_buf_t0[2];
444   w0_t[3]  = salt_buf_t0[3];
445   w1_t[0]  = 0x80;
446   w1_t[1]  = 0;
447   w1_t[2]  = 0;
448   w1_t[3]  = 0;
449   w2_t[0]  = 0;
450   w2_t[1]  = 0;
451   w2_t[2]  = 0;
452   w2_t[3]  = 0;
453   w3_t[0]  = 0;
454   w3_t[1]  = 0;
455   w3_t[2]  = 21 * 16 * 8;
456   w3_t[3]  = 0;
457
458   md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
459 }
460
461 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
462 {
463   /**
464    * modifier
465    */
466
467   const u32 lid = get_local_id (0);
468
469   /**
470    * base
471    */
472
473   const u32 gid = get_global_id (0);
474
475   if (gid >= gid_max) return;
476
477   u32 pw_buf0[4];
478   u32 pw_buf1[4];
479
480   pw_buf0[0] = pws[gid].i[ 0];
481   pw_buf0[1] = pws[gid].i[ 1];
482   pw_buf0[2] = pws[gid].i[ 2];
483   pw_buf0[3] = pws[gid].i[ 3];
484   pw_buf1[0] = pws[gid].i[ 4];
485   pw_buf1[1] = pws[gid].i[ 5];
486   pw_buf1[2] = pws[gid].i[ 6];
487   pw_buf1[3] = pws[gid].i[ 7];
488
489   const u32 pw_len = pws[gid].pw_len;
490
491   /**
492    * salt
493    */
494
495   u32 salt_buf[4];
496
497   salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
498   salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
499   salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
500   salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
501
502   /**
503    * loop
504    */
505
506   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
507   {
508     u32x w0[4] = { 0 };
509     u32x w1[4] = { 0 };
510     u32x w2[4] = { 0 };
511     u32x w3[4] = { 0 };
512
513     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
514
515     append_0x80_2x4_VV (w0, w1, out_len);
516
517     /**
518      * md5
519      */
520
521     make_unicode (w1, w2, w3);
522     make_unicode (w0, w0, w1);
523
524     w3[2] = out_len * 8 * 2;
525     w3[3] = 0;
526
527     u32x digest_pre[4];
528
529     digest_pre[0] = MD5M_A;
530     digest_pre[1] = MD5M_B;
531     digest_pre[2] = MD5M_C;
532     digest_pre[3] = MD5M_D;
533
534     md5_transform (w0, w1, w2, w3, digest_pre);
535
536     digest_pre[0] &= 0xffffffff;
537     digest_pre[1] &= 0x000000ff;
538     digest_pre[2] &= 0x00000000;
539     digest_pre[3] &= 0x00000000;
540
541     u32x digest[4];
542
543     digest[0] = MD5M_A;
544     digest[1] = MD5M_B;
545     digest[2] = MD5M_C;
546     digest[3] = MD5M_D;
547
548     gen336 (digest_pre, salt_buf, digest);
549
550     u32x a = digest[0];
551     u32x b = digest[1] & 0xff;
552     u32x c = 0;
553     u32x d = 0;
554
555     COMPARE_M_SIMD (a, b, c, d);
556   }
557 }
558
559 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
560 {
561 }
562
563 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
564 {
565 }
566
567 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
568 {
569   /**
570    * modifier
571    */
572
573   const u32 lid = get_local_id (0);
574
575   /**
576    * base
577    */
578
579   const u32 gid = get_global_id (0);
580
581   if (gid >= gid_max) return;
582
583   u32 pw_buf0[4];
584   u32 pw_buf1[4];
585
586   pw_buf0[0] = pws[gid].i[ 0];
587   pw_buf0[1] = pws[gid].i[ 1];
588   pw_buf0[2] = pws[gid].i[ 2];
589   pw_buf0[3] = pws[gid].i[ 3];
590   pw_buf1[0] = pws[gid].i[ 4];
591   pw_buf1[1] = pws[gid].i[ 5];
592   pw_buf1[2] = pws[gid].i[ 6];
593   pw_buf1[3] = pws[gid].i[ 7];
594
595   const u32 pw_len = pws[gid].pw_len;
596
597   /**
598    * salt
599    */
600
601   u32 salt_buf[4];
602
603   salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
604   salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
605   salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
606   salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
607
608   /**
609    * digest
610    */
611
612   const u32 search[4] =
613   {
614     digests_buf[digests_offset].digest_buf[DGST_R0],
615     digests_buf[digests_offset].digest_buf[DGST_R1],
616     digests_buf[digests_offset].digest_buf[DGST_R2],
617     digests_buf[digests_offset].digest_buf[DGST_R3]
618   };
619
620   /**
621    * loop
622    */
623
624   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
625   {
626     u32x w0[4] = { 0 };
627     u32x w1[4] = { 0 };
628     u32x w2[4] = { 0 };
629     u32x w3[4] = { 0 };
630
631     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
632
633     append_0x80_2x4_VV (w0, w1, out_len);
634
635     /**
636      * md5
637      */
638
639     make_unicode (w1, w2, w3);
640     make_unicode (w0, w0, w1);
641
642     w3[2] = out_len * 8 * 2;
643     w3[3] = 0;
644
645     u32x digest_pre[4];
646
647     digest_pre[0] = MD5M_A;
648     digest_pre[1] = MD5M_B;
649     digest_pre[2] = MD5M_C;
650     digest_pre[3] = MD5M_D;
651
652     md5_transform (w0, w1, w2, w3, digest_pre);
653
654     digest_pre[0] &= 0xffffffff;
655     digest_pre[1] &= 0x000000ff;
656     digest_pre[2] &= 0x00000000;
657     digest_pre[3] &= 0x00000000;
658
659     u32x digest[4];
660
661     digest[0] = MD5M_A;
662     digest[1] = MD5M_B;
663     digest[2] = MD5M_C;
664     digest[3] = MD5M_D;
665
666     gen336 (digest_pre, salt_buf, digest);
667
668     u32x a = digest[0];
669     u32x b = digest[1] & 0xff;
670     u32x c = 0;
671     u32x d = 0;
672
673     COMPARE_S_SIMD (a, b, c, d);
674   }
675 }
676
677 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
678 {
679 }
680
681 __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_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_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)
682 {
683 }