2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "inc_vendor.cl"
11 #include "inc_hash_constants.h"
12 #include "inc_hash_functions.cl"
13 #include "inc_types.cl"
14 #include "inc_common.cl"
15 #include "inc_simd.cl"
18 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
20 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
22 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
24 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7])
26 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf])
29 __kernel void m11100_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 void *esalt_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)
35 const u32 gid = get_global_id (0);
36 const u32 lid = get_local_id (0);
37 const u32 lsz = get_local_size (0);
43 __local u32 l_bin2asc[256];
45 for (u32 i = lid; i < 256; i += lsz)
47 const u32 i0 = (i >> 0) & 15;
48 const u32 i1 = (i >> 4) & 15;
50 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
51 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
54 barrier (CLK_LOCAL_MEM_FENCE);
56 if (gid >= gid_max) return;
65 pw_buf0[0] = pws[gid].i[0];
66 pw_buf0[1] = pws[gid].i[1];
67 pw_buf0[2] = pws[gid].i[2];
68 pw_buf0[3] = pws[gid].i[3];
69 pw_buf1[0] = pws[gid].i[4];
70 pw_buf1[1] = pws[gid].i[5];
71 pw_buf1[2] = pws[gid].i[6];
72 pw_buf1[3] = pws[gid].i[7];
74 const u32 pw_l_len = pws[gid].pw_len;
82 challenge = salt_bufs[salt_pos].salt_buf[0];
91 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
92 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
93 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
94 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
95 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
96 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
97 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
98 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
100 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
106 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
108 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
110 const u32x pw_len = pw_l_len + pw_r_len;
113 * concat password candidate
116 u32x wordl0[4] = { 0 };
117 u32x wordl1[4] = { 0 };
118 u32x wordl2[4] = { 0 };
119 u32x wordl3[4] = { 0 };
121 wordl0[0] = pw_buf0[0];
122 wordl0[1] = pw_buf0[1];
123 wordl0[2] = pw_buf0[2];
124 wordl0[3] = pw_buf0[3];
125 wordl1[0] = pw_buf1[0];
126 wordl1[1] = pw_buf1[1];
127 wordl1[2] = pw_buf1[2];
128 wordl1[3] = pw_buf1[3];
130 u32x wordr0[4] = { 0 };
131 u32x wordr1[4] = { 0 };
132 u32x wordr2[4] = { 0 };
133 u32x wordr3[4] = { 0 };
135 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
136 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
137 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
138 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
139 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
140 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
141 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
142 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
144 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
146 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
150 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
158 w0[0] = wordl0[0] | wordr0[0];
159 w0[1] = wordl0[1] | wordr0[1];
160 w0[2] = wordl0[2] | wordr0[2];
161 w0[3] = wordl0[3] | wordr0[3];
162 w1[0] = wordl1[0] | wordr1[0];
163 w1[1] = wordl1[1] | wordr1[1];
164 w1[2] = wordl1[2] | wordr1[2];
165 w1[3] = wordl1[3] | wordr1[3];
166 w2[0] = wordl2[0] | wordr2[0];
167 w2[1] = wordl2[1] | wordr2[1];
168 w2[2] = wordl2[2] | wordr2[2];
169 w2[3] = wordl2[3] | wordr2[3];
170 w3[0] = wordl3[0] | wordr3[0];
171 w3[1] = wordl3[1] | wordr3[1];
172 w3[2] = wordl3[2] | wordr3[2];
173 w3[3] = wordl3[3] | wordr3[3];
184 s0[0] = salt_buf0[0];
185 s0[1] = salt_buf0[1];
186 s0[2] = salt_buf0[2];
187 s0[3] = salt_buf0[3];
188 s1[0] = salt_buf1[0];
189 s1[1] = salt_buf1[1];
190 s1[2] = salt_buf1[2];
191 s1[3] = salt_buf1[3];
201 switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len);
203 const u32x pw_salt_len = pw_len + salt_len;
219 w3[2] = pw_salt_len * 8;
231 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
232 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
233 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
234 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
235 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
236 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
237 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
238 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
239 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
240 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
241 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
242 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
243 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
244 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
245 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
246 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
248 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
249 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
250 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
251 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
252 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
253 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
254 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
255 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
256 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
257 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
258 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
259 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
260 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
261 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
262 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
263 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
265 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
266 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
267 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
268 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
269 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
270 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
271 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
272 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
273 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
274 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
275 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
276 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
277 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
278 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
279 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
280 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
282 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
283 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
284 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
285 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
286 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
287 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
288 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
289 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
290 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
291 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
292 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
293 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
294 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
295 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
296 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
297 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
304 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
305 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
306 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
307 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
308 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
309 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
310 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
311 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
312 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
313 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
314 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
315 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
316 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
317 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
318 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
319 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
321 // add the 4 byte challenge here
329 w3[2] = (32 + 4) * 8;
333 * md5 ($hash.$challenge)
341 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
342 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
343 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
344 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
345 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
346 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
347 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
348 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
349 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
350 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
351 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
352 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
353 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
354 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
355 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
356 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
358 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
359 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
360 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
361 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
362 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
363 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
364 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
365 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
366 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
367 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
368 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
369 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
370 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
371 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
372 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
373 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
375 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
376 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
377 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
378 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
379 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
380 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
381 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
382 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
383 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
384 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
385 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
386 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
387 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
388 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
389 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
390 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
392 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
393 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
394 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
395 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
396 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
397 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
398 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
399 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
400 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
401 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
402 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
403 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
404 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
405 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
406 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
407 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
409 COMPARE_M_SIMD (a, d, c, b);
413 __kernel void m11100_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 void *esalt_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)
417 __kernel void m11100_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 void *esalt_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)
421 __kernel void m11100_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 void *esalt_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)
427 const u32 gid = get_global_id (0);
428 const u32 lid = get_local_id (0);
429 const u32 lsz = get_local_size (0);
435 __local u32 l_bin2asc[256];
437 for (u32 i = lid; i < 256; i += lsz)
439 const u32 i0 = (i >> 0) & 15;
440 const u32 i1 = (i >> 4) & 15;
442 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
443 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
446 barrier (CLK_LOCAL_MEM_FENCE);
448 if (gid >= gid_max) return;
457 pw_buf0[0] = pws[gid].i[0];
458 pw_buf0[1] = pws[gid].i[1];
459 pw_buf0[2] = pws[gid].i[2];
460 pw_buf0[3] = pws[gid].i[3];
461 pw_buf1[0] = pws[gid].i[4];
462 pw_buf1[1] = pws[gid].i[5];
463 pw_buf1[2] = pws[gid].i[6];
464 pw_buf1[3] = pws[gid].i[7];
466 const u32 pw_l_len = pws[gid].pw_len;
474 challenge = salt_bufs[salt_pos].salt_buf[0];
483 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
484 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
485 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
486 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
487 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
488 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
489 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
490 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
492 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
498 const u32 search[4] =
500 digests_buf[digests_offset].digest_buf[DGST_R0],
501 digests_buf[digests_offset].digest_buf[DGST_R1],
502 digests_buf[digests_offset].digest_buf[DGST_R2],
503 digests_buf[digests_offset].digest_buf[DGST_R3]
510 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
512 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
514 const u32x pw_len = pw_l_len + pw_r_len;
517 * concat password candidate
520 u32x wordl0[4] = { 0 };
521 u32x wordl1[4] = { 0 };
522 u32x wordl2[4] = { 0 };
523 u32x wordl3[4] = { 0 };
525 wordl0[0] = pw_buf0[0];
526 wordl0[1] = pw_buf0[1];
527 wordl0[2] = pw_buf0[2];
528 wordl0[3] = pw_buf0[3];
529 wordl1[0] = pw_buf1[0];
530 wordl1[1] = pw_buf1[1];
531 wordl1[2] = pw_buf1[2];
532 wordl1[3] = pw_buf1[3];
534 u32x wordr0[4] = { 0 };
535 u32x wordr1[4] = { 0 };
536 u32x wordr2[4] = { 0 };
537 u32x wordr3[4] = { 0 };
539 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
540 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
541 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
542 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
543 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
544 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
545 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
546 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
548 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
550 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
554 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
562 w0[0] = wordl0[0] | wordr0[0];
563 w0[1] = wordl0[1] | wordr0[1];
564 w0[2] = wordl0[2] | wordr0[2];
565 w0[3] = wordl0[3] | wordr0[3];
566 w1[0] = wordl1[0] | wordr1[0];
567 w1[1] = wordl1[1] | wordr1[1];
568 w1[2] = wordl1[2] | wordr1[2];
569 w1[3] = wordl1[3] | wordr1[3];
570 w2[0] = wordl2[0] | wordr2[0];
571 w2[1] = wordl2[1] | wordr2[1];
572 w2[2] = wordl2[2] | wordr2[2];
573 w2[3] = wordl2[3] | wordr2[3];
574 w3[0] = wordl3[0] | wordr3[0];
575 w3[1] = wordl3[1] | wordr3[1];
576 w3[2] = wordl3[2] | wordr3[2];
577 w3[3] = wordl3[3] | wordr3[3];
588 s0[0] = salt_buf0[0];
589 s0[1] = salt_buf0[1];
590 s0[2] = salt_buf0[2];
591 s0[3] = salt_buf0[3];
592 s1[0] = salt_buf1[0];
593 s1[1] = salt_buf1[1];
594 s1[2] = salt_buf1[2];
595 s1[3] = salt_buf1[3];
605 switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len);
607 const u32x pw_salt_len = pw_len + salt_len;
623 w3[2] = pw_salt_len * 8;
635 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
636 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
637 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
638 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
639 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
640 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
641 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
642 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
643 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
644 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
645 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
646 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
647 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
648 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
649 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
650 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
652 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
653 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
654 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
655 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
656 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
657 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
658 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
659 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
660 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
661 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
662 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
663 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
664 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
665 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
666 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
667 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
669 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
670 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
671 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
672 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
673 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
674 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
675 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
676 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
677 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
678 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
679 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
680 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
681 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
682 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
683 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
684 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
686 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
687 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
688 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
689 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
690 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
691 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
692 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
693 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
694 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
695 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
696 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
697 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
698 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
699 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
700 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
701 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
708 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
709 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
710 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
711 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
712 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
713 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
714 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
715 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
716 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
717 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
718 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
719 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
720 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
721 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
722 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
723 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
725 // add the 4 byte challenge here
733 w3[2] = (32 + 4) * 8;
737 * md5 ($hash.$challenge)
745 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
746 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
747 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
748 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
749 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
750 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
751 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
752 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
753 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
754 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
755 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
756 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
757 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
758 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
759 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
760 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
762 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
763 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
764 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
765 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
766 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
767 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
768 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
769 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
770 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
771 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
772 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
773 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
774 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
775 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
776 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
777 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
779 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
780 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
781 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
782 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
783 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
784 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
785 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
786 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
787 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
788 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
789 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
790 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
791 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
792 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
793 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
794 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
796 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
797 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
798 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
799 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
800 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
801 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
802 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
803 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
804 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
805 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
806 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
807 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
808 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
810 if (MATCHES_NONE_VS (a, search[0])) continue;
812 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
813 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
814 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
816 COMPARE_S_SIMD (a, d, c, b);
820 __kernel void m11100_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 void *esalt_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)
824 __kernel void m11100_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 void *esalt_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)