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