2 * Authors......: Jens Steube <jens.steube@gmail.com>
3 * Fist0urs <eddy.maaalou@gmail.com>
4 * Gabriele Gristina <matrix@hashcat.net>
11 //too much register pressure
12 //#define NEW_SIMD_CODE
14 #include "inc_hash_constants.h"
15 #include "inc_vendor.cl"
22 #include "inc_hash_functions.cl"
23 #include "inc_types.cl"
24 #include "inc_common.cl"
25 #include "inc_simd.cl"
35 void swap (__local RC4_KEY *rc4_key, const u8 i, const u8 j)
40 rc4_key->S[i] = rc4_key->S[j];
44 void rc4_init_16 (__local RC4_KEY *rc4_key, const u32 data[4])
49 __local u32 *ptr = (__local u32 *) rc4_key->S;
54 for (u32 i = 0; i < 64; i++)
61 for (u32 i = 0; i < 16; i++)
69 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
70 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
71 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
72 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
76 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
77 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
78 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
79 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
83 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
84 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
85 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
86 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
90 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
91 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
92 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
93 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
97 u8 rc4_next_16 (__local RC4_KEY *rc4_key, u8 i, u8 j, __global u32 *in, u32 out[4])
102 for (u32 k = 0; k < 4; k++)
111 swap (rc4_key, i, j);
113 idx = rc4_key->S[i] + rc4_key->S[j];
115 xor4 |= rc4_key->S[idx] << 0;
120 swap (rc4_key, i, j);
122 idx = rc4_key->S[i] + rc4_key->S[j];
124 xor4 |= rc4_key->S[idx] << 8;
129 swap (rc4_key, i, j);
131 idx = rc4_key->S[i] + rc4_key->S[j];
133 xor4 |= rc4_key->S[idx] << 16;
138 swap (rc4_key, i, j);
140 idx = rc4_key->S[i] + rc4_key->S[j];
142 xor4 |= rc4_key->S[idx] << 24;
144 out[k] = in[k] ^ xor4;
150 void md4_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4])
157 MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
158 MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
159 MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
160 MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
161 MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
162 MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
163 MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
164 MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
165 MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
166 MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
167 MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
168 MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
169 MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
170 MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
171 MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
172 MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
174 MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
175 MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
176 MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
177 MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
178 MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
179 MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
180 MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
181 MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
182 MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
183 MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
184 MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
185 MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
186 MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
187 MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
188 MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
189 MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
191 MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
192 MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
193 MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
194 MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
195 MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
196 MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
197 MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
198 MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
199 MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
200 MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
201 MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
202 MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
203 MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
204 MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
205 MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
206 MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
214 void md5_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4])
238 MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
239 MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
240 MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
241 MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
242 MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
243 MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
244 MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
245 MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
246 MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
247 MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
248 MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
249 MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
250 MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
251 MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
252 MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
253 MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
255 MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
256 MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
257 MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
258 MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
259 MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
260 MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
261 MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
262 MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
263 MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
264 MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
265 MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
266 MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
267 MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
268 MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
269 MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
270 MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
272 MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
273 MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
274 MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
275 MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
276 MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
277 MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
278 MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
279 MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
280 MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
281 MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
282 MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
283 MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
284 MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
285 MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
286 MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
287 MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
289 MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
290 MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
291 MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
292 MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
293 MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
294 MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
295 MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
296 MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
297 MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
298 MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
299 MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
300 MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
301 MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
302 MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
303 MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
304 MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
312 void hmac_md5_pad (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[4], u32 opad[4])
314 w0[0] = w0[0] ^ 0x36363636;
315 w0[1] = w0[1] ^ 0x36363636;
316 w0[2] = w0[2] ^ 0x36363636;
317 w0[3] = w0[3] ^ 0x36363636;
318 w1[0] = w1[0] ^ 0x36363636;
319 w1[1] = w1[1] ^ 0x36363636;
320 w1[2] = w1[2] ^ 0x36363636;
321 w1[3] = w1[3] ^ 0x36363636;
322 w2[0] = w2[0] ^ 0x36363636;
323 w2[1] = w2[1] ^ 0x36363636;
324 w2[2] = w2[2] ^ 0x36363636;
325 w2[3] = w2[3] ^ 0x36363636;
326 w3[0] = w3[0] ^ 0x36363636;
327 w3[1] = w3[1] ^ 0x36363636;
328 w3[2] = w3[2] ^ 0x36363636;
329 w3[3] = w3[3] ^ 0x36363636;
336 md5_transform (w0, w1, w2, w3, ipad);
338 w0[0] = w0[0] ^ 0x6a6a6a6a;
339 w0[1] = w0[1] ^ 0x6a6a6a6a;
340 w0[2] = w0[2] ^ 0x6a6a6a6a;
341 w0[3] = w0[3] ^ 0x6a6a6a6a;
342 w1[0] = w1[0] ^ 0x6a6a6a6a;
343 w1[1] = w1[1] ^ 0x6a6a6a6a;
344 w1[2] = w1[2] ^ 0x6a6a6a6a;
345 w1[3] = w1[3] ^ 0x6a6a6a6a;
346 w2[0] = w2[0] ^ 0x6a6a6a6a;
347 w2[1] = w2[1] ^ 0x6a6a6a6a;
348 w2[2] = w2[2] ^ 0x6a6a6a6a;
349 w2[3] = w2[3] ^ 0x6a6a6a6a;
350 w3[0] = w3[0] ^ 0x6a6a6a6a;
351 w3[1] = w3[1] ^ 0x6a6a6a6a;
352 w3[2] = w3[2] ^ 0x6a6a6a6a;
353 w3[3] = w3[3] ^ 0x6a6a6a6a;
360 md5_transform (w0, w1, w2, w3, opad);
363 void hmac_md5_run (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[4], u32 opad[4], u32 digest[4])
370 md5_transform (w0, w1, w2, w3, digest);
386 w3[2] = (64 + 16) * 8;
394 md5_transform (w0, w1, w2, w3, digest);
397 int decrypt_and_check (__local RC4_KEY *rc4_key, u32 data[4], __global u32 *edata2, const u32 edata2_len, const u32 K2[4], const u32 checksum[4])
399 rc4_init_16 (rc4_key, data);
408 8 first bytes are nonce, then ASN1 structs (DER encoding: type-length-data)
410 if length >= 128 bytes:
411 length is on 2 bytes and type is \x63\x82 (encode_krb5_enc_tkt_part) and data is an ASN1 sequence \x30\x82
413 length is on 1 byte and type is \x63\x81 and data is an ASN1 sequence \x30\x81
415 next headers follow the same ASN1 "type-length-data" scheme
418 j = rc4_next_16 (rc4_key, i, j, edata2 + 0, out0); i += 16;
420 if (((out0[2] & 0xff00ffff) != 0x30008163) && ((out0[2] & 0x0000ffff) != 0x00008263)) return 0;
422 j = rc4_next_16 (rc4_key, i, j, edata2 + 4, out1); i += 16;
424 if (((out1[0] & 0x00ffffff) != 0x00000503) && (out1[0] != 0x050307A0)) return 0;
426 rc4_init_16 (rc4_key, data);
458 hmac_md5_pad (w0, w1, w2, w3, ipad, opad);
462 for (edata2_left = edata2_len; edata2_left >= 64; edata2_left -= 64)
464 j = rc4_next_16 (rc4_key, i, j, edata2, w0); i += 16; edata2 += 4;
465 j = rc4_next_16 (rc4_key, i, j, edata2, w1); i += 16; edata2 += 4;
466 j = rc4_next_16 (rc4_key, i, j, edata2, w2); i += 16; edata2 += 4;
467 j = rc4_next_16 (rc4_key, i, j, edata2, w3); i += 16; edata2 += 4;
469 md5_transform (w0, w1, w2, w3, ipad);
489 if (edata2_left < 16)
491 j = rc4_next_16 (rc4_key, i, j, edata2, w0); i += 16; edata2 += 4;
493 truncate_block (w0, edata2_left & 0xf);
494 append_0x80_1x4 (w0, edata2_left & 0xf);
496 w3[2] = (64 + edata2_len) * 8;
499 md5_transform (w0, w1, w2, w3, ipad);
501 else if (edata2_left < 32)
503 j = rc4_next_16 (rc4_key, i, j, edata2, w0); i += 16; edata2 += 4;
504 j = rc4_next_16 (rc4_key, i, j, edata2, w1); i += 16; edata2 += 4;
506 truncate_block (w1, edata2_left & 0xf);
507 append_0x80_1x4 (w1, edata2_left & 0xf);
509 w3[2] = (64 + edata2_len) * 8;
512 md5_transform (w0, w1, w2, w3, ipad);
514 else if (edata2_left < 48)
516 j = rc4_next_16 (rc4_key, i, j, edata2, w0); i += 16; edata2 += 4;
517 j = rc4_next_16 (rc4_key, i, j, edata2, w1); i += 16; edata2 += 4;
518 j = rc4_next_16 (rc4_key, i, j, edata2, w2); i += 16; edata2 += 4;
520 truncate_block (w2, edata2_left & 0xf);
521 append_0x80_1x4 (w2, edata2_left & 0xf);
523 w3[2] = (64 + edata2_len) * 8;
526 md5_transform (w0, w1, w2, w3, ipad);
530 j = rc4_next_16 (rc4_key, i, j, edata2, w0); i += 16; edata2 += 4;
531 j = rc4_next_16 (rc4_key, i, j, edata2, w1); i += 16; edata2 += 4;
532 j = rc4_next_16 (rc4_key, i, j, edata2, w2); i += 16; edata2 += 4;
533 j = rc4_next_16 (rc4_key, i, j, edata2, w3); i += 16; edata2 += 4;
535 truncate_block (w3, edata2_left & 0xf);
536 append_0x80_1x4 (w3, edata2_left & 0xf);
538 if (edata2_left < 56)
540 w3[2] = (64 + edata2_len) * 8;
543 md5_transform (w0, w1, w2, w3, ipad);
547 md5_transform (w0, w1, w2, w3, ipad);
563 w3[2] = (64 + edata2_len) * 8;
566 md5_transform (w0, w1, w2, w3, ipad);
584 w3[2] = (64 + 16) * 8;
587 md5_transform (w0, w1, w2, w3, opad);
589 if (checksum[0] != opad[0]) return 0;
590 if (checksum[1] != opad[1]) return 0;
591 if (checksum[2] != opad[2]) return 0;
592 if (checksum[3] != opad[3]) return 0;
597 void kerb_prepare (const u32 w0[4], const u32 w1[4], const u32 pw_len, const u32 checksum[4], u32 digest[4], u32 K2[4])
625 // K=MD4(Little_indian(UNICODE(pwd))
627 append_0x80_2x4 (w0_t, w1_t, pw_len);
629 make_unicode (w1_t, w2_t, w3_t);
630 make_unicode (w0_t, w0_t, w1_t);
632 w3_t[2] = pw_len * 8 * 2;
640 md4_transform (w0_t, w1_t, w2_t, w3_t, digest);
642 // K1=MD5_HMAC(K,1); with 2 encoded as little indian on 4 bytes (02000000 in hexa);
664 hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
680 w3_t[2] = (64 + 4) * 8;
683 hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
692 // K3=MD5_HMAC(K1,checksum);
711 hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
713 w0_t[0] = checksum[0];
714 w0_t[1] = checksum[1];
715 w0_t[2] = checksum[2];
716 w0_t[3] = checksum[3];
727 w3_t[2] = (64 + 16) * 8;
730 hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
733 __kernel void m13100_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 krb5tgs_t *krb5tgs_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)
739 const u32 lid = get_local_id (0);
745 const u32 gid = get_global_id (0);
747 if (gid >= gid_max) return;
752 pw_buf0[0] = pws[gid].i[0];
753 pw_buf0[1] = pws[gid].i[1];
754 pw_buf0[2] = pws[gid].i[2];
755 pw_buf0[3] = pws[gid].i[3];
756 pw_buf1[0] = pws[gid].i[4];
757 pw_buf1[1] = pws[gid].i[5];
758 pw_buf1[2] = pws[gid].i[6];
759 pw_buf1[3] = pws[gid].i[7];
761 const u32 pw_l_len = pws[gid].pw_len;
767 __local RC4_KEY rc4_keys[64];
775 checksum[0] = krb5tgs_bufs[salt_pos].checksum[0];
776 checksum[1] = krb5tgs_bufs[salt_pos].checksum[1];
777 checksum[2] = krb5tgs_bufs[salt_pos].checksum[2];
778 checksum[3] = krb5tgs_bufs[salt_pos].checksum[3];
784 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
786 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
788 const u32x pw_len = pw_l_len + pw_r_len;
791 * concat password candidate
794 u32x wordl0[4] = { 0 };
795 u32x wordl1[4] = { 0 };
796 u32x wordl2[4] = { 0 };
797 u32x wordl3[4] = { 0 };
799 wordl0[0] = pw_buf0[0];
800 wordl0[1] = pw_buf0[1];
801 wordl0[2] = pw_buf0[2];
802 wordl0[3] = pw_buf0[3];
803 wordl1[0] = pw_buf1[0];
804 wordl1[1] = pw_buf1[1];
805 wordl1[2] = pw_buf1[2];
806 wordl1[3] = pw_buf1[3];
808 u32x wordr0[4] = { 0 };
809 u32x wordr1[4] = { 0 };
810 u32x wordr2[4] = { 0 };
811 u32x wordr3[4] = { 0 };
813 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
814 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
815 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
816 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
817 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
818 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
819 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
820 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
822 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
824 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
828 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
834 w0[0] = wordl0[0] | wordr0[0];
835 w0[1] = wordl0[1] | wordr0[1];
836 w0[2] = wordl0[2] | wordr0[2];
837 w0[3] = wordl0[3] | wordr0[3];
838 w1[0] = wordl1[0] | wordr1[0];
839 w1[1] = wordl1[1] | wordr1[1];
840 w1[2] = wordl1[2] | wordr1[2];
841 w1[3] = wordl1[3] | wordr1[3];
851 kerb_prepare (w0, w1, pw_len, checksum, digest, K2);
860 if (decrypt_and_check (&rc4_keys[lid], tmp, krb5tgs_bufs[salt_pos].edata2, krb5tgs_bufs[salt_pos].edata2_len, K2, checksum) == 1)
862 mark_hash (plains_buf, d_return_buf, salt_pos, 0, digests_offset + 0, gid, il_pos);
867 __kernel void m13100_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 krb5tgs_t *krb5tgs_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)
871 __kernel void m13100_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 krb5tgs_t *krb5tgs_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)
875 __kernel void m13100_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 krb5tgs_t *krb5tgs_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)
881 const u32 lid = get_local_id (0);
887 const u32 gid = get_global_id (0);
889 if (gid >= gid_max) return;
894 pw_buf0[0] = pws[gid].i[0];
895 pw_buf0[1] = pws[gid].i[1];
896 pw_buf0[2] = pws[gid].i[2];
897 pw_buf0[3] = pws[gid].i[3];
898 pw_buf1[0] = pws[gid].i[4];
899 pw_buf1[1] = pws[gid].i[5];
900 pw_buf1[2] = pws[gid].i[6];
901 pw_buf1[3] = pws[gid].i[7];
903 const u32 pw_l_len = pws[gid].pw_len;
909 __local RC4_KEY rc4_keys[64];
917 checksum[0] = krb5tgs_bufs[salt_pos].checksum[0];
918 checksum[1] = krb5tgs_bufs[salt_pos].checksum[1];
919 checksum[2] = krb5tgs_bufs[salt_pos].checksum[2];
920 checksum[3] = krb5tgs_bufs[salt_pos].checksum[3];
926 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
928 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
930 const u32x pw_len = pw_l_len + pw_r_len;
933 * concat password candidate
936 u32x wordl0[4] = { 0 };
937 u32x wordl1[4] = { 0 };
938 u32x wordl2[4] = { 0 };
939 u32x wordl3[4] = { 0 };
941 wordl0[0] = pw_buf0[0];
942 wordl0[1] = pw_buf0[1];
943 wordl0[2] = pw_buf0[2];
944 wordl0[3] = pw_buf0[3];
945 wordl1[0] = pw_buf1[0];
946 wordl1[1] = pw_buf1[1];
947 wordl1[2] = pw_buf1[2];
948 wordl1[3] = pw_buf1[3];
950 u32x wordr0[4] = { 0 };
951 u32x wordr1[4] = { 0 };
952 u32x wordr2[4] = { 0 };
953 u32x wordr3[4] = { 0 };
955 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
956 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
957 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
958 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
959 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
960 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
961 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
962 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
964 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
966 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
970 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
976 w0[0] = wordl0[0] | wordr0[0];
977 w0[1] = wordl0[1] | wordr0[1];
978 w0[2] = wordl0[2] | wordr0[2];
979 w0[3] = wordl0[3] | wordr0[3];
980 w1[0] = wordl1[0] | wordr1[0];
981 w1[1] = wordl1[1] | wordr1[1];
982 w1[2] = wordl1[2] | wordr1[2];
983 w1[3] = wordl1[3] | wordr1[3];
993 kerb_prepare (w0, w1, pw_len, checksum, digest, K2);
1002 if (decrypt_and_check (&rc4_keys[lid], tmp, krb5tgs_bufs[salt_pos].edata2, krb5tgs_bufs[salt_pos].edata2_len, K2, checksum) == 1)
1004 mark_hash (plains_buf, d_return_buf, salt_pos, 0, digests_offset + 0, gid, il_pos);
1009 __kernel void m13100_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 krb5tgs_t *krb5tgs_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)
1013 __kernel void m13100_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 krb5tgs_t *krb5tgs_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)