0f5790e84662b68dd312fc2a5f64d7af4fa1b7ce
[hashcat.git] / OpenCL / types_ocl.c
1 /**
2 * Authors.....: Jens Steube <jens.steube@gmail.com>
3 * magnum <john.magnum@hushmail.com>
4 *
5 * License.....: MIT
6 */
7
8 #define DEVICE_TYPE_CPU 2
9 #define DEVICE_TYPE_GPU 4
10
11 typedef uchar u8;
12 typedef ushort u16;
13 typedef uint u32;
14 typedef ulong u64;
15
16 #ifndef NEW_SIMD_CODE
17 #undef VECT_SIZE
18 #define VECT_SIZE 1
19 #endif
20
21 #define CONCAT(a, b) a##b
22 #define VTYPE(type, width) CONCAT(type, width)
23
24 #if VECT_SIZE == 1
25 typedef uchar u8x;
26 typedef ushort u16x;
27 typedef uint u32x;
28 typedef ulong u64x;
29 #else
30 typedef VTYPE(uchar, VECT_SIZE) u8x;
31 typedef VTYPE(ushort, VECT_SIZE) u16x;
32 typedef VTYPE(uint, VECT_SIZE) u32x;
33 typedef VTYPE(ulong, VECT_SIZE) u64x;
34 #endif
35
36 inline u32 l32_from_64_S (u64 a)
37 {
38 const u32 r = (u32) (a);
39
40 return r;
41 }
42
43 inline u32 h32_from_64_S (u64 a)
44 {
45 a >>= 32;
46
47 const u32 r = (u32) (a);
48
49 return r;
50 }
51
52 inline u64 hl32_to_64_S (const u32 a, const u32 b)
53 {
54 return as_ulong ((uint2) (b, a));
55 }
56
57 inline u32x l32_from_64 (u64x a)
58 {
59 u32x r;
60
61 #if VECT_SIZE == 1
62 r = (u32) a;
63 #endif
64
65 #if VECT_SIZE >= 2
66 r.s0 = (u32) a.s0;
67 r.s1 = (u32) a.s1;
68 #endif
69
70 #if VECT_SIZE >= 4
71 r.s2 = (u32) a.s2;
72 r.s3 = (u32) a.s3;
73 #endif
74
75 #if VECT_SIZE >= 8
76 r.s4 = (u32) a.s4;
77 r.s5 = (u32) a.s5;
78 r.s6 = (u32) a.s6;
79 r.s7 = (u32) a.s7;
80 #endif
81
82 #if VECT_SIZE >= 16
83 r.s8 = (u32) a.s8;
84 r.s9 = (u32) a.s9;
85 r.sa = (u32) a.sa;
86 r.sb = (u32) a.sb;
87 r.sc = (u32) a.sc;
88 r.sd = (u32) a.sd;
89 r.se = (u32) a.se;
90 r.sf = (u32) a.sf;
91 #endif
92
93 return r;
94 }
95
96 inline u32x h32_from_64 (u64x a)
97 {
98 a >>= 32;
99
100 u32x r;
101
102 #if VECT_SIZE == 1
103 r = (u32) a;
104 #endif
105
106 #if VECT_SIZE >= 2
107 r.s0 = (u32) a.s0;
108 r.s1 = (u32) a.s1;
109 #endif
110
111 #if VECT_SIZE >= 4
112 r.s2 = (u32) a.s2;
113 r.s3 = (u32) a.s3;
114 #endif
115
116 #if VECT_SIZE >= 8
117 r.s4 = (u32) a.s4;
118 r.s5 = (u32) a.s5;
119 r.s6 = (u32) a.s6;
120 r.s7 = (u32) a.s7;
121 #endif
122
123 #if VECT_SIZE >= 16
124 r.s8 = (u32) a.s8;
125 r.s9 = (u32) a.s9;
126 r.sa = (u32) a.sa;
127 r.sb = (u32) a.sb;
128 r.sc = (u32) a.sc;
129 r.sd = (u32) a.sd;
130 r.se = (u32) a.se;
131 r.sf = (u32) a.sf;
132 #endif
133
134 return r;
135 }
136
137 inline u64x hl32_to_64 (const u32x a, const u32x b)
138 {
139 u64x r;
140
141 #if VECT_SIZE == 1
142 r = as_ulong ((uint2) (b, a));
143 #endif
144
145 #if VECT_SIZE >= 2
146 r.s0 = as_ulong ((uint2) (b.s0, a.s0));
147 r.s1 = as_ulong ((uint2) (b.s1, a.s1));
148 #endif
149
150 #if VECT_SIZE >= 4
151 r.s2 = as_ulong ((uint2) (b.s2, a.s2));
152 r.s3 = as_ulong ((uint2) (b.s3, a.s3));
153 #endif
154
155 #if VECT_SIZE >= 8
156 r.s4 = as_ulong ((uint2) (b.s4, a.s4));
157 r.s5 = as_ulong ((uint2) (b.s5, a.s5));
158 r.s6 = as_ulong ((uint2) (b.s6, a.s6));
159 r.s7 = as_ulong ((uint2) (b.s7, a.s7));
160 #endif
161
162 #if VECT_SIZE >= 16
163 r.s8 = as_ulong ((uint2) (b.s8, a.s8));
164 r.s9 = as_ulong ((uint2) (b.s9, a.s9));
165 r.sa = as_ulong ((uint2) (b.sa, a.sa));
166 r.sb = as_ulong ((uint2) (b.sb, a.sb));
167 r.sc = as_ulong ((uint2) (b.sc, a.sc));
168 r.sd = as_ulong ((uint2) (b.sd, a.sd));
169 r.se = as_ulong ((uint2) (b.se, a.se));
170 r.sf = as_ulong ((uint2) (b.sf, a.sf));
171 #endif
172
173 return r;
174 }
175
176 #ifdef IS_AMD
177 inline u32 swap32_S (const u32 v)
178 {
179 return (as_uint (as_uchar4 (v).s3210));
180 }
181
182 inline u64 swap64_S (const u64 v)
183 {
184 return (as_ulong (as_uchar8 (v).s76543210));
185 }
186
187 inline u32 rotr32_S (const u32 a, const u32 n)
188 {
189 return rotate (a, 32 - n);
190 }
191
192 inline u32 rotl32_S (const u32 a, const u32 n)
193 {
194 return rotate (a, n);
195 }
196
197 inline u64 rotr64_S (const u64 a, const u32 n)
198 {
199 const u32 a0 = h32_from_64_S (a);
200 const u32 a1 = l32_from_64_S (a);
201
202 const u32 t0 = (n >= 32) ? amd_bitalign (a0, a1, n - 32) : amd_bitalign (a1, a0, n);
203 const u32 t1 = (n >= 32) ? amd_bitalign (a1, a0, n - 32) : amd_bitalign (a0, a1, n);
204
205 const u64 r = hl32_to_64_S (t0, t1);
206
207 return r;
208 }
209
210 inline u64 rotl64_S (const u64 a, const u32 n)
211 {
212 return rotr64_S (a, 64 - n);
213 }
214
215 inline u32x swap32 (const u32x v)
216 {
217 return ((v >> 24) & 0x000000ff)
218 | ((v >> 8) & 0x0000ff00)
219 | ((v << 8) & 0x00ff0000)
220 | ((v << 24) & 0xff000000);
221 }
222
223 inline u64x swap64 (const u64x v)
224 {
225 return ((v >> 56) & 0x00000000000000ff)
226 | ((v >> 40) & 0x000000000000ff00)
227 | ((v >> 24) & 0x0000000000ff0000)
228 | ((v >> 8) & 0x00000000ff000000)
229 | ((v << 8) & 0x000000ff00000000)
230 | ((v << 24) & 0x0000ff0000000000)
231 | ((v << 40) & 0x00ff000000000000)
232 | ((v << 56) & 0xff00000000000000);
233 }
234
235 inline u32x rotr32 (const u32x a, const u32 n)
236 {
237 return rotate (a, 32 - n);
238 }
239
240 inline u32x rotl32 (const u32x a, const u32 n)
241 {
242 return rotate (a, n);
243 }
244
245 inline u64x rotr64 (const u64x a, const u32 n)
246 {
247 const u32x a0 = h32_from_64 (a);
248 const u32x a1 = l32_from_64 (a);
249
250 const u32x t0 = (n >= 32) ? amd_bitalign (a0, a1, n - 32) : amd_bitalign (a1, a0, n);
251 const u32x t1 = (n >= 32) ? amd_bitalign (a1, a0, n - 32) : amd_bitalign (a0, a1, n);
252
253 const u64x r = hl32_to_64 (t0, t1);
254
255 return r;
256 }
257
258 inline u64x rotl64 (const u64x a, const u32 n)
259 {
260 return rotr64 (a, 64 - n);
261 }
262
263 inline u32 __bfe (const u32 a, const u32 b, const u32 c)
264 {
265 return amd_bfe (a, b, c);
266 }
267
268 inline u32 amd_bytealign_S (const u32 a, const u32 b, const u32 c)
269 {
270 return amd_bytealign (a, b, c);
271 }
272 #endif
273
274 #ifdef IS_NV
275 inline u32 swap32_S (const u32 v)
276 {
277 u32 r;
278
279 asm ("prmt.b32 %0, %1, 0, 0x0123;" : "=r"(r) : "r"(v));
280
281 return r;
282 }
283
284 inline u64 swap64_S (const u64 v)
285 {
286 u32 il;
287 u32 ir;
288
289 asm ("mov.b64 {%0, %1}, %2;" : "=r"(il), "=r"(ir) : "l"(v));
290
291 u32 tl;
292 u32 tr;
293
294 asm ("prmt.b32 %0, %1, 0, 0x0123;" : "=r"(tl) : "r"(il));
295 asm ("prmt.b32 %0, %1, 0, 0x0123;" : "=r"(tr) : "r"(ir));
296
297 u64 r;
298
299 asm ("mov.b64 %0, {%1, %2};" : "=l"(r) : "r"(tr), "r"(tl));
300
301 return r;
302 }
303
304 inline u32 rotr32_S (const u32 a, const u32 n)
305 {
306 return rotate (a, 32 - n);
307 }
308
309 inline u32 rotl32_S (const u32 a, const u32 n)
310 {
311 return rotate (a, n);
312 }
313
314 inline u64 rotr64_S (const u64 a, const u32 n)
315 {
316 return rotate (a, (u64) 64 - n);
317 }
318
319 inline u64 rotl64_S (const u64 a, const u32 n)
320 {
321 return rotr64_S (a, 64 - n);
322 }
323
324 inline u32 __byte_perm_S (const u32 a, const u32 b, const u32 c)
325 {
326 u32 r;
327
328 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(c));
329
330 return r;
331 }
332
333 inline u32x swap32 (const u32x v)
334 {
335 return ((v >> 24) & 0x000000ff)
336 | ((v >> 8) & 0x0000ff00)
337 | ((v << 8) & 0x00ff0000)
338 | ((v << 24) & 0xff000000);
339 }
340
341 inline u64x swap64 (const u64x v)
342 {
343 return ((v >> 56) & 0x00000000000000ff)
344 | ((v >> 40) & 0x000000000000ff00)
345 | ((v >> 24) & 0x0000000000ff0000)
346 | ((v >> 8) & 0x00000000ff000000)
347 | ((v << 8) & 0x000000ff00000000)
348 | ((v << 24) & 0x0000ff0000000000)
349 | ((v << 40) & 0x00ff000000000000)
350 | ((v << 56) & 0xff00000000000000);
351 }
352
353 inline u32x rotr32 (const u32x a, const u32 n)
354 {
355 #if CUDA_ARCH < 350
356
357 u32x t;
358 u32x r;
359
360 #if VECT_SIZE == 2
361
362 asm ("shr.b32 %4, %2, %6;"
363 "shr.b32 %5, %3, %6;"
364 "mad.lo.u32 %0, %2, %7, %4;"
365 "mad.lo.u32 %1, %3, %7, %5;"
366 : "=r"(r.s0),
367 "=r"(r.s1)
368 : "r"(a.s0),
369 "r"(a.s1),
370 "r"(t.s0),
371 "r"(t.s1),
372 "r"(n),
373 "r"(1 << (32 - n)));
374
375 #elif VECT_SIZE == 4
376
377 asm ("shr.b32 %8, %4, %12;\n"
378 "shr.b32 %9, %5, %12;\n"
379 "shr.b32 %10, %6, %12;\n"
380 "shr.b32 %11, %7, %12;\n"
381 "mad.lo.u32 %0, %4, %13, %8;\n"
382 "mad.lo.u32 %1, %5, %13, %9;\n"
383 "mad.lo.u32 %2, %6, %13, %10;\n"
384 "mad.lo.u32 %3, %7, %13, %11;\n"
385 : "=r"(r.s0),
386 "=r"(r.s1),
387 "=r"(r.s2),
388 "=r"(r.s3)
389 : "r"(a.s0),
390 "r"(a.s1),
391 "r"(a.s2),
392 "r"(a.s3),
393 "r"(t.s0),
394 "r"(t.s1),
395 "r"(t.s2),
396 "r"(t.s3),
397 "r"(n),
398 "r"(1 << (32 - n)));
399
400 #else
401
402 r = rotate (a, n);
403
404 #endif
405
406 return r;
407
408 #else
409
410 return rotate (a, n);
411
412 #endif
413 }
414
415 inline u32x rotl32 (const u32x a, const u32 n)
416 {
417 return rotr32 (a, 32 - n);
418 }
419
420 inline u64x rotr64 (const u64x a, const u32 n)
421 {
422 return rotate (a, (u64) 64 - n);
423 }
424
425 inline u64x rotl64 (const u64x a, const u32 n)
426 {
427 return rotate (a, (u64) n);
428 }
429
430 inline u32x __byte_perm (const u32x a, const u32x b, const u32x c)
431 {
432 u32x r;
433
434 #if VECT_SIZE == 1
435 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(c) );
436 #endif
437
438 #if VECT_SIZE >= 2
439 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s0) : "r"(a.s0), "r"(b.s0), "r"(c.s0));
440 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s1) : "r"(a.s1), "r"(b.s1), "r"(c.s1));
441 #endif
442
443 #if VECT_SIZE >= 4
444 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s2) : "r"(a.s2), "r"(b.s2), "r"(c.s2));
445 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s3) : "r"(a.s3), "r"(b.s3), "r"(c.s3));
446 #endif
447
448 #if VECT_SIZE >= 8
449 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s4) : "r"(a.s4), "r"(b.s4), "r"(c.s4));
450 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s5) : "r"(a.s5), "r"(b.s5), "r"(c.s5));
451 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s6) : "r"(a.s6), "r"(b.s6), "r"(c.s6));
452 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s7) : "r"(a.s7), "r"(b.s7), "r"(c.s7));
453 #endif
454
455 #if VECT_SIZE >= 16
456 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s8) : "r"(a.s8), "r"(b.s8), "r"(c.s8));
457 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s9) : "r"(a.s9), "r"(b.s9), "r"(c.s9));
458 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sa) : "r"(a.sa), "r"(b.sa), "r"(c.sa));
459 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sb) : "r"(a.sb), "r"(b.sb), "r"(c.sb));
460 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sc) : "r"(a.sc), "r"(b.sc), "r"(c.sc));
461 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sd) : "r"(a.sd), "r"(b.sd), "r"(c.sd));
462 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.se) : "r"(a.se), "r"(b.se), "r"(c.se));
463 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sf) : "r"(a.sf), "r"(b.sf), "r"(c.sf));
464 #endif
465
466 return r;
467 }
468
469 inline u32 __bfe (const u32 a, const u32 b, const u32 c)
470 {
471 u32 r;
472
473 asm ("bfe.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(c));
474
475 return r;
476 }
477
478 #if CUDA_ARCH >= 350
479 inline u32 amd_bytealign (const u32 a, const u32 b, const u32 c)
480 {
481 u32 r;
482
483 asm ("shf.r.wrap.b32 %0, %1, %2, %3;" : "=r"(r) : "r"(b), "r"(a), "r"((c & 3) * 8));
484
485 return r;
486 }
487 #else
488 inline u32 amd_bytealign (const u32 a, const u32 b, const u32 c)
489 {
490 return __byte_perm_S (b, a, (0x76543210 >> ((c & 3) * 4)) & 0xffff);
491 }
492 #endif
493
494 #endif
495
496 #ifdef IS_GENERIC
497 inline u32 swap32_S (const u32 v)
498 {
499 return (as_uint (as_uchar4 (v).s3210));
500 }
501
502 inline u64 swap64_S (const u64 v)
503 {
504 return (as_ulong (as_uchar8 (v).s76543210));
505 }
506
507 inline u32 rotr32_S (const u32 a, const u32 n)
508 {
509 return rotate (a, 32 - n);
510 }
511
512 inline u32 rotl32_S (const u32 a, const u32 n)
513 {
514 return rotate (a, n);
515 }
516
517 inline u64 rotr64_S (const u64 a, const u32 n)
518 {
519 return rotate (a, (u64) 64 - n);
520 }
521
522 inline u64 rotl64_S (const u64 a, const u32 n)
523 {
524 return rotate (a, (u64) n);
525 }
526
527 inline u32 amd_bytealign_S (const u32 a, const u32 b, const u32 c)
528 {
529 const u64 tmp = ((((u64) a) << 32) | ((u64) b)) >> ((c & 3) * 8);
530
531 return (u32) (tmp);
532 }
533
534 inline u32x swap32 (const u32x v)
535 {
536 return ((v >> 24) & 0x000000ff)
537 | ((v >> 8) & 0x0000ff00)
538 | ((v << 8) & 0x00ff0000)
539 | ((v << 24) & 0xff000000);
540 }
541
542 inline u64x swap64 (const u64x v)
543 {
544 return ((v >> 56) & 0x00000000000000ff)
545 | ((v >> 40) & 0x000000000000ff00)
546 | ((v >> 24) & 0x0000000000ff0000)
547 | ((v >> 8) & 0x00000000ff000000)
548 | ((v << 8) & 0x000000ff00000000)
549 | ((v << 24) & 0x0000ff0000000000)
550 | ((v << 40) & 0x00ff000000000000)
551 | ((v << 56) & 0xff00000000000000);
552 }
553
554 inline u32x rotr32 (const u32x a, const u32 n)
555 {
556 return rotate (a, 32 - n);
557 }
558
559 inline u32x rotl32 (const u32x a, const u32 n)
560 {
561 return rotate (a, n);
562 }
563
564 inline u64x rotr64 (const u64x a, const u32 n)
565 {
566 return rotate (a, (u64) 64 - n);
567 }
568
569 inline u64x rotl64 (const u64x a, const u32 n)
570 {
571 return rotate (a, (u64) n);
572 }
573
574 inline u32 __bfe (const u32 a, const u32 b, const u32 c)
575 {
576 #define BIT(x) (1 << (x))
577 #define BIT_MASK(x) (BIT (x) - 1)
578 #define BFE(x,y,z) (((x) >> (y)) & BIT_MASK (z))
579
580 return BFE (a, b, c);
581 }
582
583 inline u32x amd_bytealign (const u32x a, const u32x b, const u32 c)
584 {
585 #if VECT_SIZE == 1
586 const u64x tmp = ((((u64x) (a)) << 32) | ((u64x) (b))) >> ((c & 3) * 8);
587
588 return (u32x) (tmp);
589 #endif
590
591 #if VECT_SIZE == 2
592 const u64x tmp = ((((u64x) (a.s0, a.s1)) << 32) | ((u64x) (b.s0, b.s1))) >> ((c & 3) * 8);
593
594 return (u32x) (tmp.s0, tmp.s1);
595 #endif
596
597 #if VECT_SIZE == 4
598 const u64x tmp = ((((u64x) (a.s0, a.s1, a.s2, a.s3)) << 32) | ((u64x) (b.s0, b.s1, b.s2, b.s3))) >> ((c & 3) * 8);
599
600 return (u32x) (tmp.s0, tmp.s1, tmp.s2, tmp.s3);
601 #endif
602
603 #if VECT_SIZE == 8
604 const u64x tmp = ((((u64x) (a.s0, a.s1, a.s2, a.s3, a.s4, a.s5, a.s6, a.s7)) << 32) | ((u64x) (b.s0, b.s1, b.s2, b.s3, b.s4, b.s5, b.s6, b.s7))) >> ((c & 3) * 8);
605
606 return (u32x) (tmp.s0, tmp.s1, tmp.s2, tmp.s3, tmp.s4, tmp.s5, tmp.s6, tmp.s7);
607 #endif
608
609 #if VECT_SIZE == 16
610 const u64x tmp = ((((u64x) (a.s0, a.s1, a.s2, a.s3, a.s4, a.s5, a.s6, a.s7, a.s8, a.s9, a.sa, a.sb, a.sc, a.sd, a.se, a.sf)) << 32) | ((u64x) (b.s0, b.s1, b.s2, b.s3, b.s4, b.s5, b.s6, b.s7, b.s8, b.s9, b.sa, b.sb, b.sc, b.sd, b.se, b.sf))) >> ((c & 3) * 8);
611
612 return (u32x) (tmp.s0, tmp.s1, tmp.s2, tmp.s3, tmp.s4, tmp.s5, tmp.s6, tmp.s7, tmp.s8, tmp.s9, tmp.sa, tmp.sb, tmp.sc, tmp.sd, tmp.se, tmp.sf);
613 #endif
614 }
615 #endif
616
617 typedef struct
618 {
619 #if defined _DES_
620 u32 digest_buf[4];
621 #elif defined _MD4_
622 u32 digest_buf[4];
623 #elif defined _MD5_
624 u32 digest_buf[4];
625 #elif defined _MD5H_
626 u32 digest_buf[4];
627 #elif defined _SHA1_
628 u32 digest_buf[5];
629 #elif defined _BCRYPT_
630 u32 digest_buf[6];
631 #elif defined _SHA256_
632 u32 digest_buf[8];
633 #elif defined _SHA384_
634 u32 digest_buf[16];
635 #elif defined _SHA512_
636 u32 digest_buf[16];
637 #elif defined _KECCAK_
638 u32 digest_buf[50];
639 #elif defined _RIPEMD160_
640 u32 digest_buf[5];
641 #elif defined _WHIRLPOOL_
642 u32 digest_buf[16];
643 #elif defined _GOST_
644 u32 digest_buf[8];
645 #elif defined _GOST2012_256_
646 u32 digest_buf[8];
647 #elif defined _GOST2012_512_
648 u32 digest_buf[16];
649 #elif defined _SAPB_
650 u32 digest_buf[4];
651 #elif defined _SAPG_
652 u32 digest_buf[5];
653 #elif defined _MYSQL323_
654 u32 digest_buf[4];
655 #elif defined _LOTUS5_
656 u32 digest_buf[4];
657 #elif defined _LOTUS6_
658 u32 digest_buf[4];
659 #elif defined _SCRYPT_
660 u32 digest_buf[8];
661 #elif defined _LOTUS8_
662 u32 digest_buf[4];
663 #elif defined _OFFICE2007_
664 u32 digest_buf[4];
665 #elif defined _OFFICE2010_
666 u32 digest_buf[4];
667 #elif defined _OFFICE2013_
668 u32 digest_buf[4];
669 #elif defined _OLDOFFICE01_
670 u32 digest_buf[4];
671 #elif defined _OLDOFFICE34_
672 u32 digest_buf[4];
673 #elif defined _SIPHASH_
674 u32 digest_buf[4];
675 #elif defined _PBKDF2_MD5_
676 u32 digest_buf[32];
677 #elif defined _PBKDF2_SHA1_
678 u32 digest_buf[32];
679 #elif defined _PBKDF2_SHA256_
680 u32 digest_buf[32];
681 #elif defined _PBKDF2_SHA512_
682 u32 digest_buf[32];
683 #elif defined _PDF17L8_
684 u32 digest_buf[8];
685 #elif defined _CRC32_
686 u32 digest_buf[4];
687 #elif defined _SEVEN_ZIP_
688 u32 digest_buf[4];
689 #elif defined _ANDROIDFDE_
690 u32 digest_buf[4];
691 #elif defined _DCC2_
692 u32 digest_buf[4];
693 #elif defined _WPA_
694 u32 digest_buf[4];
695 #elif defined _MD5_SHA1_
696 u32 digest_buf[4];
697 #elif defined _SHA1_MD5_
698 u32 digest_buf[5];
699 #elif defined _NETNTLMV2_
700 u32 digest_buf[4];
701 #elif defined _KRB5PA_
702 u32 digest_buf[4];
703 #elif defined _CLOUDKEY_
704 u32 digest_buf[8];
705 #elif defined _SCRYPT_
706 u32 digest_buf[4];
707 #elif defined _PSAFE2_
708 u32 digest_buf[5];
709 #elif defined _LOTUS8_
710 u32 digest_buf[4];
711 #elif defined _RAR3_
712 u32 digest_buf[4];
713 #elif defined _SHA256_SHA1_
714 u32 digest_buf[8];
715 #elif defined _MS_DRSR_
716 u32 digest_buf[8];
717 #elif defined _ANDROIDFDE_SAMSUNG_
718 u32 digest_buf[8];
719 #elif defined _RAR5_
720 u32 digest_buf[4];
721 #elif defined _KRB5TGS_
722 u32 digest_buf[4];
723 #elif defined _AXCRYPT_
724 u32 digest_buf[4];
725 #elif defined _KEEPASS_
726 u32 digest_buf[4];
727 #endif
728
729 } digest_t;
730
731 typedef struct
732 {
733 u32 salt_buf[16];
734 u32 salt_buf_pc[8];
735
736 u32 salt_len;
737 u32 salt_iter;
738 u32 salt_sign[2];
739
740 u32 keccak_mdlen;
741 u32 truecrypt_mdlen;
742
743 u32 digests_cnt;
744 u32 digests_done;
745
746 u32 digests_offset;
747
748 u32 scrypt_N;
749 u32 scrypt_r;
750 u32 scrypt_p;
751 u32 scrypt_tmto;
752 u32 scrypt_phy;
753
754 } salt_t;
755
756 typedef struct
757 {
758 int V;
759 int R;
760 int P;
761
762 int enc_md;
763
764 u32 id_buf[8];
765 u32 u_buf[32];
766 u32 o_buf[32];
767
768 int id_len;
769 int o_len;
770 int u_len;
771
772 u32 rc4key[2];
773 u32 rc4data[2];
774
775 } pdf_t;
776
777 typedef struct
778 {
779 u32 pke[25];
780 u32 eapol[64];
781 int eapol_size;
782 int keyver;
783 u8 orig_mac1[6];
784 u8 orig_mac2[6];
785 u8 orig_nonce1[32];
786 u8 orig_nonce2[32];
787
788 } wpa_t;
789
790 typedef struct
791 {
792 u32 cry_master_buf[64];
793 u32 ckey_buf[64];
794 u32 public_key_buf[64];
795
796 u32 cry_master_len;
797 u32 ckey_len;
798 u32 public_key_len;
799
800 } bitcoin_wallet_t;
801
802 typedef struct
803 {
804 u32 salt_buf[30];
805 u32 salt_len;
806
807 u32 esalt_buf[38];
808 u32 esalt_len;
809
810 } sip_t;
811
812 typedef struct
813 {
814 u32 data[384];
815
816 } androidfde_t;
817
818 typedef struct
819 {
820 u32 nr_buf[16];
821 u32 nr_len;
822
823 u32 msg_buf[128];
824 u32 msg_len;
825
826 } ikepsk_t;
827
828 typedef struct
829 {
830 u32 user_len;
831 u32 domain_len;
832 u32 srvchall_len;
833 u32 clichall_len;
834
835 u32 userdomain_buf[64];
836 u32 chall_buf[256];
837
838 } netntlm_t;
839
840 typedef struct
841 {
842 u32 user[16];
843 u32 realm[16];
844 u32 salt[32];
845 u32 timestamp[16];
846 u32 checksum[4];
847
848 } krb5pa_t;
849
850 typedef struct
851 {
852 u32 account_info[512];
853 u32 checksum[4];
854 u32 edata2[2560];
855 u32 edata2_len;
856
857 } krb5tgs_t;
858
859 typedef struct
860 {
861 u32 salt_buf[16];
862 u32 data_buf[112];
863 u32 keyfile_buf[16];
864
865 } tc_t;
866
867 typedef struct
868 {
869 u32 salt_buf[16];
870
871 } pbkdf2_md5_t;
872
873 typedef struct
874 {
875 u32 salt_buf[16];
876
877 } pbkdf2_sha1_t;
878
879 typedef struct
880 {
881 u32 salt_buf[16];
882
883 } pbkdf2_sha256_t;
884
885 typedef struct
886 {
887 u32 salt_buf[32];
888
889 } pbkdf2_sha512_t;
890
891 typedef struct
892 {
893 u32 salt_buf[128];
894 u32 salt_len;
895
896 } rakp_t;
897
898 typedef struct
899 {
900 u32 data_len;
901 u32 data_buf[512];
902
903 } cloudkey_t;
904
905 typedef struct
906 {
907 u32 encryptedVerifier[4];
908 u32 encryptedVerifierHash[5];
909
910 u32 keySize;
911
912 } office2007_t;
913
914 typedef struct
915 {
916 u32 encryptedVerifier[4];
917 u32 encryptedVerifierHash[8];
918
919 } office2010_t;
920
921 typedef struct
922 {
923 u32 encryptedVerifier[4];
924 u32 encryptedVerifierHash[8];
925
926 } office2013_t;
927
928 typedef struct
929 {
930 u32 version;
931 u32 encryptedVerifier[4];
932 u32 encryptedVerifierHash[4];
933 u32 rc4key[2];
934
935 } oldoffice01_t;
936
937 typedef struct
938 {
939 u32 version;
940 u32 encryptedVerifier[4];
941 u32 encryptedVerifierHash[5];
942 u32 rc4key[2];
943
944 } oldoffice34_t;
945
946 typedef struct
947 {
948 u32 salt_buf[128];
949 u32 salt_len;
950
951 u32 pc_digest[5];
952 u32 pc_offset;
953
954 } pstoken_t;
955
956 typedef struct
957 {
958 u32 version;
959 u32 algorithm;
960
961 /* key-file handling */
962 u32 keyfile_len;
963 u32 keyfile[8];
964
965 u32 final_random_seed[8];
966 u32 transf_random_seed[8];
967 u32 enc_iv[4];
968 u32 contents_hash[8];
969
970 /* specific to version 1 */
971 u32 contents_len;
972 u32 contents[75000];
973
974 /* specific to version 2 */
975 u32 expected_bytes[8];
976
977 } keepass_t;
978
979 typedef struct
980 {
981 u32 digest[4];
982 u32 out[4];
983
984 } pdf14_tmp_t;
985
986 typedef struct
987 {
988 union
989 {
990 u32 dgst32[16];
991 u64 dgst64[8];
992 };
993
994 u32 dgst_len;
995 u32 W_len;
996
997 } pdf17l8_tmp_t;
998
999 typedef struct
1000 {
1001 u32 digest_buf[4];
1002
1003 } phpass_tmp_t;
1004
1005 typedef struct
1006 {
1007 u32 digest_buf[4];
1008
1009 } md5crypt_tmp_t;
1010
1011 typedef struct
1012 {
1013 u32 alt_result[8];
1014
1015 u32 p_bytes[4];
1016 u32 s_bytes[4];
1017
1018 } sha256crypt_tmp_t;
1019
1020 typedef struct
1021 {
1022 u64 l_alt_result[8];
1023
1024 u64 l_p_bytes[2];
1025 u64 l_s_bytes[2];
1026
1027 } sha512crypt_tmp_t;
1028
1029 typedef struct
1030 {
1031 u32 ipad[5];
1032 u32 opad[5];
1033
1034 u32 dgst[10];
1035 u32 out[10];
1036
1037 } wpa_tmp_t;
1038
1039 typedef struct
1040 {
1041 u64 dgst[8];
1042
1043 } bitcoin_wallet_tmp_t;
1044
1045 typedef struct
1046 {
1047 u32 ipad[5];
1048 u32 opad[5];
1049
1050 u32 dgst[5];
1051 u32 out[4];
1052
1053 } dcc2_tmp_t;
1054
1055 typedef struct
1056 {
1057 u32 E[18];
1058
1059 u32 P[18];
1060
1061 u32 S0[256];
1062 u32 S1[256];
1063 u32 S2[256];
1064 u32 S3[256];
1065
1066 } bcrypt_tmp_t;
1067
1068 typedef struct
1069 {
1070 u32 digest[2];
1071
1072 u32 P[18];
1073
1074 u32 S0[256];
1075 u32 S1[256];
1076 u32 S2[256];
1077 u32 S3[256];
1078
1079 } pwsafe2_tmp_t;
1080
1081 typedef struct
1082 {
1083 u32 digest_buf[8];
1084
1085 } pwsafe3_tmp_t;
1086
1087 typedef struct
1088 {
1089 u32 digest_buf[5];
1090
1091 } androidpin_tmp_t;
1092
1093 typedef struct
1094 {
1095 u32 ipad[5];
1096 u32 opad[5];
1097
1098 u32 dgst[10];
1099 u32 out[10];
1100
1101 } androidfde_tmp_t;
1102
1103 typedef struct
1104 {
1105 u32 ipad[16];
1106 u32 opad[16];
1107
1108 u32 dgst[64];
1109 u32 out[64];
1110
1111 } tc_tmp_t;
1112
1113 typedef struct
1114 {
1115 u64 ipad[8];
1116 u64 opad[8];
1117
1118 u64 dgst[32];
1119 u64 out[32];
1120
1121 } tc64_tmp_t;
1122
1123 typedef struct
1124 {
1125 u32 ipad[4];
1126 u32 opad[4];
1127
1128 u32 dgst[32];
1129 u32 out[32];
1130
1131 } pbkdf2_md5_tmp_t;
1132
1133 typedef struct
1134 {
1135 u32 ipad[5];
1136 u32 opad[5];
1137
1138 u32 dgst[32];
1139 u32 out[32];
1140
1141 } pbkdf2_sha1_tmp_t;
1142
1143 typedef struct
1144 {
1145 u32 ipad[8];
1146 u32 opad[8];
1147
1148 u32 dgst[32];
1149 u32 out[32];
1150
1151 } pbkdf2_sha256_tmp_t;
1152
1153 typedef struct
1154 {
1155 u64 ipad[8];
1156 u64 opad[8];
1157
1158 u64 dgst[16];
1159 u64 out[16];
1160
1161 } pbkdf2_sha512_tmp_t;
1162
1163 typedef struct
1164 {
1165 u64 out[8];
1166
1167 } ecryptfs_tmp_t;
1168
1169 typedef struct
1170 {
1171 u64 ipad[8];
1172 u64 opad[8];
1173
1174 u64 dgst[16];
1175 u64 out[16];
1176
1177 } oraclet_tmp_t;
1178
1179 typedef struct
1180 {
1181 u32 ipad[5];
1182 u32 opad[5];
1183
1184 u32 dgst[5];
1185 u32 out[5];
1186
1187 } agilekey_tmp_t;
1188
1189 typedef struct
1190 {
1191 u32 ipad[5];
1192 u32 opad[5];
1193
1194 u32 dgst1[5];
1195 u32 out1[5];
1196
1197 u32 dgst2[5];
1198 u32 out2[5];
1199
1200 } mywallet_tmp_t;
1201
1202 typedef struct
1203 {
1204 u32 ipad[5];
1205 u32 opad[5];
1206
1207 u32 dgst[5];
1208 u32 out[5];
1209
1210 } sha1aix_tmp_t;
1211
1212 typedef struct
1213 {
1214 u32 ipad[8];
1215 u32 opad[8];
1216
1217 u32 dgst[8];
1218 u32 out[8];
1219
1220 } sha256aix_tmp_t;
1221
1222 typedef struct
1223 {
1224 u64 ipad[8];
1225 u64 opad[8];
1226
1227 u64 dgst[8];
1228 u64 out[8];
1229
1230 } sha512aix_tmp_t;
1231
1232 typedef struct
1233 {
1234 u32 ipad[8];
1235 u32 opad[8];
1236
1237 u32 dgst[8];
1238 u32 out[8];
1239
1240 } lastpass_tmp_t;
1241
1242 typedef struct
1243 {
1244 u64 digest_buf[8];
1245
1246 } drupal7_tmp_t;
1247
1248 typedef struct
1249 {
1250 u32 ipad[5];
1251 u32 opad[5];
1252
1253 u32 dgst[5];
1254 u32 out[5];
1255
1256 } lotus8_tmp_t;
1257
1258 typedef struct
1259 {
1260 u32 out[5];
1261
1262 } office2007_tmp_t;
1263
1264 typedef struct
1265 {
1266 u32 out[5];
1267
1268 } office2010_tmp_t;
1269
1270 typedef struct
1271 {
1272 u64 out[8];
1273
1274 } office2013_tmp_t;
1275
1276 typedef struct
1277 {
1278 u32 digest_buf[5];
1279
1280 } saph_sha1_tmp_t;
1281
1282 typedef struct
1283 {
1284 u32 block[16];
1285
1286 u32 dgst[8];
1287
1288 u32 block_len;
1289 u32 final_len;
1290
1291 } seven_zip_tmp_t;
1292
1293 typedef struct
1294 {
1295 u32 KEK[5];
1296
1297 u32 lsb[4];
1298 u32 cipher[4];
1299
1300 } axcrypt_tmp_t;
1301
1302 typedef struct
1303 {
1304 u32 tmp_digest[8];
1305
1306 } keepass_tmp_t;
1307
1308 typedef struct
1309 {
1310 u32 Kc[16];
1311 u32 Kd[16];
1312
1313 u32 iv[2];
1314
1315 } bsdicrypt_tmp_t;
1316
1317 typedef struct
1318 {
1319 u32 dgst[17][5];
1320
1321 } rar3_tmp_t;
1322
1323 typedef struct
1324 {
1325 u32 user[16];
1326
1327 } cram_md5_t;
1328
1329 typedef struct
1330 {
1331 u32 iv_buf[4];
1332 u32 iv_len;
1333
1334 u32 salt_buf[4];
1335 u32 salt_len;
1336
1337 u32 crc;
1338
1339 u32 data_buf[96];
1340 u32 data_len;
1341
1342 u32 unpack_size;
1343
1344 } seven_zip_t;
1345
1346 typedef struct
1347 {
1348 u32 key;
1349 u64 val;
1350
1351 } hcstat_table_t;
1352
1353 typedef struct
1354 {
1355 u32 cs_buf[0x100];
1356 u32 cs_len;
1357
1358 } cs_t;
1359
1360 typedef struct
1361 {
1362 u32 cmds[0x100];
1363
1364 } kernel_rule_t;
1365
1366 typedef struct
1367 {
1368 u32 gidvid;
1369 u32 il_pos;
1370
1371 } plain_t;
1372
1373 typedef struct
1374 {
1375 u32 i[16];
1376
1377 u32 pw_len;
1378
1379 u32 alignment_placeholder_1;
1380 u32 alignment_placeholder_2;
1381 u32 alignment_placeholder_3;
1382
1383 } pw_t;
1384
1385 typedef struct
1386 {
1387 u32 i;
1388
1389 } bf_t;
1390
1391 typedef struct
1392 {
1393 u32 i[8];
1394
1395 u32 pw_len;
1396
1397 } comb_t;
1398
1399 typedef struct
1400 {
1401 u32 b[32];
1402
1403 } bs_word_t;
1404
1405 typedef struct
1406 {
1407 uint4 P[64];
1408
1409 } scrypt_tmp_t;