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