2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
28 #include "include/kernel_functions.c"
29 #include "types_amd.c"
30 #include "common_amd.c"
33 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
34 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
38 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
39 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
43 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
44 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
55 static void swap (__local RC4_KEY *rc4_key, const u8 i, const u8 j)
60 rc4_key->S[i] = rc4_key->S[j];
64 static void rc4_init_16 (__local RC4_KEY *rc4_key, const u32 data[4])
69 __local u32 *ptr = (__local u32 *) rc4_key->S;
72 for (u32 i = 0; i < 64; i++)
80 for (u32 i = 0; i < 16; i++)
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++;
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++;
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++;
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++;
116 static u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, const u32 in[4], u32 out[4])
119 for (u32 k = 0; k < 4; k++)
128 swap (rc4_key, i, j);
130 idx = rc4_key->S[i] + rc4_key->S[j];
132 xor4 |= rc4_key->S[idx] << 0;
137 swap (rc4_key, i, j);
139 idx = rc4_key->S[i] + rc4_key->S[j];
141 xor4 |= rc4_key->S[idx] << 8;
146 swap (rc4_key, i, j);
148 idx = rc4_key->S[i] + rc4_key->S[j];
150 xor4 |= rc4_key->S[idx] << 16;
155 swap (rc4_key, i, j);
157 idx = rc4_key->S[i] + rc4_key->S[j];
159 xor4 |= rc4_key->S[idx] << 24;
161 out[k] = in[k] ^ xor4;
167 static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
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);
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);
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);
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);
265 static void gen336 (u32x digest_pre[4], u32 salt_buf[4], u32x digest[4])
272 digest_t0[0] = digest_pre[0];
273 digest_t0[1] = digest_pre[1] & 0xff;
275 digest_t1[0] = digest_pre[0] << 8;
276 digest_t1[1] = digest_pre[0] >> 24 | digest_pre[1] << 8;
278 digest_t2[0] = digest_pre[0] << 16;
279 digest_t2[1] = digest_pre[0] >> 16 | digest_pre[1] << 16;
281 digest_t3[0] = digest_pre[0] << 24;
282 digest_t3[1] = digest_pre[0] >> 8 | digest_pre[1] << 24;
289 salt_buf_t0[0] = salt_buf[0];
290 salt_buf_t0[1] = salt_buf[1];
291 salt_buf_t0[2] = salt_buf[2];
292 salt_buf_t0[3] = salt_buf[3];
294 salt_buf_t1[0] = salt_buf[0] << 8;
295 salt_buf_t1[1] = salt_buf[0] >> 24 | salt_buf[1] << 8;
296 salt_buf_t1[2] = salt_buf[1] >> 24 | salt_buf[2] << 8;
297 salt_buf_t1[3] = salt_buf[2] >> 24 | salt_buf[3] << 8;
298 salt_buf_t1[4] = salt_buf[3] >> 24;
300 salt_buf_t2[0] = salt_buf[0] << 16;
301 salt_buf_t2[1] = salt_buf[0] >> 16 | salt_buf[1] << 16;
302 salt_buf_t2[2] = salt_buf[1] >> 16 | salt_buf[2] << 16;
303 salt_buf_t2[3] = salt_buf[2] >> 16 | salt_buf[3] << 16;
304 salt_buf_t2[4] = salt_buf[3] >> 16;
306 salt_buf_t3[0] = salt_buf[0] << 24;
307 salt_buf_t3[1] = salt_buf[0] >> 8 | salt_buf[1] << 24;
308 salt_buf_t3[2] = salt_buf[1] >> 8 | salt_buf[2] << 24;
309 salt_buf_t3[3] = salt_buf[2] >> 8 | salt_buf[3] << 24;
310 salt_buf_t3[4] = salt_buf[3] >> 8;
317 // generate the 16 * 21 buffer
337 w0_t[0] = digest_t0[0];
338 w0_t[1] = digest_t0[1];
341 w0_t[1] |= salt_buf_t1[0];
342 w0_t[2] = salt_buf_t1[1];
343 w0_t[3] = salt_buf_t1[2];
344 w1_t[0] = salt_buf_t1[3];
345 w1_t[1] = salt_buf_t1[4];
348 w1_t[1] |= digest_t1[0];
349 w1_t[2] = digest_t1[1];
352 w1_t[2] |= salt_buf_t2[0];
353 w1_t[3] = salt_buf_t2[1];
354 w2_t[0] = salt_buf_t2[2];
355 w2_t[1] = salt_buf_t2[3];
356 w2_t[2] = salt_buf_t2[4];
359 w2_t[2] |= digest_t2[0];
360 w2_t[3] = digest_t2[1];
363 w2_t[3] |= salt_buf_t3[0];
364 w3_t[0] = salt_buf_t3[1];
365 w3_t[1] = salt_buf_t3[2];
366 w3_t[2] = salt_buf_t3[3];
367 w3_t[3] = salt_buf_t3[4];
371 w3_t[3] |= digest_t3[0];
373 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
393 w0_t[0] = digest_t3[1];
396 w0_t[1] = salt_buf_t0[0];
397 w0_t[2] = salt_buf_t0[1];
398 w0_t[3] = salt_buf_t0[2];
399 w1_t[0] = salt_buf_t0[3];
402 w1_t[1] = digest_t0[0];
403 w1_t[2] = digest_t0[1];
406 w1_t[2] |= salt_buf_t1[0];
407 w1_t[3] = salt_buf_t1[1];
408 w2_t[0] = salt_buf_t1[2];
409 w2_t[1] = salt_buf_t1[3];
410 w2_t[2] = salt_buf_t1[4];
413 w2_t[2] |= digest_t1[0];
414 w2_t[3] = digest_t1[1];
417 w2_t[3] |= salt_buf_t2[0];
418 w3_t[0] = salt_buf_t2[1];
419 w3_t[1] = salt_buf_t2[2];
420 w3_t[2] = salt_buf_t2[3];
421 w3_t[3] = salt_buf_t2[4];
424 w3_t[3] |= digest_t2[0];
426 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
446 w0_t[0] = digest_t2[1];
449 w0_t[0] |= salt_buf_t3[0];
450 w0_t[1] = salt_buf_t3[1];
451 w0_t[2] = salt_buf_t3[2];
452 w0_t[3] = salt_buf_t3[3];
453 w1_t[0] = salt_buf_t3[4];
456 w1_t[0] |= digest_t3[0];
457 w1_t[1] = digest_t3[1];
460 w1_t[2] = salt_buf_t0[0];
461 w1_t[3] = salt_buf_t0[1];
462 w2_t[0] = salt_buf_t0[2];
463 w2_t[1] = salt_buf_t0[3];
466 w2_t[2] = digest_t0[0];
467 w2_t[3] = digest_t0[1];
470 w2_t[3] |= salt_buf_t1[0];
471 w3_t[0] = salt_buf_t1[1];
472 w3_t[1] = salt_buf_t1[2];
473 w3_t[2] = salt_buf_t1[3];
474 w3_t[3] = salt_buf_t1[4];
477 w3_t[3] |= digest_t1[0];
479 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
499 w0_t[0] = digest_t1[1];
502 w0_t[0] |= salt_buf_t2[0];
503 w0_t[1] = salt_buf_t2[1];
504 w0_t[2] = salt_buf_t2[2];
505 w0_t[3] = salt_buf_t2[3];
506 w1_t[0] = salt_buf_t2[4];
509 w1_t[0] |= digest_t2[0];
510 w1_t[1] = digest_t2[1];
513 w1_t[1] |= salt_buf_t3[0];
514 w1_t[2] = salt_buf_t3[1];
515 w1_t[3] = salt_buf_t3[2];
516 w2_t[0] = salt_buf_t3[3];
517 w2_t[1] = salt_buf_t3[4];
520 w2_t[1] |= digest_t3[0];
521 w2_t[2] = digest_t3[1];
524 w2_t[3] = salt_buf_t0[0];
525 w3_t[0] = salt_buf_t0[1];
526 w3_t[1] = salt_buf_t0[2];
527 w3_t[2] = salt_buf_t0[3];
530 w3_t[3] = digest_t0[0];
532 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
552 w0_t[0] = digest_t0[1];
555 w0_t[0] |= salt_buf_t1[0];
556 w0_t[1] = salt_buf_t1[1];
557 w0_t[2] = salt_buf_t1[2];
558 w0_t[3] = salt_buf_t1[3];
559 w1_t[0] = salt_buf_t1[4];
562 w1_t[0] |= digest_t1[0];
563 w1_t[1] = digest_t1[1];
566 w1_t[1] |= salt_buf_t2[0];
567 w1_t[2] = salt_buf_t2[1];
568 w1_t[3] = salt_buf_t2[2];
569 w2_t[0] = salt_buf_t2[3];
570 w2_t[1] = salt_buf_t2[4];
573 w2_t[1] |= digest_t2[0];
574 w2_t[2] = digest_t2[1];
577 w2_t[2] |= salt_buf_t3[0];
578 w2_t[3] = salt_buf_t3[1];
579 w3_t[0] = salt_buf_t3[2];
580 w3_t[1] = salt_buf_t3[3];
581 w3_t[2] = salt_buf_t3[4];
584 w3_t[2] |= digest_t3[0];
585 w3_t[3] = digest_t3[1];
587 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
589 w0_t[0] = salt_buf_t0[0];
590 w0_t[1] = salt_buf_t0[1];
591 w0_t[2] = salt_buf_t0[2];
592 w0_t[3] = salt_buf_t0[3];
603 w3_t[2] = 21 * 16 * 8;
606 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
609 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m09700_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)
615 const u32 lid = get_local_id (0);
617 __local RC4_KEY rc4_keys[64];
619 __local RC4_KEY *rc4_key = &rc4_keys[lid];
625 const u32 gid = get_global_id (0);
627 if (gid >= gid_max) return;
631 wordl0[0] = pws[gid].i[ 0];
632 wordl0[1] = pws[gid].i[ 1];
633 wordl0[2] = pws[gid].i[ 2];
634 wordl0[3] = pws[gid].i[ 3];
638 wordl1[0] = pws[gid].i[ 4];
639 wordl1[1] = pws[gid].i[ 5];
640 wordl1[2] = pws[gid].i[ 6];
641 wordl1[3] = pws[gid].i[ 7];
657 const u32 pw_l_len = pws[gid].pw_len;
659 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
661 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
668 const u32 search[4] =
670 digests_buf[digests_offset].digest_buf[DGST_R0],
671 digests_buf[digests_offset].digest_buf[DGST_R1],
672 digests_buf[digests_offset].digest_buf[DGST_R2],
673 digests_buf[digests_offset].digest_buf[DGST_R3]
682 salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
683 salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
684 salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
685 salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
691 const u32 version = oldoffice01_bufs[salt_pos].version;
693 u32 encryptedVerifier[4];
695 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
696 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
697 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
698 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
704 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
706 const u32 pw_r_len = combs_buf[il_pos].pw_len;
708 const u32 pw_len = pw_l_len + pw_r_len;
712 wordr0[0] = combs_buf[il_pos].i[0];
713 wordr0[1] = combs_buf[il_pos].i[1];
714 wordr0[2] = combs_buf[il_pos].i[2];
715 wordr0[3] = combs_buf[il_pos].i[3];
719 wordr1[0] = combs_buf[il_pos].i[4];
720 wordr1[1] = combs_buf[il_pos].i[5];
721 wordr1[2] = combs_buf[il_pos].i[6];
722 wordr1[3] = combs_buf[il_pos].i[7];
738 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
740 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
745 w0[0] = wordl0[0] | wordr0[0];
746 w0[1] = wordl0[1] | wordr0[1];
747 w0[2] = wordl0[2] | wordr0[2];
748 w0[3] = wordl0[3] | wordr0[3];
752 w1[0] = wordl1[0] | wordr1[0];
753 w1[1] = wordl1[1] | wordr1[1];
754 w1[2] = wordl1[2] | wordr1[2];
755 w1[3] = wordl1[3] | wordr1[3];
759 w2[0] = wordl2[0] | wordr2[0];
760 w2[1] = wordl2[1] | wordr2[1];
761 w2[2] = wordl2[2] | wordr2[2];
762 w2[3] = wordl2[3] | wordr2[3];
766 w3[0] = wordl3[0] | wordr3[0];
767 w3[1] = wordl3[1] | wordr3[1];
771 append_0x80_2 (w0, w1, pw_len);
778 make_unicode (w0, w0_t, w1_t);
779 make_unicode (w1, w2_t, w3_t);
781 w3_t[2] = pw_len * 8 * 2;
785 digest_pre[0] = MD5M_A;
786 digest_pre[1] = MD5M_B;
787 digest_pre[2] = MD5M_C;
788 digest_pre[3] = MD5M_D;
790 md5_transform (w0_t, w1_t, w2_t, w3_t, digest_pre);
792 digest_pre[0] &= 0xffffffff;
793 digest_pre[1] &= 0x000000ff;
794 digest_pre[2] &= 0x00000000;
795 digest_pre[3] &= 0x00000000;
804 gen336 (digest_pre, salt_buf, digest);
806 // now the 40 bit input for the MD5 which then will generate the RC4 key, so it's precomputable!
809 w0_t[1] = digest[1] & 0xff;
830 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
841 rc4_init_16 (rc4_key, key);
845 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
869 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
871 rc4_next_16 (rc4_key, 16, j, digest, out);
873 const u32x r0 = out[0];
874 const u32x r1 = out[1];
875 const u32x r2 = out[2];
876 const u32x r3 = out[3];
878 #include VECT_COMPARE_M
882 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m09700_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)
886 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m09700_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)
890 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m09700_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)
896 const u32 lid = get_local_id (0);
898 __local RC4_KEY rc4_keys[64];
900 __local RC4_KEY *rc4_key = &rc4_keys[lid];
906 const u32 gid = get_global_id (0);
908 if (gid >= gid_max) return;
912 wordl0[0] = pws[gid].i[ 0];
913 wordl0[1] = pws[gid].i[ 1];
914 wordl0[2] = pws[gid].i[ 2];
915 wordl0[3] = pws[gid].i[ 3];
919 wordl1[0] = pws[gid].i[ 4];
920 wordl1[1] = pws[gid].i[ 5];
921 wordl1[2] = pws[gid].i[ 6];
922 wordl1[3] = pws[gid].i[ 7];
938 const u32 pw_l_len = pws[gid].pw_len;
940 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
942 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
949 const u32 search[4] =
951 digests_buf[digests_offset].digest_buf[DGST_R0],
952 digests_buf[digests_offset].digest_buf[DGST_R1],
953 digests_buf[digests_offset].digest_buf[DGST_R2],
954 digests_buf[digests_offset].digest_buf[DGST_R3]
963 salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
964 salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
965 salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
966 salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
972 const u32 version = oldoffice01_bufs[salt_pos].version;
974 u32 encryptedVerifier[4];
976 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
977 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
978 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
979 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
985 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
987 const u32 pw_r_len = combs_buf[il_pos].pw_len;
989 const u32 pw_len = pw_l_len + pw_r_len;
993 wordr0[0] = combs_buf[il_pos].i[0];
994 wordr0[1] = combs_buf[il_pos].i[1];
995 wordr0[2] = combs_buf[il_pos].i[2];
996 wordr0[3] = combs_buf[il_pos].i[3];
1000 wordr1[0] = combs_buf[il_pos].i[4];
1001 wordr1[1] = combs_buf[il_pos].i[5];
1002 wordr1[2] = combs_buf[il_pos].i[6];
1003 wordr1[3] = combs_buf[il_pos].i[7];
1019 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
1021 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
1026 w0[0] = wordl0[0] | wordr0[0];
1027 w0[1] = wordl0[1] | wordr0[1];
1028 w0[2] = wordl0[2] | wordr0[2];
1029 w0[3] = wordl0[3] | wordr0[3];
1033 w1[0] = wordl1[0] | wordr1[0];
1034 w1[1] = wordl1[1] | wordr1[1];
1035 w1[2] = wordl1[2] | wordr1[2];
1036 w1[3] = wordl1[3] | wordr1[3];
1040 w2[0] = wordl2[0] | wordr2[0];
1041 w2[1] = wordl2[1] | wordr2[1];
1042 w2[2] = wordl2[2] | wordr2[2];
1043 w2[3] = wordl2[3] | wordr2[3];
1047 w3[0] = wordl3[0] | wordr3[0];
1048 w3[1] = wordl3[1] | wordr3[1];
1052 append_0x80_2 (w0, w1, pw_len);
1059 make_unicode (w0, w0_t, w1_t);
1060 make_unicode (w1, w2_t, w3_t);
1062 w3_t[2] = pw_len * 8 * 2;
1066 digest_pre[0] = MD5M_A;
1067 digest_pre[1] = MD5M_B;
1068 digest_pre[2] = MD5M_C;
1069 digest_pre[3] = MD5M_D;
1071 md5_transform (w0_t, w1_t, w2_t, w3_t, digest_pre);
1073 digest_pre[0] &= 0xffffffff;
1074 digest_pre[1] &= 0x000000ff;
1075 digest_pre[2] &= 0x00000000;
1076 digest_pre[3] &= 0x00000000;
1085 gen336 (digest_pre, salt_buf, digest);
1087 // now the 40 bit input for the MD5 which then will generate the RC4 key, so it's precomputable!
1089 w0_t[0] = digest[0];
1090 w0_t[1] = digest[1] & 0xff;
1111 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
1122 rc4_init_16 (rc4_key, key);
1126 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
1150 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
1152 rc4_next_16 (rc4_key, 16, j, digest, out);
1154 const u32x r0 = out[0];
1155 const u32x r1 = out[1];
1156 const u32x r2 = out[2];
1157 const u32x r3 = out[3];
1159 #include VECT_COMPARE_S
1163 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m09700_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)
1167 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m09700_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)