2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "inc_hash_constants.h"
11 #include "inc_vendor.cl"
18 #include "inc_hash_functions.cl"
19 #include "inc_types.cl"
20 #include "inc_common.cl"
21 #include "inc_simd.cl"
24 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
26 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
28 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
30 #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])
32 #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])
35 __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)
41 const u32 gid = get_global_id (0);
42 const u32 lid = get_local_id (0);
43 const u32 lsz = get_local_size (0);
49 __local u32 l_bin2asc[256];
51 for (u32 i = lid; i < 256; i += lsz)
53 const u32 i0 = (i >> 0) & 15;
54 const u32 i1 = (i >> 4) & 15;
56 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
57 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
60 barrier (CLK_LOCAL_MEM_FENCE);
62 if (gid >= gid_max) return;
71 pw_buf0[0] = pws[gid].i[0];
72 pw_buf0[1] = pws[gid].i[1];
73 pw_buf0[2] = pws[gid].i[2];
74 pw_buf0[3] = pws[gid].i[3];
75 pw_buf1[0] = pws[gid].i[4];
76 pw_buf1[1] = pws[gid].i[5];
77 pw_buf1[2] = pws[gid].i[6];
78 pw_buf1[3] = pws[gid].i[7];
80 const u32 pw_l_len = pws[gid].pw_len;
88 challenge = salt_bufs[salt_pos].salt_buf[0];
97 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
98 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
99 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
100 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
101 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
102 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
103 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
104 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
106 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
112 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
114 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
116 const u32x pw_len = pw_l_len + pw_r_len;
119 * concat password candidate
122 u32x wordl0[4] = { 0 };
123 u32x wordl1[4] = { 0 };
124 u32x wordl2[4] = { 0 };
125 u32x wordl3[4] = { 0 };
127 wordl0[0] = pw_buf0[0];
128 wordl0[1] = pw_buf0[1];
129 wordl0[2] = pw_buf0[2];
130 wordl0[3] = pw_buf0[3];
131 wordl1[0] = pw_buf1[0];
132 wordl1[1] = pw_buf1[1];
133 wordl1[2] = pw_buf1[2];
134 wordl1[3] = pw_buf1[3];
136 u32x wordr0[4] = { 0 };
137 u32x wordr1[4] = { 0 };
138 u32x wordr2[4] = { 0 };
139 u32x wordr3[4] = { 0 };
141 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
142 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
143 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
144 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
145 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
146 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
147 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
148 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
150 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
152 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
156 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
164 w0[0] = wordl0[0] | wordr0[0];
165 w0[1] = wordl0[1] | wordr0[1];
166 w0[2] = wordl0[2] | wordr0[2];
167 w0[3] = wordl0[3] | wordr0[3];
168 w1[0] = wordl1[0] | wordr1[0];
169 w1[1] = wordl1[1] | wordr1[1];
170 w1[2] = wordl1[2] | wordr1[2];
171 w1[3] = wordl1[3] | wordr1[3];
172 w2[0] = wordl2[0] | wordr2[0];
173 w2[1] = wordl2[1] | wordr2[1];
174 w2[2] = wordl2[2] | wordr2[2];
175 w2[3] = wordl2[3] | wordr2[3];
176 w3[0] = wordl3[0] | wordr3[0];
177 w3[1] = wordl3[1] | wordr3[1];
178 w3[2] = wordl3[2] | wordr3[2];
179 w3[3] = wordl3[3] | wordr3[3];
190 s0[0] = salt_buf0[0];
191 s0[1] = salt_buf0[1];
192 s0[2] = salt_buf0[2];
193 s0[3] = salt_buf0[3];
194 s1[0] = salt_buf1[0];
195 s1[1] = salt_buf1[1];
196 s1[2] = salt_buf1[2];
197 s1[3] = salt_buf1[3];
207 switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len);
209 const u32x pw_salt_len = pw_len + salt_len;
225 w3[2] = pw_salt_len * 8;
237 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
238 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
239 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
240 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
241 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
242 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
243 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
244 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
245 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
246 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
247 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
248 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
249 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
250 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
251 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
252 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
254 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
255 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
256 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
257 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
258 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
259 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
260 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
261 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
262 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
263 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
264 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
265 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
266 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
267 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
268 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
269 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
271 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
272 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
273 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
274 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
275 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
276 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
277 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
278 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
279 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
280 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
281 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
282 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
283 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
284 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
285 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
286 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
288 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
289 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
290 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
291 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
292 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
293 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
294 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
295 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
296 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
297 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
298 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
299 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
300 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
301 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
302 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
303 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
310 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
311 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
312 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
313 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
314 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
315 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
316 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
317 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
318 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
319 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
320 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
321 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
322 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
323 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
324 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
325 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
327 // add the 4 byte challenge here
335 w3[2] = (32 + 4) * 8;
339 * md5 ($hash.$challenge)
347 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
348 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
349 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
350 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
351 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
352 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
353 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
354 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
355 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
356 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
357 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
358 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
359 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
360 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
361 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
362 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
364 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
365 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
366 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
367 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
368 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
369 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
370 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
371 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
372 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
373 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
374 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
375 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
376 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
377 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
378 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
379 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
381 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
382 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
383 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
384 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
385 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
386 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
387 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
388 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
389 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
390 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
391 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
392 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
393 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
394 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
395 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
396 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
398 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
399 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
400 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
401 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
402 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
403 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
404 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
405 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
406 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
407 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
408 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
409 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
410 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
411 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
412 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
413 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
415 COMPARE_M_SIMD (a, d, c, b);
419 __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)
423 __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)
427 __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)
433 const u32 gid = get_global_id (0);
434 const u32 lid = get_local_id (0);
435 const u32 lsz = get_local_size (0);
441 __local u32 l_bin2asc[256];
443 for (u32 i = lid; i < 256; i += lsz)
445 const u32 i0 = (i >> 0) & 15;
446 const u32 i1 = (i >> 4) & 15;
448 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
449 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
452 barrier (CLK_LOCAL_MEM_FENCE);
454 if (gid >= gid_max) return;
463 pw_buf0[0] = pws[gid].i[0];
464 pw_buf0[1] = pws[gid].i[1];
465 pw_buf0[2] = pws[gid].i[2];
466 pw_buf0[3] = pws[gid].i[3];
467 pw_buf1[0] = pws[gid].i[4];
468 pw_buf1[1] = pws[gid].i[5];
469 pw_buf1[2] = pws[gid].i[6];
470 pw_buf1[3] = pws[gid].i[7];
472 const u32 pw_l_len = pws[gid].pw_len;
480 challenge = salt_bufs[salt_pos].salt_buf[0];
489 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
490 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
491 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
492 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
493 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
494 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
495 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
496 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
498 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
504 const u32 search[4] =
506 digests_buf[digests_offset].digest_buf[DGST_R0],
507 digests_buf[digests_offset].digest_buf[DGST_R1],
508 digests_buf[digests_offset].digest_buf[DGST_R2],
509 digests_buf[digests_offset].digest_buf[DGST_R3]
516 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
518 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
520 const u32x pw_len = pw_l_len + pw_r_len;
523 * concat password candidate
526 u32x wordl0[4] = { 0 };
527 u32x wordl1[4] = { 0 };
528 u32x wordl2[4] = { 0 };
529 u32x wordl3[4] = { 0 };
531 wordl0[0] = pw_buf0[0];
532 wordl0[1] = pw_buf0[1];
533 wordl0[2] = pw_buf0[2];
534 wordl0[3] = pw_buf0[3];
535 wordl1[0] = pw_buf1[0];
536 wordl1[1] = pw_buf1[1];
537 wordl1[2] = pw_buf1[2];
538 wordl1[3] = pw_buf1[3];
540 u32x wordr0[4] = { 0 };
541 u32x wordr1[4] = { 0 };
542 u32x wordr2[4] = { 0 };
543 u32x wordr3[4] = { 0 };
545 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
546 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
547 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
548 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
549 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
550 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
551 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
552 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
554 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
556 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
560 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
568 w0[0] = wordl0[0] | wordr0[0];
569 w0[1] = wordl0[1] | wordr0[1];
570 w0[2] = wordl0[2] | wordr0[2];
571 w0[3] = wordl0[3] | wordr0[3];
572 w1[0] = wordl1[0] | wordr1[0];
573 w1[1] = wordl1[1] | wordr1[1];
574 w1[2] = wordl1[2] | wordr1[2];
575 w1[3] = wordl1[3] | wordr1[3];
576 w2[0] = wordl2[0] | wordr2[0];
577 w2[1] = wordl2[1] | wordr2[1];
578 w2[2] = wordl2[2] | wordr2[2];
579 w2[3] = wordl2[3] | wordr2[3];
580 w3[0] = wordl3[0] | wordr3[0];
581 w3[1] = wordl3[1] | wordr3[1];
582 w3[2] = wordl3[2] | wordr3[2];
583 w3[3] = wordl3[3] | wordr3[3];
594 s0[0] = salt_buf0[0];
595 s0[1] = salt_buf0[1];
596 s0[2] = salt_buf0[2];
597 s0[3] = salt_buf0[3];
598 s1[0] = salt_buf1[0];
599 s1[1] = salt_buf1[1];
600 s1[2] = salt_buf1[2];
601 s1[3] = salt_buf1[3];
611 switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len);
613 const u32x pw_salt_len = pw_len + salt_len;
629 w3[2] = pw_salt_len * 8;
641 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
642 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
643 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
644 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
645 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
646 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
647 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
648 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
649 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
650 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
651 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
652 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
653 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
654 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
655 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
656 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
658 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
659 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
660 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
661 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
662 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
663 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
664 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
665 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
666 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
667 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
668 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
669 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
670 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
671 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
672 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
673 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
675 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
676 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
677 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
678 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
679 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
680 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
681 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
682 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
683 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
684 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
685 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
686 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
687 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
688 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
689 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
690 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
692 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
693 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
694 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
695 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
696 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
697 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
698 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
699 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
700 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
701 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
702 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
703 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
704 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
705 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
706 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
707 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
714 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
715 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
716 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
717 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
718 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
719 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
720 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
721 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
722 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
723 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
724 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
725 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
726 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
727 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
728 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
729 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
731 // add the 4 byte challenge here
739 w3[2] = (32 + 4) * 8;
743 * md5 ($hash.$challenge)
751 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
752 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
753 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
754 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
755 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
756 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
757 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
758 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
759 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
760 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
761 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
762 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
763 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
764 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
765 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
766 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
768 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
769 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
770 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
771 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
772 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
773 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
774 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
775 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
776 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
777 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
778 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
779 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
780 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
781 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
782 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
783 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
785 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
786 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
787 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
788 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
789 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
790 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
791 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
792 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
793 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
794 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
795 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
796 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
797 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
798 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
799 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
800 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
802 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
803 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
804 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
805 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
806 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
807 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
808 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
809 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
810 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
811 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
812 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
813 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
814 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
816 if (MATCHES_NONE_VS (a, search[0])) continue;
818 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
819 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
820 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
822 COMPARE_S_SIMD (a, d, c, b);
826 __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)
830 __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)