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