Initial commit
[hashcat.git] / nv / m07500_a1.cu
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _KRB5PA_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW2
16 #define VECT_SIZE1
17 #endif
18
19 #define DGST_R0 3
20 #define DGST_R1 7
21 #define DGST_R2 2
22 #define DGST_R3 6
23
24 #include "include/kernel_functions.c"
25 #include "types_nv.c"
26 #include "common_nv.c"
27
28 __device__ __constant__ comb_t c_combs[1024];
29
30 typedef struct
31 {
32   u8 S[256];
33
34   u8 i;
35   u8 j;
36
37 } RC4_KEY;
38
39 __device__ static void swap (RC4_KEY *rc4_key, const u8 i, const u8 j)
40 {
41   u8 tmp;
42
43   tmp           = rc4_key->S[i];
44   rc4_key->S[i] = rc4_key->S[j];
45   rc4_key->S[j] = tmp;
46 }
47
48 __device__ static void rc4_init_16 (RC4_KEY *rc4_key, const u32 data[4])
49 {
50   u32 i;
51
52   for (i = 0; i < 256; i +=  1) rc4_key->S[i] = i;
53
54   u8 j = 0;
55
56   for (i = 0; i < 256; i += 16)
57   {
58     u32 idx = i;
59
60     u32 v;
61
62     v = data[0];
63
64     j += rc4_key->S[idx] + (v >>  0);  swap (rc4_key, idx, j); idx++;
65     j += rc4_key->S[idx] + (v >>  8);  swap (rc4_key, idx, j); idx++;
66     j += rc4_key->S[idx] + (v >> 16);  swap (rc4_key, idx, j); idx++;
67     j += rc4_key->S[idx] + (v >> 24);  swap (rc4_key, idx, j); idx++;
68
69     v = data[1];
70
71     j += rc4_key->S[idx] + (v >>  0);  swap (rc4_key, idx, j); idx++;
72     j += rc4_key->S[idx] + (v >>  8);  swap (rc4_key, idx, j); idx++;
73     j += rc4_key->S[idx] + (v >> 16);  swap (rc4_key, idx, j); idx++;
74     j += rc4_key->S[idx] + (v >> 24);  swap (rc4_key, idx, j); idx++;
75
76     v = data[2];
77
78     j += rc4_key->S[idx] + (v >>  0);  swap (rc4_key, idx, j); idx++;
79     j += rc4_key->S[idx] + (v >>  8);  swap (rc4_key, idx, j); idx++;
80     j += rc4_key->S[idx] + (v >> 16);  swap (rc4_key, idx, j); idx++;
81     j += rc4_key->S[idx] + (v >> 24);  swap (rc4_key, idx, j); idx++;
82
83     v = data[3];
84
85     j += rc4_key->S[idx] + (v >>  0);  swap (rc4_key, idx, j); idx++;
86     j += rc4_key->S[idx] + (v >>  8);  swap (rc4_key, idx, j); idx++;
87     j += rc4_key->S[idx] + (v >> 16);  swap (rc4_key, idx, j); idx++;
88     j += rc4_key->S[idx] + (v >> 24);  swap (rc4_key, idx, j); idx++;
89   }
90
91   rc4_key->i = 0;
92   rc4_key->j = 0;
93 }
94
95 __device__ static u32 rc4_next_4 (RC4_KEY *rc4_key, const u32 ct)
96 {
97   u8 idx;
98
99   u32 xor4 = 0;
100
101   u8 i = rc4_key->i;
102   u8 j = rc4_key->j;
103
104   i += 1;
105   j += rc4_key->S[i];
106
107   swap (rc4_key, i, j);
108
109   idx = rc4_key->S[i] + rc4_key->S[j];
110
111   xor4 |= rc4_key->S[idx] <<  0;
112
113   i += 1;
114   j += rc4_key->S[i];
115
116   swap (rc4_key, i, j);
117
118   idx = rc4_key->S[i] + rc4_key->S[j];
119
120   xor4 |= rc4_key->S[idx] <<  8;
121
122   i += 1;
123   j += rc4_key->S[i];
124
125   swap (rc4_key, i, j);
126
127   idx = rc4_key->S[i] + rc4_key->S[j];
128
129   xor4 |= rc4_key->S[idx] << 16;
130
131   i += 1;
132   j += rc4_key->S[i];
133
134   swap (rc4_key, i, j);
135
136   idx = rc4_key->S[i] + rc4_key->S[j];
137
138   xor4 |= rc4_key->S[idx] << 24;
139
140   rc4_key->i = i;
141   rc4_key->j = j;
142
143   return ct ^ xor4;
144 }
145
146 __device__ static int decrypt_and_check (RC4_KEY *rc4_key, u32 data[4], u32 timestamp_ct[8])
147 {
148   u32 pt;
149
150   rc4_init_16 (rc4_key, data);
151
152   pt = rc4_next_4 (rc4_key, timestamp_ct[0]);
153   pt = rc4_next_4 (rc4_key, timestamp_ct[1]);
154   pt = rc4_next_4 (rc4_key, timestamp_ct[2]);
155   pt = rc4_next_4 (rc4_key, timestamp_ct[3]);
156
157   if ((pt & 0xffff0000) != 0x30320000) return 0;
158
159   pt = rc4_next_4 (rc4_key, timestamp_ct[4]);
160
161   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
162   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
163   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
164   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0;
165
166   pt = rc4_next_4 (rc4_key, timestamp_ct[5]);
167
168   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
169   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
170   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
171   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0;
172
173   pt = rc4_next_4 (rc4_key, timestamp_ct[6]);
174
175   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
176   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
177   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0; pt >>= 8;
178   if (((pt & 0xff) < '0') || ((pt & 0xff) > '9')) return 0;
179
180   return 1;
181 }
182
183 __device__ static void md4_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
184 {
185   u32x a = digest[0];
186   u32x b = digest[1];
187   u32x c = digest[2];
188   u32x d = digest[3];
189
190   MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
191   MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
192   MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
193   MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
194   MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
195   MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
196   MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
197   MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
198   MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
199   MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
200   MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
201   MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
202   MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
203   MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
204   MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
205   MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
206
207   MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
208   MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
209   MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
210   MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
211   MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
212   MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
213   MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
214   MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
215   MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
216   MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
217   MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
218   MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
219   MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
220   MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
221   MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
222   MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
223
224   MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
225   MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
226   MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
227   MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
228   MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
229   MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
230   MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
231   MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
232   MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
233   MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
234   MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
235   MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
236   MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
237   MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
238   MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
239   MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
240
241   digest[0] += a;
242   digest[1] += b;
243   digest[2] += c;
244   digest[3] += d;
245 }
246
247 __device__ static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
248 {
249   u32x a = digest[0];
250   u32x b = digest[1];
251   u32x c = digest[2];
252   u32x d = digest[3];
253
254   u32x w0_t = w0[0];
255   u32x w1_t = w0[1];
256   u32x w2_t = w0[2];
257   u32x w3_t = w0[3];
258   u32x w4_t = w1[0];
259   u32x w5_t = w1[1];
260   u32x w6_t = w1[2];
261   u32x w7_t = w1[3];
262   u32x w8_t = w2[0];
263   u32x w9_t = w2[1];
264   u32x wa_t = w2[2];
265   u32x wb_t = w2[3];
266   u32x wc_t = w3[0];
267   u32x wd_t = w3[1];
268   u32x we_t = w3[2];
269   u32x wf_t = w3[3];
270
271   MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
272   MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
273   MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
274   MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
275   MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
276   MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
277   MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
278   MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
279   MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
280   MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
281   MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
282   MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
283   MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
284   MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
285   MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
286   MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
287
288   MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
289   MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
290   MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
291   MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
292   MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
293   MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
294   MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
295   MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
296   MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
297   MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
298   MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
299   MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
300   MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
301   MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
302   MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
303   MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
304
305   MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
306   MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
307   MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
308   MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
309   MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
310   MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
311   MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
312   MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
313   MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
314   MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
315   MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
316   MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
317   MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
318   MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
319   MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
320   MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
321
322   MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
323   MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
324   MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
325   MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
326   MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
327   MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
328   MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
329   MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
330   MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
331   MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
332   MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
333   MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
334   MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
335   MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
336   MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
337   MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
338
339   digest[0] += a;
340   digest[1] += b;
341   digest[2] += c;
342   digest[3] += d;
343 }
344
345 __device__ static void hmac_md5_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[4], u32x opad[4])
346 {
347   w0[0] = w0[0] ^ 0x36363636;
348   w0[1] = w0[1] ^ 0x36363636;
349   w0[2] = w0[2] ^ 0x36363636;
350   w0[3] = w0[3] ^ 0x36363636;
351   w1[0] = w1[0] ^ 0x36363636;
352   w1[1] = w1[1] ^ 0x36363636;
353   w1[2] = w1[2] ^ 0x36363636;
354   w1[3] = w1[3] ^ 0x36363636;
355   w2[0] = w2[0] ^ 0x36363636;
356   w2[1] = w2[1] ^ 0x36363636;
357   w2[2] = w2[2] ^ 0x36363636;
358   w2[3] = w2[3] ^ 0x36363636;
359   w3[0] = w3[0] ^ 0x36363636;
360   w3[1] = w3[1] ^ 0x36363636;
361   w3[2] = w3[2] ^ 0x36363636;
362   w3[3] = w3[3] ^ 0x36363636;
363
364   ipad[0] = MD5M_A;
365   ipad[1] = MD5M_B;
366   ipad[2] = MD5M_C;
367   ipad[3] = MD5M_D;
368
369   md5_transform (w0, w1, w2, w3, ipad);
370
371   w0[0] = w0[0] ^ 0x6a6a6a6a;
372   w0[1] = w0[1] ^ 0x6a6a6a6a;
373   w0[2] = w0[2] ^ 0x6a6a6a6a;
374   w0[3] = w0[3] ^ 0x6a6a6a6a;
375   w1[0] = w1[0] ^ 0x6a6a6a6a;
376   w1[1] = w1[1] ^ 0x6a6a6a6a;
377   w1[2] = w1[2] ^ 0x6a6a6a6a;
378   w1[3] = w1[3] ^ 0x6a6a6a6a;
379   w2[0] = w2[0] ^ 0x6a6a6a6a;
380   w2[1] = w2[1] ^ 0x6a6a6a6a;
381   w2[2] = w2[2] ^ 0x6a6a6a6a;
382   w2[3] = w2[3] ^ 0x6a6a6a6a;
383   w3[0] = w3[0] ^ 0x6a6a6a6a;
384   w3[1] = w3[1] ^ 0x6a6a6a6a;
385   w3[2] = w3[2] ^ 0x6a6a6a6a;
386   w3[3] = w3[3] ^ 0x6a6a6a6a;
387
388   opad[0] = MD5M_A;
389   opad[1] = MD5M_B;
390   opad[2] = MD5M_C;
391   opad[3] = MD5M_D;
392
393   md5_transform (w0, w1, w2, w3, opad);
394 }
395
396 __device__ static void hmac_md5_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[4], u32x opad[4], u32x digest[4])
397 {
398   digest[0] = ipad[0];
399   digest[1] = ipad[1];
400   digest[2] = ipad[2];
401   digest[3] = ipad[3];
402
403   md5_transform (w0, w1, w2, w3, digest);
404
405   w0[0] = digest[0];
406   w0[1] = digest[1];
407   w0[2] = digest[2];
408   w0[3] = digest[3];
409   w1[0] = 0x80;
410   w1[1] = 0;
411   w1[2] = 0;
412   w1[3] = 0;
413   w2[0] = 0;
414   w2[1] = 0;
415   w2[2] = 0;
416   w2[3] = 0;
417   w3[0] = 0;
418   w3[1] = 0;
419   w3[2] = (64 + 16) * 8;
420   w3[3] = 0;
421
422   digest[0] = opad[0];
423   digest[1] = opad[1];
424   digest[2] = opad[2];
425   digest[3] = opad[3];
426
427   md5_transform (w0, w1, w2, w3, digest);
428 }
429
430 __device__ static void kerb_prepare (const u32x w0[4], const u32x w1[4], const u32 pw_len, const u32 checksum[4], u32x digest[4])
431 {
432   /**
433    * pads
434    */
435
436   u32x w0_t[4];
437   u32x w1_t[4];
438   u32x w2_t[4];
439   u32x w3_t[4];
440
441   w0_t[0] = w0[0];
442   w0_t[1] = w0[1];
443   w0_t[2] = w0[2];
444   w0_t[3] = w0[3];
445   w1_t[0] = w1[0];
446   w1_t[1] = w1[1];
447   w1_t[2] = w1[2];
448   w1_t[3] = w1[3];
449   w2_t[0] = 0;
450   w2_t[1] = 0;
451   w2_t[2] = 0;
452   w2_t[3] = 0;
453   w3_t[0] = 0;
454   w3_t[1] = 0;
455   w3_t[2] = 0;
456   w3_t[3] = 0;
457
458   // K=MD4(Little_indian(UNICODE(pwd))
459
460   append_0x80_2 (w0_t, w1_t, pw_len);
461
462   make_unicode (w1_t, w2_t, w3_t);
463   make_unicode (w0_t, w0_t, w1_t);
464
465   w3_t[2] = pw_len * 8 * 2;
466   w3_t[3] = 0;
467
468   digest[0] = MD4M_A;
469   digest[1] = MD4M_B;
470   digest[2] = MD4M_C;
471   digest[3] = MD4M_D;
472
473   md4_transform (w0_t, w1_t, w2_t, w3_t, digest);
474
475   // K1=MD5_HMAC(K,1); with 1 encoded as little indian on 4 bytes (01000000 in hexa);
476
477   w0_t[0] = digest[0];
478   w0_t[1] = digest[1];
479   w0_t[2] = digest[2];
480   w0_t[3] = digest[3];
481   w1_t[0] = 0;
482   w1_t[1] = 0;
483   w1_t[2] = 0;
484   w1_t[3] = 0;
485   w2_t[0] = 0;
486   w2_t[1] = 0;
487   w2_t[2] = 0;
488   w2_t[3] = 0;
489   w3_t[0] = 0;
490   w3_t[1] = 0;
491   w3_t[2] = 0;
492   w3_t[3] = 0;
493
494   u32x ipad[4];
495   u32x opad[4];
496
497   hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
498
499   w0_t[0] = 1;
500   w0_t[1] = 0x80;
501   w0_t[2] = 0;
502   w0_t[3] = 0;
503   w1_t[0] = 0;
504   w1_t[1] = 0;
505   w1_t[2] = 0;
506   w1_t[3] = 0;
507   w2_t[0] = 0;
508   w2_t[1] = 0;
509   w2_t[2] = 0;
510   w2_t[3] = 0;
511   w3_t[0] = 0;
512   w3_t[1] = 0;
513   w3_t[2] = (64 + 4) * 8;
514   w3_t[3] = 0;
515
516   hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
517
518   // K3=MD5_HMAC(K1,checksum);
519
520   w0_t[0] = digest[0];
521   w0_t[1] = digest[1];
522   w0_t[2] = digest[2];
523   w0_t[3] = digest[3];
524   w1_t[0] = 0;
525   w1_t[1] = 0;
526   w1_t[2] = 0;
527   w1_t[3] = 0;
528   w2_t[0] = 0;
529   w2_t[1] = 0;
530   w2_t[2] = 0;
531   w2_t[3] = 0;
532   w3_t[0] = 0;
533   w3_t[1] = 0;
534   w3_t[2] = 0;
535   w3_t[3] = 0;
536
537   hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
538
539   w0_t[0] = checksum[0];
540   w0_t[1] = checksum[1];
541   w0_t[2] = checksum[2];
542   w0_t[3] = checksum[3];
543   w1_t[0] = 0x80;
544   w1_t[1] = 0;
545   w1_t[2] = 0;
546   w1_t[3] = 0;
547   w2_t[0] = 0;
548   w2_t[1] = 0;
549   w2_t[2] = 0;
550   w2_t[3] = 0;
551   w3_t[0] = 0;
552   w3_t[1] = 0;
553   w3_t[2] = (64 + 16) * 8;
554   w3_t[3] = 0;
555
556   hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
557 }
558
559 extern "C" __global__ void __launch_bounds__ (64, 1) m07500_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 krb5pa_t *krb5pa_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
560 {
561   /**
562    * modifier
563    */
564
565   __shared__ RC4_KEY rc4_keys[64];
566
567   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
568   const u32 lid = threadIdx.x;
569
570   if (gid >= gid_max) return;
571
572   /**
573    * base
574    */
575
576   u32x wordl0[4];
577
578   wordl0[0] = pws[gid].i[ 0];
579   wordl0[1] = pws[gid].i[ 1];
580   wordl0[2] = pws[gid].i[ 2];
581   wordl0[3] = pws[gid].i[ 3];
582
583   u32x wordl1[4];
584
585   wordl1[0] = pws[gid].i[ 4];
586   wordl1[1] = pws[gid].i[ 5];
587   wordl1[2] = pws[gid].i[ 6];
588   wordl1[3] = pws[gid].i[ 7];
589
590   u32x wordl2[4];
591
592   wordl2[0] = 0;
593   wordl2[1] = 0;
594   wordl2[2] = 0;
595   wordl2[3] = 0;
596
597   u32x wordl3[4];
598
599   wordl3[0] = 0;
600   wordl3[1] = 0;
601   wordl3[2] = 0;
602   wordl3[3] = 0;
603
604   const u32 pw_l_len = pws[gid].pw_len;
605
606   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
607   {
608     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
609   }
610
611   /**
612    * salt
613    */
614
615   u32 checksum[4];
616
617   checksum[0] = krb5pa_bufs[salt_pos].checksum[0];
618   checksum[1] = krb5pa_bufs[salt_pos].checksum[1];
619   checksum[2] = krb5pa_bufs[salt_pos].checksum[2];
620   checksum[3] = krb5pa_bufs[salt_pos].checksum[3];
621
622   u32 timestamp_ct[8];
623
624   timestamp_ct[0] = krb5pa_bufs[salt_pos].timestamp[0];
625   timestamp_ct[1] = krb5pa_bufs[salt_pos].timestamp[1];
626   timestamp_ct[2] = krb5pa_bufs[salt_pos].timestamp[2];
627   timestamp_ct[3] = krb5pa_bufs[salt_pos].timestamp[3];
628   timestamp_ct[4] = krb5pa_bufs[salt_pos].timestamp[4];
629   timestamp_ct[5] = krb5pa_bufs[salt_pos].timestamp[5];
630   timestamp_ct[6] = krb5pa_bufs[salt_pos].timestamp[6];
631   timestamp_ct[7] = krb5pa_bufs[salt_pos].timestamp[7];
632
633   /**
634    * loop
635    */
636
637   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
638   {
639     const u32 pw_r_len = c_combs[il_pos].pw_len;
640
641     const u32 pw_len = pw_l_len + pw_r_len;
642
643     u32 wordr0[4];
644
645     wordr0[0] = c_combs[il_pos].i[0];
646     wordr0[1] = c_combs[il_pos].i[1];
647     wordr0[2] = c_combs[il_pos].i[2];
648     wordr0[3] = c_combs[il_pos].i[3];
649
650     u32 wordr1[4];
651
652     wordr1[0] = c_combs[il_pos].i[4];
653     wordr1[1] = c_combs[il_pos].i[5];
654     wordr1[2] = c_combs[il_pos].i[6];
655     wordr1[3] = c_combs[il_pos].i[7];
656
657     u32 wordr2[4];
658
659     wordr2[0] = 0;
660     wordr2[1] = 0;
661     wordr2[2] = 0;
662     wordr2[3] = 0;
663
664     u32 wordr3[4];
665
666     wordr3[0] = 0;
667     wordr3[1] = 0;
668     wordr3[2] = 0;
669     wordr3[3] = 0;
670
671     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
672     {
673       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
674     }
675
676     u32x w0[4];
677
678     w0[0] = wordl0[0] | wordr0[0];
679     w0[1] = wordl0[1] | wordr0[1];
680     w0[2] = wordl0[2] | wordr0[2];
681     w0[3] = wordl0[3] | wordr0[3];
682
683     u32x w1[4];
684
685     w1[0] = wordl1[0] | wordr1[0];
686     w1[1] = wordl1[1] | wordr1[1];
687     w1[2] = wordl1[2] | wordr1[2];
688     w1[3] = wordl1[3] | wordr1[3];
689
690     u32x w2[4];
691
692     w2[0] = wordl2[0] | wordr2[0];
693     w2[1] = wordl2[1] | wordr2[1];
694     w2[2] = wordl2[2] | wordr2[2];
695     w2[3] = wordl2[3] | wordr2[3];
696
697     u32x w3[4];
698
699     w3[0] = wordl3[0] | wordr3[0];
700     w3[1] = wordl3[1] | wordr3[1];
701     w3[2] = 0;
702     w3[3] = 0;
703
704     /**
705      * kerberos
706      */
707
708     u32x digest[4];
709
710     kerb_prepare (w0, w1, pw_len, checksum, digest);
711
712     u32 tmp[4];
713
714     #ifdef VECT_SIZE1
715
716     tmp[0] = digest[0];
717     tmp[1] = digest[1];
718     tmp[2] = digest[2];
719     tmp[3] = digest[3];
720
721     if (decrypt_and_check (&rc4_keys[lid], tmp, timestamp_ct) == 1)
722     {
723       mark_hash_s0 (plains_buf, hashes_shown, digests_offset, gid, il_pos);
724
725       d_return_buf[lid] = 1;
726     }
727
728     #endif
729   }
730 }
731
732 extern "C" __global__ void __launch_bounds__ (64, 1) m07500_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 krb5pa_t *krb5pa_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)
733 {
734 }
735
736 extern "C" __global__ void __launch_bounds__ (64, 1) m07500_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 krb5pa_t *krb5pa_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)
737 {
738 }
739
740 extern "C" __global__ void __launch_bounds__ (64, 1) m07500_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 krb5pa_t *krb5pa_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
741 {
742   /**
743    * modifier
744    */
745
746   __shared__ RC4_KEY rc4_keys[64];
747
748   const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
749   const u32 lid = threadIdx.x;
750
751   if (gid >= gid_max) return;
752
753   /**
754    * base
755    */
756
757   u32x wordl0[4];
758
759   wordl0[0] = pws[gid].i[ 0];
760   wordl0[1] = pws[gid].i[ 1];
761   wordl0[2] = pws[gid].i[ 2];
762   wordl0[3] = pws[gid].i[ 3];
763
764   u32x wordl1[4];
765
766   wordl1[0] = pws[gid].i[ 4];
767   wordl1[1] = pws[gid].i[ 5];
768   wordl1[2] = pws[gid].i[ 6];
769   wordl1[3] = pws[gid].i[ 7];
770
771   u32x wordl2[4];
772
773   wordl2[0] = 0;
774   wordl2[1] = 0;
775   wordl2[2] = 0;
776   wordl2[3] = 0;
777
778   u32x wordl3[4];
779
780   wordl3[0] = 0;
781   wordl3[1] = 0;
782   wordl3[2] = 0;
783   wordl3[3] = 0;
784
785   const u32 pw_l_len = pws[gid].pw_len;
786
787   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
788   {
789     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
790   }
791
792   /**
793    * salt
794    */
795
796   u32 checksum[4];
797
798   checksum[0] = krb5pa_bufs[salt_pos].checksum[0];
799   checksum[1] = krb5pa_bufs[salt_pos].checksum[1];
800   checksum[2] = krb5pa_bufs[salt_pos].checksum[2];
801   checksum[3] = krb5pa_bufs[salt_pos].checksum[3];
802
803   u32 timestamp_ct[8];
804
805   timestamp_ct[0] = krb5pa_bufs[salt_pos].timestamp[0];
806   timestamp_ct[1] = krb5pa_bufs[salt_pos].timestamp[1];
807   timestamp_ct[2] = krb5pa_bufs[salt_pos].timestamp[2];
808   timestamp_ct[3] = krb5pa_bufs[salt_pos].timestamp[3];
809   timestamp_ct[4] = krb5pa_bufs[salt_pos].timestamp[4];
810   timestamp_ct[5] = krb5pa_bufs[salt_pos].timestamp[5];
811   timestamp_ct[6] = krb5pa_bufs[salt_pos].timestamp[6];
812   timestamp_ct[7] = krb5pa_bufs[salt_pos].timestamp[7];
813
814   /**
815    * loop
816    */
817
818   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
819   {
820     const u32 pw_r_len = c_combs[il_pos].pw_len;
821
822     const u32 pw_len = pw_l_len + pw_r_len;
823
824     u32 wordr0[4];
825
826     wordr0[0] = c_combs[il_pos].i[0];
827     wordr0[1] = c_combs[il_pos].i[1];
828     wordr0[2] = c_combs[il_pos].i[2];
829     wordr0[3] = c_combs[il_pos].i[3];
830
831     u32 wordr1[4];
832
833     wordr1[0] = c_combs[il_pos].i[4];
834     wordr1[1] = c_combs[il_pos].i[5];
835     wordr1[2] = c_combs[il_pos].i[6];
836     wordr1[3] = c_combs[il_pos].i[7];
837
838     u32 wordr2[4];
839
840     wordr2[0] = 0;
841     wordr2[1] = 0;
842     wordr2[2] = 0;
843     wordr2[3] = 0;
844
845     u32 wordr3[4];
846
847     wordr3[0] = 0;
848     wordr3[1] = 0;
849     wordr3[2] = 0;
850     wordr3[3] = 0;
851
852     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
853     {
854       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
855     }
856
857     u32x w0[4];
858
859     w0[0] = wordl0[0] | wordr0[0];
860     w0[1] = wordl0[1] | wordr0[1];
861     w0[2] = wordl0[2] | wordr0[2];
862     w0[3] = wordl0[3] | wordr0[3];
863
864     u32x w1[4];
865
866     w1[0] = wordl1[0] | wordr1[0];
867     w1[1] = wordl1[1] | wordr1[1];
868     w1[2] = wordl1[2] | wordr1[2];
869     w1[3] = wordl1[3] | wordr1[3];
870
871     u32x w2[4];
872
873     w2[0] = wordl2[0] | wordr2[0];
874     w2[1] = wordl2[1] | wordr2[1];
875     w2[2] = wordl2[2] | wordr2[2];
876     w2[3] = wordl2[3] | wordr2[3];
877
878     u32x w3[4];
879
880     w3[0] = wordl3[0] | wordr3[0];
881     w3[1] = wordl3[1] | wordr3[1];
882     w3[2] = 0;
883     w3[3] = 0;
884
885     /**
886      * kerberos
887      */
888
889     u32x digest[4];
890
891     kerb_prepare (w0, w1, pw_len, checksum, digest);
892
893     u32 tmp[4];
894
895     #ifdef VECT_SIZE1
896
897     tmp[0] = digest[0];
898     tmp[1] = digest[1];
899     tmp[2] = digest[2];
900     tmp[3] = digest[3];
901
902     if (decrypt_and_check (&rc4_keys[lid], tmp, timestamp_ct) == 1)
903     {
904       mark_hash_s0 (plains_buf, hashes_shown, digests_offset, gid, il_pos);
905
906       d_return_buf[lid] = 1;
907     }
908
909     #endif
910   }
911 }
912
913 extern "C" __global__ void __launch_bounds__ (64, 1) m07500_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 krb5pa_t *krb5pa_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)
914 {
915 }
916
917 extern "C" __global__ void __launch_bounds__ (64, 1) m07500_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 krb5pa_t *krb5pa_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)
918 {
919 }