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