2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
24 #include "include/kernel_functions.c"
26 #include "common_nv.c"
27 #include "include/rp_gpu.h"
31 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
32 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
36 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
37 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
40 __device__ __constant__ u32 padding[8] =
60 __device__ static void swap (RC4_KEY *rc4_key, const u8 i, const u8 j)
65 rc4_key->S[i] = rc4_key->S[j];
69 __device__ static void rc4_init_16 (RC4_KEY *rc4_key, const u32 data[4])
74 u32 *ptr = (u32 *) rc4_key->S;
77 for (u32 i = 0; i < 64; i++)
82 const u32 d0 = data[0] >> 0;
83 const u32 d1 = data[0] >> 8;
84 const u32 d2 = data[0] >> 16;
85 const u32 d3 = data[0] >> 24;
86 const u32 d4 = data[1] >> 0;
92 for (i = 0; i < 255; i += 5)
94 j += rc4_key->S[i + 0]; j += d0; swap (rc4_key, i + 0, j);
95 j += rc4_key->S[i + 1]; j += d1; swap (rc4_key, i + 1, j);
96 j += rc4_key->S[i + 2]; j += d2; swap (rc4_key, i + 2, j);
97 j += rc4_key->S[i + 3]; j += d3; swap (rc4_key, i + 3, j);
98 j += rc4_key->S[i + 4]; j += d4; swap (rc4_key, i + 4, j);
101 j += rc4_key->S[i + 0]; j += d0; swap (rc4_key, i + 0, j);
104 __device__ static u8 rc4_next_16 (RC4_KEY *rc4_key, u8 i, u8 j, const u32 in[4], u32 out[4])
107 for (u32 k = 0; k < 4; k++)
116 swap (rc4_key, i, j);
118 idx = rc4_key->S[i] + rc4_key->S[j];
120 xor4 |= rc4_key->S[idx] << 0;
125 swap (rc4_key, i, j);
127 idx = rc4_key->S[i] + rc4_key->S[j];
129 xor4 |= rc4_key->S[idx] << 8;
134 swap (rc4_key, i, j);
136 idx = rc4_key->S[i] + rc4_key->S[j];
138 xor4 |= rc4_key->S[idx] << 16;
143 swap (rc4_key, i, j);
145 idx = rc4_key->S[i] + rc4_key->S[j];
147 xor4 |= rc4_key->S[idx] << 24;
149 out[k] = in[k] ^ xor4;
155 __device__ static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
179 MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
180 MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
181 MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
182 MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
183 MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
184 MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
185 MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
186 MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
187 MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
188 MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
189 MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
190 MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
191 MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
192 MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
193 MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
194 MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
196 MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
197 MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
198 MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
199 MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
200 MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
201 MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
202 MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
203 MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
204 MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
205 MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
206 MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
207 MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
208 MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
209 MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
210 MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
211 MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
213 MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
214 MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
215 MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
216 MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
217 MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
218 MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
219 MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
220 MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
221 MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
222 MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
223 MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
224 MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
225 MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
226 MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
227 MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
228 MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
230 MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
231 MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
232 MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
233 MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
234 MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
235 MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
236 MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
237 MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
238 MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
239 MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
240 MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
241 MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
242 MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
243 MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
244 MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
245 MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
253 __device__ __constant__ gpu_rule_t c_rules[1024];
255 extern "C" __global__ void __launch_bounds__ (64, 1) m10400_m04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
261 const u32 lid = threadIdx.x;
267 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
269 if (gid >= gid_max) return;
273 pw_buf0[0] = pws[gid].i[ 0];
274 pw_buf0[1] = pws[gid].i[ 1];
275 pw_buf0[2] = pws[gid].i[ 2];
276 pw_buf0[3] = pws[gid].i[ 3];
280 pw_buf1[0] = pws[gid].i[ 4];
281 pw_buf1[1] = pws[gid].i[ 5];
282 pw_buf1[2] = pws[gid].i[ 6];
283 pw_buf1[3] = pws[gid].i[ 7];
285 const u32 pw_len = pws[gid].pw_len;
291 __shared__ RC4_KEY rc4_keys[64];
293 RC4_KEY *rc4_key = &rc4_keys[lid];
301 o_buf[0] = pdf_bufs[salt_pos].o_buf[0];
302 o_buf[1] = pdf_bufs[salt_pos].o_buf[1];
303 o_buf[2] = pdf_bufs[salt_pos].o_buf[2];
304 o_buf[3] = pdf_bufs[salt_pos].o_buf[3];
305 o_buf[4] = pdf_bufs[salt_pos].o_buf[4];
306 o_buf[5] = pdf_bufs[salt_pos].o_buf[5];
307 o_buf[6] = pdf_bufs[salt_pos].o_buf[6];
308 o_buf[7] = pdf_bufs[salt_pos].o_buf[7];
310 u32 P = pdf_bufs[salt_pos].P;
314 id_buf[0] = pdf_bufs[salt_pos].id_buf[0];
315 id_buf[1] = pdf_bufs[salt_pos].id_buf[1];
316 id_buf[2] = pdf_bufs[salt_pos].id_buf[2];
317 id_buf[3] = pdf_bufs[salt_pos].id_buf[3];
323 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
353 const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
360 // max length supported by pdf11 is 32
362 w0_t[0] = padding[0];
363 w0_t[1] = padding[1];
364 w0_t[2] = padding[2];
365 w0_t[3] = padding[3];
366 w1_t[0] = padding[4];
367 w1_t[1] = padding[5];
368 w1_t[2] = padding[6];
369 w1_t[3] = padding[7];
379 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
382 // truncate at 32 is wanted, not a bug!
409 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
428 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
435 key[1] = digest[1] & 0xff;
439 rc4_init_16 (rc4_key, key);
443 rc4_next_16 (rc4_key, 0, 0, padding, out);
445 const u32x r0 = out[0];
446 const u32x r1 = out[1];
447 const u32x r2 = out[2];
448 const u32x r3 = out[3];
450 #include VECT_COMPARE_M
454 extern "C" __global__ void __launch_bounds__ (64, 1) m10400_m08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
458 extern "C" __global__ void __launch_bounds__ (64, 1) m10400_m16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
462 extern "C" __global__ void __launch_bounds__ (64, 1) m10400_s04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
468 const u32 lid = threadIdx.x;
474 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
476 if (gid >= gid_max) return;
480 pw_buf0[0] = pws[gid].i[ 0];
481 pw_buf0[1] = pws[gid].i[ 1];
482 pw_buf0[2] = pws[gid].i[ 2];
483 pw_buf0[3] = pws[gid].i[ 3];
487 pw_buf1[0] = pws[gid].i[ 4];
488 pw_buf1[1] = pws[gid].i[ 5];
489 pw_buf1[2] = pws[gid].i[ 6];
490 pw_buf1[3] = pws[gid].i[ 7];
492 const u32 pw_len = pws[gid].pw_len;
498 __shared__ RC4_KEY rc4_keys[64];
500 RC4_KEY *rc4_key = &rc4_keys[lid];
506 const u32 search[4] =
508 digests_buf[digests_offset].digest_buf[DGST_R0],
509 digests_buf[digests_offset].digest_buf[DGST_R1],
510 digests_buf[digests_offset].digest_buf[DGST_R2],
511 digests_buf[digests_offset].digest_buf[DGST_R3]
520 o_buf[0] = pdf_bufs[salt_pos].o_buf[0];
521 o_buf[1] = pdf_bufs[salt_pos].o_buf[1];
522 o_buf[2] = pdf_bufs[salt_pos].o_buf[2];
523 o_buf[3] = pdf_bufs[salt_pos].o_buf[3];
524 o_buf[4] = pdf_bufs[salt_pos].o_buf[4];
525 o_buf[5] = pdf_bufs[salt_pos].o_buf[5];
526 o_buf[6] = pdf_bufs[salt_pos].o_buf[6];
527 o_buf[7] = pdf_bufs[salt_pos].o_buf[7];
529 u32 P = pdf_bufs[salt_pos].P;
533 id_buf[0] = pdf_bufs[salt_pos].id_buf[0];
534 id_buf[1] = pdf_bufs[salt_pos].id_buf[1];
535 id_buf[2] = pdf_bufs[salt_pos].id_buf[2];
536 id_buf[3] = pdf_bufs[salt_pos].id_buf[3];
542 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
572 const u32 out_len = apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
579 // max length supported by pdf11 is 32
581 w0_t[0] = padding[0];
582 w0_t[1] = padding[1];
583 w0_t[2] = padding[2];
584 w0_t[3] = padding[3];
585 w1_t[0] = padding[4];
586 w1_t[1] = padding[5];
587 w1_t[2] = padding[6];
588 w1_t[3] = padding[7];
598 switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, pw_len);
601 // truncate at 32 is wanted, not a bug!
628 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
647 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
654 key[1] = digest[1] & 0xff;
658 rc4_init_16 (rc4_key, key);
662 rc4_next_16 (rc4_key, 0, 0, padding, out);
664 const u32x r0 = out[0];
665 const u32x r1 = out[1];
666 const u32x r2 = out[2];
667 const u32x r3 = out[3];
669 #include VECT_COMPARE_S
673 extern "C" __global__ void __launch_bounds__ (64, 1) m10400_s08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
677 extern "C" __global__ void __launch_bounds__ (64, 1) m10400_s16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const pdf_t *pdf_bufs, u32 *d_return_buf, 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)