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