Fix WinZip multihash
[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 #elif defined _ZIP2_
668 u32 digest_buf[4];
669 #endif
670
671 } digest_t;
672
673 typedef struct
674 {
675 u32 salt_buf[16];
676 u32 salt_buf_pc[8];
677
678 u32 salt_len;
679 u32 salt_iter;
680 u32 salt_sign[2];
681
682 u32 keccak_mdlen;
683 u32 truecrypt_mdlen;
684
685 u32 digests_cnt;
686 u32 digests_done;
687
688 u32 digests_offset;
689
690 u32 scrypt_N;
691 u32 scrypt_r;
692 u32 scrypt_p;
693 u32 scrypt_tmto;
694 u32 scrypt_phy;
695
696 } salt_t;
697
698 typedef struct
699 {
700 int V;
701 int R;
702 int P;
703
704 int enc_md;
705
706 u32 id_buf[8];
707 u32 u_buf[32];
708 u32 o_buf[32];
709
710 int id_len;
711 int o_len;
712 int u_len;
713
714 u32 rc4key[2];
715 u32 rc4data[2];
716
717 } pdf_t;
718
719 typedef struct
720 {
721 u32 pke[25];
722 u32 eapol[64];
723 int eapol_size;
724 int keyver;
725 u8 orig_mac1[6];
726 u8 orig_mac2[6];
727 u8 orig_nonce1[32];
728 u8 orig_nonce2[32];
729
730 } wpa_t;
731
732 typedef struct
733 {
734 u32 cry_master_buf[64];
735 u32 ckey_buf[64];
736 u32 public_key_buf[64];
737
738 u32 cry_master_len;
739 u32 ckey_len;
740 u32 public_key_len;
741
742 } bitcoin_wallet_t;
743
744 typedef struct
745 {
746 u32 salt_buf[30];
747 u32 salt_len;
748
749 u32 esalt_buf[38];
750 u32 esalt_len;
751
752 } sip_t;
753
754 typedef struct
755 {
756 u32 data[384];
757
758 } androidfde_t;
759
760 typedef struct
761 {
762 u32 nr_buf[16];
763 u32 nr_len;
764
765 u32 msg_buf[128];
766 u32 msg_len;
767
768 } ikepsk_t;
769
770 typedef struct
771 {
772 u32 user_len;
773 u32 domain_len;
774 u32 srvchall_len;
775 u32 clichall_len;
776
777 u32 userdomain_buf[64];
778 u32 chall_buf[256];
779
780 } netntlm_t;
781
782 typedef struct
783 {
784 u32 user[16];
785 u32 realm[16];
786 u32 salt[32];
787 u32 timestamp[16];
788 u32 checksum[4];
789
790 } krb5pa_t;
791
792 typedef struct
793 {
794 u32 account_info[512];
795 u32 checksum[4];
796 u32 edata2[2560];
797 u32 edata2_len;
798
799 } krb5tgs_t;
800
801 typedef struct
802 {
803 u32 salt_buf[16];
804 u32 data_buf[112];
805 u32 keyfile_buf[16];
806
807 } tc_t;
808
809 typedef struct
810 {
811 u32 salt_buf[16];
812
813 } pbkdf2_md5_t;
814
815 typedef struct
816 {
817 u32 salt_buf[16];
818
819 } pbkdf2_sha1_t;
820
821 typedef struct
822 {
823 u32 salt_buf[16];
824
825 } pbkdf2_sha256_t;
826
827 typedef struct
828 {
829 u32 salt_buf[32];
830
831 } pbkdf2_sha512_t;
832
833 typedef struct
834 {
835 u32 salt_buf[128];
836 u32 salt_len;
837
838 } rakp_t;
839
840 typedef struct
841 {
842 u32 data_len;
843 u32 data_buf[512];
844
845 } cloudkey_t;
846
847 typedef struct
848 {
849 u32 encryptedVerifier[4];
850 u32 encryptedVerifierHash[5];
851
852 u32 keySize;
853
854 } office2007_t;
855
856 typedef struct
857 {
858 u32 encryptedVerifier[4];
859 u32 encryptedVerifierHash[8];
860
861 } office2010_t;
862
863 typedef struct
864 {
865 u32 encryptedVerifier[4];
866 u32 encryptedVerifierHash[8];
867
868 } office2013_t;
869
870 typedef struct
871 {
872 u32 version;
873 u32 encryptedVerifier[4];
874 u32 encryptedVerifierHash[4];
875 u32 rc4key[2];
876
877 } oldoffice01_t;
878
879 typedef struct
880 {
881 u32 version;
882 u32 encryptedVerifier[4];
883 u32 encryptedVerifierHash[5];
884 u32 rc4key[2];
885
886 } oldoffice34_t;
887
888 typedef struct
889 {
890 u32 salt_buf[128];
891 u32 salt_len;
892
893 u32 pc_digest[5];
894 u32 pc_offset;
895
896 } pstoken_t;
897
898 typedef struct
899 {
900 u32 type;
901 u32 mode;
902 u32 magic;
903 u32 salt_len;
904 u32 salt_buf[4];
905 u32 verify_bytes;
906 u32 compress_length;
907 u32 data_len;
908 u32 data_buf[2048];
909 u32 auth_len;
910 u32 auth_buf[4];
911
912 } zip2_t;
913
914 typedef struct
915 {
916 u32 version;
917 u32 algorithm;
918
919 /* key-file handling */
920 u32 keyfile_len;
921 u32 keyfile[8];
922
923 u32 final_random_seed[8];
924 u32 transf_random_seed[8];
925 u32 enc_iv[4];
926 u32 contents_hash[8];
927
928 /* specific to version 1 */
929 u32 contents_len;
930 u32 contents[75000];
931
932 /* specific to version 2 */
933 u32 expected_bytes[8];
934
935 } keepass_t;
936
937 typedef struct
938 {
939 u32 digest[4];
940 u32 out[4];
941
942 } pdf14_tmp_t;
943
944 typedef struct
945 {
946 union
947 {
948 u32 dgst32[16];
949 u64 dgst64[8];
950 };
951
952 u32 dgst_len;
953 u32 W_len;
954
955 } pdf17l8_tmp_t;
956
957 typedef struct
958 {
959 u32 digest_buf[4];
960
961 } phpass_tmp_t;
962
963 typedef struct
964 {
965 u32 digest_buf[4];
966
967 } md5crypt_tmp_t;
968
969 typedef struct
970 {
971 u32 alt_result[8];
972
973 u32 p_bytes[4];
974 u32 s_bytes[4];
975
976 } sha256crypt_tmp_t;
977
978 typedef struct
979 {
980 u64 l_alt_result[8];
981
982 u64 l_p_bytes[2];
983 u64 l_s_bytes[2];
984
985 } sha512crypt_tmp_t;
986
987 typedef struct
988 {
989 u32 ipad[5];
990 u32 opad[5];
991
992 u32 dgst[10];
993 u32 out[10];
994
995 } wpa_tmp_t;
996
997 typedef struct
998 {
999 u64 dgst[8];
1000
1001 } bitcoin_wallet_tmp_t;
1002
1003 typedef struct
1004 {
1005 u32 ipad[5];
1006 u32 opad[5];
1007
1008 u32 dgst[5];
1009 u32 out[4];
1010
1011 } dcc2_tmp_t;
1012
1013 typedef struct
1014 {
1015 u32 E[18];
1016
1017 u32 P[18];
1018
1019 u32 S0[256];
1020 u32 S1[256];
1021 u32 S2[256];
1022 u32 S3[256];
1023
1024 } bcrypt_tmp_t;
1025
1026 typedef struct
1027 {
1028 u32 digest[2];
1029
1030 u32 P[18];
1031
1032 u32 S0[256];
1033 u32 S1[256];
1034 u32 S2[256];
1035 u32 S3[256];
1036
1037 } pwsafe2_tmp_t;
1038
1039 typedef struct
1040 {
1041 u32 digest_buf[8];
1042
1043 } pwsafe3_tmp_t;
1044
1045 typedef struct
1046 {
1047 u32 digest_buf[5];
1048
1049 } androidpin_tmp_t;
1050
1051 typedef struct
1052 {
1053 u32 ipad[5];
1054 u32 opad[5];
1055
1056 u32 dgst[10];
1057 u32 out[10];
1058
1059 } androidfde_tmp_t;
1060
1061 typedef struct
1062 {
1063 u32 ipad[16];
1064 u32 opad[16];
1065
1066 u32 dgst[64];
1067 u32 out[64];
1068
1069 } tc_tmp_t;
1070
1071 typedef struct
1072 {
1073 u64 ipad[8];
1074 u64 opad[8];
1075
1076 u64 dgst[32];
1077 u64 out[32];
1078
1079 } tc64_tmp_t;
1080
1081 typedef struct
1082 {
1083 u32 ipad[4];
1084 u32 opad[4];
1085
1086 u32 dgst[32];
1087 u32 out[32];
1088
1089 } pbkdf2_md5_tmp_t;
1090
1091 typedef struct
1092 {
1093 u32 ipad[5];
1094 u32 opad[5];
1095
1096 u32 dgst[32];
1097 u32 out[32];
1098
1099 } pbkdf2_sha1_tmp_t;
1100
1101 typedef struct
1102 {
1103 u32 ipad[8];
1104 u32 opad[8];
1105
1106 u32 dgst[32];
1107 u32 out[32];
1108
1109 } pbkdf2_sha256_tmp_t;
1110
1111 typedef struct
1112 {
1113 u64 ipad[8];
1114 u64 opad[8];
1115
1116 u64 dgst[16];
1117 u64 out[16];
1118
1119 } pbkdf2_sha512_tmp_t;
1120
1121 typedef struct
1122 {
1123 u64 out[8];
1124
1125 } ecryptfs_tmp_t;
1126
1127 typedef struct
1128 {
1129 u64 ipad[8];
1130 u64 opad[8];
1131
1132 u64 dgst[16];
1133 u64 out[16];
1134
1135 } oraclet_tmp_t;
1136
1137 typedef struct
1138 {
1139 u32 ipad[5];
1140 u32 opad[5];
1141
1142 u32 dgst[5];
1143 u32 out[5];
1144
1145 } agilekey_tmp_t;
1146
1147 typedef struct
1148 {
1149 u32 ipad[5];
1150 u32 opad[5];
1151
1152 u32 dgst1[5];
1153 u32 out1[5];
1154
1155 u32 dgst2[5];
1156 u32 out2[5];
1157
1158 } mywallet_tmp_t;
1159
1160 typedef struct
1161 {
1162 u32 ipad[5];
1163 u32 opad[5];
1164
1165 u32 dgst[5];
1166 u32 out[5];
1167
1168 } sha1aix_tmp_t;
1169
1170 typedef struct
1171 {
1172 u32 ipad[8];
1173 u32 opad[8];
1174
1175 u32 dgst[8];
1176 u32 out[8];
1177
1178 } sha256aix_tmp_t;
1179
1180 typedef struct
1181 {
1182 u64 ipad[8];
1183 u64 opad[8];
1184
1185 u64 dgst[8];
1186 u64 out[8];
1187
1188 } sha512aix_tmp_t;
1189
1190 typedef struct
1191 {
1192 u32 ipad[8];
1193 u32 opad[8];
1194
1195 u32 dgst[8];
1196 u32 out[8];
1197
1198 } lastpass_tmp_t;
1199
1200 typedef struct
1201 {
1202 u64 digest_buf[8];
1203
1204 } drupal7_tmp_t;
1205
1206 typedef struct
1207 {
1208 u32 ipad[5];
1209 u32 opad[5];
1210
1211 u32 dgst[5];
1212 u32 out[5];
1213
1214 } lotus8_tmp_t;
1215
1216 typedef struct
1217 {
1218 u32 out[5];
1219
1220 } office2007_tmp_t;
1221
1222 typedef struct
1223 {
1224 u32 out[5];
1225
1226 } office2010_tmp_t;
1227
1228 typedef struct
1229 {
1230 u64 out[8];
1231
1232 } office2013_tmp_t;
1233
1234 typedef struct
1235 {
1236 u32 digest_buf[5];
1237
1238 } saph_sha1_tmp_t;
1239
1240 typedef struct
1241 {
1242 u32 block[16];
1243
1244 u32 dgst[8];
1245
1246 u32 block_len;
1247 u32 final_len;
1248
1249 } seven_zip_tmp_t;
1250
1251 typedef struct
1252 {
1253 u32 KEK[5];
1254
1255 u32 lsb[4];
1256 u32 cipher[4];
1257
1258 } axcrypt_tmp_t;
1259
1260 typedef struct
1261 {
1262 u32 tmp_digest[8];
1263
1264 } keepass_tmp_t;
1265
1266 typedef struct
1267 {
1268 u32 Kc[16];
1269 u32 Kd[16];
1270
1271 u32 iv[2];
1272
1273 } bsdicrypt_tmp_t;
1274
1275 typedef struct
1276 {
1277 u32 dgst[17][5];
1278
1279 } rar3_tmp_t;
1280
1281 typedef struct
1282 {
1283 u32 user[16];
1284
1285 } cram_md5_t;
1286
1287 typedef struct
1288 {
1289 u32 iv_buf[4];
1290 u32 iv_len;
1291
1292 u32 salt_buf[4];
1293 u32 salt_len;
1294
1295 u32 crc;
1296
1297 u32 data_buf[96];
1298 u32 data_len;
1299
1300 u32 unpack_size;
1301
1302 } seven_zip_t;
1303
1304 typedef struct
1305 {
1306 u32 key;
1307 u64 val;
1308
1309 } hcstat_table_t;
1310
1311 typedef struct
1312 {
1313 u32 cs_buf[0x100];
1314 u32 cs_len;
1315
1316 } cs_t;
1317
1318 typedef struct
1319 {
1320 u32 cmds[0x100];
1321
1322 } kernel_rule_t;
1323
1324 typedef struct
1325 {
1326 u32 gidvid;
1327 u32 il_pos;
1328
1329 } plain_t;
1330
1331 typedef struct
1332 {
1333 u32 i[16];
1334
1335 u32 pw_len;
1336
1337 u32 alignment_placeholder_1;
1338 u32 alignment_placeholder_2;
1339 u32 alignment_placeholder_3;
1340
1341 } pw_t;
1342
1343 typedef struct
1344 {
1345 u32 i;
1346
1347 } bf_t;
1348
1349 typedef struct
1350 {
1351 u32 i[8];
1352
1353 u32 pw_len;
1354
1355 } comb_t;
1356
1357 typedef struct
1358 {
1359 u32 b[32];
1360
1361 } bs_word_t;
1362
1363 typedef struct
1364 {
1365 uint4 P[64];
1366
1367 } scrypt_tmp_t;