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