2 * Author......: Jens Steube <jens.steube@gmail.com>
8 //too much register pressure
9 //#define NEW_SIMD_CODE
11 #include "inc_hash_constants.h"
12 #include "inc_vendor.cl"
19 #include "inc_hash_functions.cl"
20 #include "inc_types.cl"
21 #include "inc_common.cl"
22 #include "inc_simd.cl"
32 void swap (__local RC4_KEY *rc4_key, const u8 i, const u8 j)
37 rc4_key->S[i] = rc4_key->S[j];
41 void rc4_init_16 (__local RC4_KEY *rc4_key, const u32 data[4])
46 __local u32 *ptr = (__local u32 *) rc4_key->S;
51 for (u32 i = 0; i < 64; i++)
58 for (u32 i = 0; i < 16; i++)
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++;
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++;
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++;
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++;
94 u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 in[4], u32 out[4])
99 for (u32 k = 0; k < 4; k++)
108 swap (rc4_key, i, j);
110 idx = rc4_key->S[i] + rc4_key->S[j];
112 xor4 |= rc4_key->S[idx] << 0;
117 swap (rc4_key, i, j);
119 idx = rc4_key->S[i] + rc4_key->S[j];
121 xor4 |= rc4_key->S[idx] << 8;
126 swap (rc4_key, i, j);
128 idx = rc4_key->S[i] + rc4_key->S[j];
130 xor4 |= rc4_key->S[idx] << 16;
135 swap (rc4_key, i, j);
137 idx = rc4_key->S[i] + rc4_key->S[j];
139 xor4 |= rc4_key->S[idx] << 24;
141 out[k] = in[k] ^ xor4;
147 void md5_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4])
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);
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);
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);
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);
245 void gen336 (u32 digest_pre[4], u32 salt_buf[4], u32 digest[4])
252 digest_t0[0] = digest_pre[0];
253 digest_t0[1] = digest_pre[1] & 0xff;
255 digest_t1[0] = digest_pre[0] << 8;
256 digest_t1[1] = digest_pre[0] >> 24 | digest_pre[1] << 8;
258 digest_t2[0] = digest_pre[0] << 16;
259 digest_t2[1] = digest_pre[0] >> 16 | digest_pre[1] << 16;
261 digest_t3[0] = digest_pre[0] << 24;
262 digest_t3[1] = digest_pre[0] >> 8 | digest_pre[1] << 24;
269 salt_buf_t0[0] = salt_buf[0];
270 salt_buf_t0[1] = salt_buf[1];
271 salt_buf_t0[2] = salt_buf[2];
272 salt_buf_t0[3] = salt_buf[3];
274 salt_buf_t1[0] = salt_buf[0] << 8;
275 salt_buf_t1[1] = salt_buf[0] >> 24 | salt_buf[1] << 8;
276 salt_buf_t1[2] = salt_buf[1] >> 24 | salt_buf[2] << 8;
277 salt_buf_t1[3] = salt_buf[2] >> 24 | salt_buf[3] << 8;
278 salt_buf_t1[4] = salt_buf[3] >> 24;
280 salt_buf_t2[0] = salt_buf[0] << 16;
281 salt_buf_t2[1] = salt_buf[0] >> 16 | salt_buf[1] << 16;
282 salt_buf_t2[2] = salt_buf[1] >> 16 | salt_buf[2] << 16;
283 salt_buf_t2[3] = salt_buf[2] >> 16 | salt_buf[3] << 16;
284 salt_buf_t2[4] = salt_buf[3] >> 16;
286 salt_buf_t3[0] = salt_buf[0] << 24;
287 salt_buf_t3[1] = salt_buf[0] >> 8 | salt_buf[1] << 24;
288 salt_buf_t3[2] = salt_buf[1] >> 8 | salt_buf[2] << 24;
289 salt_buf_t3[3] = salt_buf[2] >> 8 | salt_buf[3] << 24;
290 salt_buf_t3[4] = salt_buf[3] >> 8;
297 // generate the 16 * 21 buffer
317 w0_t[0] = digest_t0[0];
318 w0_t[1] = digest_t0[1];
321 w0_t[1] |= salt_buf_t1[0];
322 w0_t[2] = salt_buf_t1[1];
323 w0_t[3] = salt_buf_t1[2];
324 w1_t[0] = salt_buf_t1[3];
325 w1_t[1] = salt_buf_t1[4];
328 w1_t[1] |= digest_t1[0];
329 w1_t[2] = digest_t1[1];
332 w1_t[2] |= salt_buf_t2[0];
333 w1_t[3] = salt_buf_t2[1];
334 w2_t[0] = salt_buf_t2[2];
335 w2_t[1] = salt_buf_t2[3];
336 w2_t[2] = salt_buf_t2[4];
339 w2_t[2] |= digest_t2[0];
340 w2_t[3] = digest_t2[1];
343 w2_t[3] |= salt_buf_t3[0];
344 w3_t[0] = salt_buf_t3[1];
345 w3_t[1] = salt_buf_t3[2];
346 w3_t[2] = salt_buf_t3[3];
347 w3_t[3] = salt_buf_t3[4];
351 w3_t[3] |= digest_t3[0];
353 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
373 w0_t[0] = digest_t3[1];
376 w0_t[1] = salt_buf_t0[0];
377 w0_t[2] = salt_buf_t0[1];
378 w0_t[3] = salt_buf_t0[2];
379 w1_t[0] = salt_buf_t0[3];
382 w1_t[1] = digest_t0[0];
383 w1_t[2] = digest_t0[1];
386 w1_t[2] |= salt_buf_t1[0];
387 w1_t[3] = salt_buf_t1[1];
388 w2_t[0] = salt_buf_t1[2];
389 w2_t[1] = salt_buf_t1[3];
390 w2_t[2] = salt_buf_t1[4];
393 w2_t[2] |= digest_t1[0];
394 w2_t[3] = digest_t1[1];
397 w2_t[3] |= salt_buf_t2[0];
398 w3_t[0] = salt_buf_t2[1];
399 w3_t[1] = salt_buf_t2[2];
400 w3_t[2] = salt_buf_t2[3];
401 w3_t[3] = salt_buf_t2[4];
404 w3_t[3] |= digest_t2[0];
406 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
426 w0_t[0] = digest_t2[1];
429 w0_t[0] |= salt_buf_t3[0];
430 w0_t[1] = salt_buf_t3[1];
431 w0_t[2] = salt_buf_t3[2];
432 w0_t[3] = salt_buf_t3[3];
433 w1_t[0] = salt_buf_t3[4];
436 w1_t[0] |= digest_t3[0];
437 w1_t[1] = digest_t3[1];
440 w1_t[2] = salt_buf_t0[0];
441 w1_t[3] = salt_buf_t0[1];
442 w2_t[0] = salt_buf_t0[2];
443 w2_t[1] = salt_buf_t0[3];
446 w2_t[2] = digest_t0[0];
447 w2_t[3] = digest_t0[1];
450 w2_t[3] |= salt_buf_t1[0];
451 w3_t[0] = salt_buf_t1[1];
452 w3_t[1] = salt_buf_t1[2];
453 w3_t[2] = salt_buf_t1[3];
454 w3_t[3] = salt_buf_t1[4];
457 w3_t[3] |= digest_t1[0];
459 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
479 w0_t[0] = digest_t1[1];
482 w0_t[0] |= salt_buf_t2[0];
483 w0_t[1] = salt_buf_t2[1];
484 w0_t[2] = salt_buf_t2[2];
485 w0_t[3] = salt_buf_t2[3];
486 w1_t[0] = salt_buf_t2[4];
489 w1_t[0] |= digest_t2[0];
490 w1_t[1] = digest_t2[1];
493 w1_t[1] |= salt_buf_t3[0];
494 w1_t[2] = salt_buf_t3[1];
495 w1_t[3] = salt_buf_t3[2];
496 w2_t[0] = salt_buf_t3[3];
497 w2_t[1] = salt_buf_t3[4];
500 w2_t[1] |= digest_t3[0];
501 w2_t[2] = digest_t3[1];
504 w2_t[3] = salt_buf_t0[0];
505 w3_t[0] = salt_buf_t0[1];
506 w3_t[1] = salt_buf_t0[2];
507 w3_t[2] = salt_buf_t0[3];
510 w3_t[3] = digest_t0[0];
512 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
532 w0_t[0] = digest_t0[1];
535 w0_t[0] |= salt_buf_t1[0];
536 w0_t[1] = salt_buf_t1[1];
537 w0_t[2] = salt_buf_t1[2];
538 w0_t[3] = salt_buf_t1[3];
539 w1_t[0] = salt_buf_t1[4];
542 w1_t[0] |= digest_t1[0];
543 w1_t[1] = digest_t1[1];
546 w1_t[1] |= salt_buf_t2[0];
547 w1_t[2] = salt_buf_t2[1];
548 w1_t[3] = salt_buf_t2[2];
549 w2_t[0] = salt_buf_t2[3];
550 w2_t[1] = salt_buf_t2[4];
553 w2_t[1] |= digest_t2[0];
554 w2_t[2] = digest_t2[1];
557 w2_t[2] |= salt_buf_t3[0];
558 w2_t[3] = salt_buf_t3[1];
559 w3_t[0] = salt_buf_t3[2];
560 w3_t[1] = salt_buf_t3[3];
561 w3_t[2] = salt_buf_t3[4];
564 w3_t[2] |= digest_t3[0];
565 w3_t[3] = digest_t3[1];
567 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
569 w0_t[0] = salt_buf_t0[0];
570 w0_t[1] = salt_buf_t0[1];
571 w0_t[2] = salt_buf_t0[2];
572 w0_t[3] = salt_buf_t0[3];
583 w3_t[2] = 21 * 16 * 8;
586 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
589 __kernel void m09700_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)
595 const u32 lid = get_local_id (0);
601 const u32 gid = get_global_id (0);
603 if (gid >= gid_max) return;
608 pw_buf0[0] = pws[gid].i[0];
609 pw_buf0[1] = pws[gid].i[1];
610 pw_buf0[2] = pws[gid].i[2];
611 pw_buf0[3] = pws[gid].i[3];
612 pw_buf1[0] = pws[gid].i[4];
613 pw_buf1[1] = pws[gid].i[5];
614 pw_buf1[2] = pws[gid].i[6];
615 pw_buf1[3] = pws[gid].i[7];
617 const u32 pw_l_len = pws[gid].pw_len;
623 __local RC4_KEY rc4_keys[64];
625 __local RC4_KEY *rc4_key = &rc4_keys[lid];
633 salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
634 salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
635 salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
636 salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
642 const u32 version = oldoffice01_bufs[salt_pos].version;
644 u32 encryptedVerifier[4];
646 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
647 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
648 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
649 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
655 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
657 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
659 const u32x pw_len = pw_l_len + pw_r_len;
662 * concat password candidate
665 u32x wordl0[4] = { 0 };
666 u32x wordl1[4] = { 0 };
667 u32x wordl2[4] = { 0 };
668 u32x wordl3[4] = { 0 };
670 wordl0[0] = pw_buf0[0];
671 wordl0[1] = pw_buf0[1];
672 wordl0[2] = pw_buf0[2];
673 wordl0[3] = pw_buf0[3];
674 wordl1[0] = pw_buf1[0];
675 wordl1[1] = pw_buf1[1];
676 wordl1[2] = pw_buf1[2];
677 wordl1[3] = pw_buf1[3];
679 u32x wordr0[4] = { 0 };
680 u32x wordr1[4] = { 0 };
681 u32x wordr2[4] = { 0 };
682 u32x wordr3[4] = { 0 };
684 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
685 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
686 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
687 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
688 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
689 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
690 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
691 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
693 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
695 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
699 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
707 w0[0] = wordl0[0] | wordr0[0];
708 w0[1] = wordl0[1] | wordr0[1];
709 w0[2] = wordl0[2] | wordr0[2];
710 w0[3] = wordl0[3] | wordr0[3];
711 w1[0] = wordl1[0] | wordr1[0];
712 w1[1] = wordl1[1] | wordr1[1];
713 w1[2] = wordl1[2] | wordr1[2];
714 w1[3] = wordl1[3] | wordr1[3];
715 w2[0] = wordl2[0] | wordr2[0];
716 w2[1] = wordl2[1] | wordr2[1];
717 w2[2] = wordl2[2] | wordr2[2];
718 w2[3] = wordl2[3] | wordr2[3];
719 w3[0] = wordl3[0] | wordr3[0];
720 w3[1] = wordl3[1] | wordr3[1];
721 w3[2] = wordl3[2] | wordr3[2];
722 w3[3] = wordl3[3] | wordr3[3];
728 make_unicode (w1, w2, w3);
729 make_unicode (w0, w0, w1);
731 w3[2] = pw_len * 8 * 2;
736 digest_pre[0] = MD5M_A;
737 digest_pre[1] = MD5M_B;
738 digest_pre[2] = MD5M_C;
739 digest_pre[3] = MD5M_D;
741 md5_transform (w0, w1, w2, w3, digest_pre);
743 digest_pre[0] &= 0xffffffff;
744 digest_pre[1] &= 0x000000ff;
745 digest_pre[2] &= 0x00000000;
746 digest_pre[3] &= 0x00000000;
755 gen336 (digest_pre, salt_buf, digest);
757 // now the 40 bit input for the MD5 which then will generate the RC4 key, so it's precomputable!
760 w0[1] = digest[1] & 0xff;
781 md5_transform (w0, w1, w2, w3, digest);
792 rc4_init_16 (rc4_key, key);
796 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
820 md5_transform (w0, w1, w2, w3, digest);
822 rc4_next_16 (rc4_key, 16, j, digest, out);
824 COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
828 __kernel void m09700_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)
832 __kernel void m09700_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)
836 __kernel void m09700_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)
842 const u32 lid = get_local_id (0);
848 const u32 gid = get_global_id (0);
850 if (gid >= gid_max) return;
855 pw_buf0[0] = pws[gid].i[0];
856 pw_buf0[1] = pws[gid].i[1];
857 pw_buf0[2] = pws[gid].i[2];
858 pw_buf0[3] = pws[gid].i[3];
859 pw_buf1[0] = pws[gid].i[4];
860 pw_buf1[1] = pws[gid].i[5];
861 pw_buf1[2] = pws[gid].i[6];
862 pw_buf1[3] = pws[gid].i[7];
864 const u32 pw_l_len = pws[gid].pw_len;
870 __local RC4_KEY rc4_keys[64];
872 __local RC4_KEY *rc4_key = &rc4_keys[lid];
880 salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
881 salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
882 salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
883 salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
889 const u32 version = oldoffice01_bufs[salt_pos].version;
891 u32 encryptedVerifier[4];
893 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
894 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
895 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
896 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
902 const u32 search[4] =
904 digests_buf[digests_offset].digest_buf[DGST_R0],
905 digests_buf[digests_offset].digest_buf[DGST_R1],
906 digests_buf[digests_offset].digest_buf[DGST_R2],
907 digests_buf[digests_offset].digest_buf[DGST_R3]
914 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
916 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
918 const u32x pw_len = pw_l_len + pw_r_len;
921 * concat password candidate
924 u32x wordl0[4] = { 0 };
925 u32x wordl1[4] = { 0 };
926 u32x wordl2[4] = { 0 };
927 u32x wordl3[4] = { 0 };
929 wordl0[0] = pw_buf0[0];
930 wordl0[1] = pw_buf0[1];
931 wordl0[2] = pw_buf0[2];
932 wordl0[3] = pw_buf0[3];
933 wordl1[0] = pw_buf1[0];
934 wordl1[1] = pw_buf1[1];
935 wordl1[2] = pw_buf1[2];
936 wordl1[3] = pw_buf1[3];
938 u32x wordr0[4] = { 0 };
939 u32x wordr1[4] = { 0 };
940 u32x wordr2[4] = { 0 };
941 u32x wordr3[4] = { 0 };
943 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
944 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
945 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
946 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
947 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
948 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
949 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
950 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
952 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
954 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
958 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
966 w0[0] = wordl0[0] | wordr0[0];
967 w0[1] = wordl0[1] | wordr0[1];
968 w0[2] = wordl0[2] | wordr0[2];
969 w0[3] = wordl0[3] | wordr0[3];
970 w1[0] = wordl1[0] | wordr1[0];
971 w1[1] = wordl1[1] | wordr1[1];
972 w1[2] = wordl1[2] | wordr1[2];
973 w1[3] = wordl1[3] | wordr1[3];
974 w2[0] = wordl2[0] | wordr2[0];
975 w2[1] = wordl2[1] | wordr2[1];
976 w2[2] = wordl2[2] | wordr2[2];
977 w2[3] = wordl2[3] | wordr2[3];
978 w3[0] = wordl3[0] | wordr3[0];
979 w3[1] = wordl3[1] | wordr3[1];
980 w3[2] = wordl3[2] | wordr3[2];
981 w3[3] = wordl3[3] | wordr3[3];
987 make_unicode (w1, w2, w3);
988 make_unicode (w0, w0, w1);
990 w3[2] = pw_len * 8 * 2;
995 digest_pre[0] = MD5M_A;
996 digest_pre[1] = MD5M_B;
997 digest_pre[2] = MD5M_C;
998 digest_pre[3] = MD5M_D;
1000 md5_transform (w0, w1, w2, w3, digest_pre);
1002 digest_pre[0] &= 0xffffffff;
1003 digest_pre[1] &= 0x000000ff;
1004 digest_pre[2] &= 0x00000000;
1005 digest_pre[3] &= 0x00000000;
1014 gen336 (digest_pre, salt_buf, digest);
1016 // now the 40 bit input for the MD5 which then will generate the RC4 key, so it's precomputable!
1019 w0[1] = digest[1] & 0xff;
1040 md5_transform (w0, w1, w2, w3, digest);
1051 rc4_init_16 (rc4_key, key);
1055 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
1079 md5_transform (w0, w1, w2, w3, digest);
1081 rc4_next_16 (rc4_key, 16, j, digest, out);
1083 COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
1087 __kernel void m09700_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)
1091 __kernel void m09700_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)