fe7bb1c6ebc9982d426c1ee34885f2586e822786
[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 ("\n"
363 "shl.b32 %4, %2, %6;\n"
364 "shl.b32 %5, %3, %6;\n"
365 "shr.b32 %0, %2, %7;\n"
366 "shr.b32 %1, %3, %7;\n"
367 "add.u32 %0, %0, %4;\n"
368 "add.u32 %1, %1, %5;\n"
369 : "=r"(r.s0),
370 "=r"(r.s1)
371 : "r"(a.s0),
372 "r"(a.s1),
373 "r"(t.s0),
374 "r"(t.s1),
375 "r"(32 - n),
376 "r"(n));
377
378 #elif VECT_SIZE == 4
379
380 asm ("\n"
381 "shl.b32 %8, %4, %12;\n"
382 "shl.b32 %9, %5, %12;\n"
383 "shl.b32 %10, %6, %12;\n"
384 "shl.b32 %11, %7, %12;\n"
385 "shr.b32 %0, %4, %13;\n"
386 "shr.b32 %1, %5, %13;\n"
387 "shr.b32 %2, %6, %13;\n"
388 "shr.b32 %3, %7, %13;\n"
389 "add.u32 %0, %0, %8;\n"
390 "add.u32 %1, %1, %9;\n"
391 "add.u32 %2, %2, %10;\n"
392 "add.u32 %3, %3, %11;\n"
393 : "=r"(r.s0),
394 "=r"(r.s1),
395 "=r"(r.s2),
396 "=r"(r.s3)
397 : "r"(a.s0),
398 "r"(a.s1),
399 "r"(a.s2),
400 "r"(a.s3),
401 "r"(t.s0),
402 "r"(t.s1),
403 "r"(t.s2),
404 "r"(t.s3),
405 "r"(32 - n),
406 "r"(n));
407
408 #else
409
410 r = rotate (a, n);
411
412 #endif
413
414 return r;
415
416 #else
417
418 return rotate (a, n);
419
420 #endif
421 }
422
423 inline u32x rotl32 (const u32x a, const u32 n)
424 {
425 return rotr32 (a, 32 - n);
426 }
427
428 inline u64x rotr64 (const u64x a, const u32 n)
429 {
430 return rotate (a, (u64) 64 - n);
431 }
432
433 inline u64x rotl64 (const u64x a, const u32 n)
434 {
435 return rotate (a, (u64) n);
436 }
437
438 inline u32x __byte_perm (const u32x a, const u32x b, const u32x c)
439 {
440 u32x r;
441
442 #if VECT_SIZE == 1
443 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(c) );
444 #endif
445
446 #if VECT_SIZE >= 2
447 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s0) : "r"(a.s0), "r"(b.s0), "r"(c.s0));
448 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s1) : "r"(a.s1), "r"(b.s1), "r"(c.s1));
449 #endif
450
451 #if VECT_SIZE >= 4
452 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s2) : "r"(a.s2), "r"(b.s2), "r"(c.s2));
453 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s3) : "r"(a.s3), "r"(b.s3), "r"(c.s3));
454 #endif
455
456 #if VECT_SIZE >= 8
457 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s4) : "r"(a.s4), "r"(b.s4), "r"(c.s4));
458 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s5) : "r"(a.s5), "r"(b.s5), "r"(c.s5));
459 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s6) : "r"(a.s6), "r"(b.s6), "r"(c.s6));
460 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s7) : "r"(a.s7), "r"(b.s7), "r"(c.s7));
461 #endif
462
463 #if VECT_SIZE >= 16
464 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s8) : "r"(a.s8), "r"(b.s8), "r"(c.s8));
465 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.s9) : "r"(a.s9), "r"(b.s9), "r"(c.s9));
466 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sa) : "r"(a.sa), "r"(b.sa), "r"(c.sa));
467 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sb) : "r"(a.sb), "r"(b.sb), "r"(c.sb));
468 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sc) : "r"(a.sc), "r"(b.sc), "r"(c.sc));
469 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sd) : "r"(a.sd), "r"(b.sd), "r"(c.sd));
470 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.se) : "r"(a.se), "r"(b.se), "r"(c.se));
471 asm ("prmt.b32 %0, %1, %2, %3;" : "=r"(r.sf) : "r"(a.sf), "r"(b.sf), "r"(c.sf));
472 #endif
473
474 return r;
475 }
476
477 inline u32 __bfe (const u32 a, const u32 b, const u32 c)
478 {
479 u32 r;
480
481 asm ("bfe.u32 %0, %1, %2, %3;" : "=r"(r) : "r"(a), "r"(b), "r"(c));
482
483 return r;
484 }
485
486 #if CUDA_ARCH >= 350
487 inline u32 amd_bytealign (const u32 a, const u32 b, const u32 c)
488 {
489 u32 r;
490
491 asm ("shf.r.wrap.b32 %0, %1, %2, %3;" : "=r"(r) : "r"(b), "r"(a), "r"((c & 3) * 8));
492
493 return r;
494 }
495 #else
496 inline u32 amd_bytealign (const u32 a, const u32 b, const u32 c)
497 {
498 return __byte_perm_S (b, a, (0x76543210 >> ((c & 3) * 4)) & 0xffff);
499 }
500 #endif
501
502 #endif
503
504 #ifdef IS_GENERIC
505 inline u32 swap32_S (const u32 v)
506 {
507 return (as_uint (as_uchar4 (v).s3210));
508 }
509
510 inline u64 swap64_S (const u64 v)
511 {
512 return (as_ulong (as_uchar8 (v).s76543210));
513 }
514
515 inline u32 rotr32_S (const u32 a, const u32 n)
516 {
517 return rotate (a, 32 - n);
518 }
519
520 inline u32 rotl32_S (const u32 a, const u32 n)
521 {
522 return rotate (a, n);
523 }
524
525 inline u64 rotr64_S (const u64 a, const u32 n)
526 {
527 return rotate (a, (u64) 64 - n);
528 }
529
530 inline u64 rotl64_S (const u64 a, const u32 n)
531 {
532 return rotate (a, (u64) n);
533 }
534
535 inline u32 amd_bytealign_S (const u32 a, const u32 b, const u32 c)
536 {
537 const u64 tmp = ((((u64) a) << 32) | ((u64) b)) >> ((c & 3) * 8);
538
539 return (u32) (tmp);
540 }
541
542 inline u32x swap32 (const u32x v)
543 {
544 return ((v >> 24) & 0x000000ff)
545 | ((v >> 8) & 0x0000ff00)
546 | ((v << 8) & 0x00ff0000)
547 | ((v << 24) & 0xff000000);
548 }
549
550 inline u64x swap64 (const u64x v)
551 {
552 return ((v >> 56) & 0x00000000000000ff)
553 | ((v >> 40) & 0x000000000000ff00)
554 | ((v >> 24) & 0x0000000000ff0000)
555 | ((v >> 8) & 0x00000000ff000000)
556 | ((v << 8) & 0x000000ff00000000)
557 | ((v << 24) & 0x0000ff0000000000)
558 | ((v << 40) & 0x00ff000000000000)
559 | ((v << 56) & 0xff00000000000000);
560 }
561
562 inline u32x rotr32 (const u32x a, const u32 n)
563 {
564 return rotate (a, 32 - n);
565 }
566
567 inline u32x rotl32 (const u32x a, const u32 n)
568 {
569 return rotate (a, n);
570 }
571
572 inline u64x rotr64 (const u64x a, const u32 n)
573 {
574 return rotate (a, (u64) 64 - n);
575 }
576
577 inline u64x rotl64 (const u64x a, const u32 n)
578 {
579 return rotate (a, (u64) n);
580 }
581
582 inline u32 __bfe (const u32 a, const u32 b, const u32 c)
583 {
584 #define BIT(x) (1 << (x))
585 #define BIT_MASK(x) (BIT (x) - 1)
586 #define BFE(x,y,z) (((x) >> (y)) & BIT_MASK (z))
587
588 return BFE (a, b, c);
589 }
590
591 inline u32x amd_bytealign (const u32x a, const u32x b, const u32 c)
592 {
593 #if VECT_SIZE == 1
594 const u64x tmp = ((((u64x) (a)) << 32) | ((u64x) (b))) >> ((c & 3) * 8);
595
596 return (u32x) (tmp);
597 #endif
598
599 #if VECT_SIZE == 2
600 const u64x tmp = ((((u64x) (a.s0, a.s1)) << 32) | ((u64x) (b.s0, b.s1))) >> ((c & 3) * 8);
601
602 return (u32x) (tmp.s0, tmp.s1);
603 #endif
604
605 #if VECT_SIZE == 4
606 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);
607
608 return (u32x) (tmp.s0, tmp.s1, tmp.s2, tmp.s3);
609 #endif
610
611 #if VECT_SIZE == 8
612 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);
613
614 return (u32x) (tmp.s0, tmp.s1, tmp.s2, tmp.s3, tmp.s4, tmp.s5, tmp.s6, tmp.s7);
615 #endif
616
617 #if VECT_SIZE == 16
618 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);
619
620 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);
621 #endif
622 }
623 #endif
624
625 typedef struct
626 {
627 #if defined _DES_
628 u32 digest_buf[4];
629 #elif defined _MD4_
630 u32 digest_buf[4];
631 #elif defined _MD5_
632 u32 digest_buf[4];
633 #elif defined _MD5H_
634 u32 digest_buf[4];
635 #elif defined _SHA1_
636 u32 digest_buf[5];
637 #elif defined _BCRYPT_
638 u32 digest_buf[6];
639 #elif defined _SHA256_
640 u32 digest_buf[8];
641 #elif defined _SHA384_
642 u32 digest_buf[16];
643 #elif defined _SHA512_
644 u32 digest_buf[16];
645 #elif defined _KECCAK_
646 u32 digest_buf[50];
647 #elif defined _RIPEMD160_
648 u32 digest_buf[5];
649 #elif defined _WHIRLPOOL_
650 u32 digest_buf[16];
651 #elif defined _GOST_
652 u32 digest_buf[8];
653 #elif defined _GOST2012_256_
654 u32 digest_buf[8];
655 #elif defined _GOST2012_512_
656 u32 digest_buf[16];
657 #elif defined _SAPB_
658 u32 digest_buf[4];
659 #elif defined _SAPG_
660 u32 digest_buf[5];
661 #elif defined _MYSQL323_
662 u32 digest_buf[4];
663 #elif defined _LOTUS5_
664 u32 digest_buf[4];
665 #elif defined _LOTUS6_
666 u32 digest_buf[4];
667 #elif defined _SCRYPT_
668 u32 digest_buf[8];
669 #elif defined _LOTUS8_
670 u32 digest_buf[4];
671 #elif defined _OFFICE2007_
672 u32 digest_buf[4];
673 #elif defined _OFFICE2010_
674 u32 digest_buf[4];
675 #elif defined _OFFICE2013_
676 u32 digest_buf[4];
677 #elif defined _OLDOFFICE01_
678 u32 digest_buf[4];
679 #elif defined _OLDOFFICE34_
680 u32 digest_buf[4];
681 #elif defined _SIPHASH_
682 u32 digest_buf[4];
683 #elif defined _PBKDF2_MD5_
684 u32 digest_buf[32];
685 #elif defined _PBKDF2_SHA1_
686 u32 digest_buf[32];
687 #elif defined _PBKDF2_SHA256_
688 u32 digest_buf[32];
689 #elif defined _PBKDF2_SHA512_
690 u32 digest_buf[32];
691 #elif defined _PDF17L8_
692 u32 digest_buf[8];
693 #elif defined _CRC32_
694 u32 digest_buf[4];
695 #elif defined _SEVEN_ZIP_
696 u32 digest_buf[4];
697 #elif defined _ANDROIDFDE_
698 u32 digest_buf[4];
699 #elif defined _DCC2_
700 u32 digest_buf[4];
701 #elif defined _WPA_
702 u32 digest_buf[4];
703 #elif defined _MD5_SHA1_
704 u32 digest_buf[4];
705 #elif defined _SHA1_MD5_
706 u32 digest_buf[5];
707 #elif defined _NETNTLMV2_
708 u32 digest_buf[4];
709 #elif defined _KRB5PA_
710 u32 digest_buf[4];
711 #elif defined _CLOUDKEY_
712 u32 digest_buf[8];
713 #elif defined _SCRYPT_
714 u32 digest_buf[4];
715 #elif defined _PSAFE2_
716 u32 digest_buf[5];
717 #elif defined _LOTUS8_
718 u32 digest_buf[4];
719 #elif defined _RAR3_
720 u32 digest_buf[4];
721 #elif defined _SHA256_SHA1_
722 u32 digest_buf[8];
723 #elif defined _MS_DRSR_
724 u32 digest_buf[8];
725 #elif defined _ANDROIDFDE_SAMSUNG_
726 u32 digest_buf[8];
727 #elif defined _RAR5_
728 u32 digest_buf[4];
729 #elif defined _KRB5TGS_
730 u32 digest_buf[4];
731 #elif defined _AXCRYPT_
732 u32 digest_buf[4];
733 #elif defined _KEEPASS_
734 u32 digest_buf[4];
735 #endif
736
737 } digest_t;
738
739 typedef struct
740 {
741 u32 salt_buf[16];
742 u32 salt_buf_pc[8];
743
744 u32 salt_len;
745 u32 salt_iter;
746 u32 salt_sign[2];
747
748 u32 keccak_mdlen;
749 u32 truecrypt_mdlen;
750
751 u32 digests_cnt;
752 u32 digests_done;
753
754 u32 digests_offset;
755
756 u32 scrypt_N;
757 u32 scrypt_r;
758 u32 scrypt_p;
759 u32 scrypt_tmto;
760 u32 scrypt_phy;
761
762 } salt_t;
763
764 typedef struct
765 {
766 int V;
767 int R;
768 int P;
769
770 int enc_md;
771
772 u32 id_buf[8];
773 u32 u_buf[32];
774 u32 o_buf[32];
775
776 int id_len;
777 int o_len;
778 int u_len;
779
780 u32 rc4key[2];
781 u32 rc4data[2];
782
783 } pdf_t;
784
785 typedef struct
786 {
787 u32 pke[25];
788 u32 eapol[64];
789 int eapol_size;
790 int keyver;
791 u8 orig_mac1[6];
792 u8 orig_mac2[6];
793 u8 orig_nonce1[32];
794 u8 orig_nonce2[32];
795
796 } wpa_t;
797
798 typedef struct
799 {
800 u32 cry_master_buf[64];
801 u32 ckey_buf[64];
802 u32 public_key_buf[64];
803
804 u32 cry_master_len;
805 u32 ckey_len;
806 u32 public_key_len;
807
808 } bitcoin_wallet_t;
809
810 typedef struct
811 {
812 u32 salt_buf[30];
813 u32 salt_len;
814
815 u32 esalt_buf[38];
816 u32 esalt_len;
817
818 } sip_t;
819
820 typedef struct
821 {
822 u32 data[384];
823
824 } androidfde_t;
825
826 typedef struct
827 {
828 u32 nr_buf[16];
829 u32 nr_len;
830
831 u32 msg_buf[128];
832 u32 msg_len;
833
834 } ikepsk_t;
835
836 typedef struct
837 {
838 u32 user_len;
839 u32 domain_len;
840 u32 srvchall_len;
841 u32 clichall_len;
842
843 u32 userdomain_buf[64];
844 u32 chall_buf[256];
845
846 } netntlm_t;
847
848 typedef struct
849 {
850 u32 user[16];
851 u32 realm[16];
852 u32 salt[32];
853 u32 timestamp[16];
854 u32 checksum[4];
855
856 } krb5pa_t;
857
858 typedef struct
859 {
860 u32 account_info[512];
861 u32 checksum[4];
862 u32 edata2[2560];
863 u32 edata2_len;
864
865 } krb5tgs_t;
866
867 typedef struct
868 {
869 u32 salt_buf[16];
870 u32 data_buf[112];
871 u32 keyfile_buf[16];
872
873 } tc_t;
874
875 typedef struct
876 {
877 u32 salt_buf[16];
878
879 } pbkdf2_md5_t;
880
881 typedef struct
882 {
883 u32 salt_buf[16];
884
885 } pbkdf2_sha1_t;
886
887 typedef struct
888 {
889 u32 salt_buf[16];
890
891 } pbkdf2_sha256_t;
892
893 typedef struct
894 {
895 u32 salt_buf[32];
896
897 } pbkdf2_sha512_t;
898
899 typedef struct
900 {
901 u32 salt_buf[128];
902 u32 salt_len;
903
904 } rakp_t;
905
906 typedef struct
907 {
908 u32 data_len;
909 u32 data_buf[512];
910
911 } cloudkey_t;
912
913 typedef struct
914 {
915 u32 encryptedVerifier[4];
916 u32 encryptedVerifierHash[5];
917
918 u32 keySize;
919
920 } office2007_t;
921
922 typedef struct
923 {
924 u32 encryptedVerifier[4];
925 u32 encryptedVerifierHash[8];
926
927 } office2010_t;
928
929 typedef struct
930 {
931 u32 encryptedVerifier[4];
932 u32 encryptedVerifierHash[8];
933
934 } office2013_t;
935
936 typedef struct
937 {
938 u32 version;
939 u32 encryptedVerifier[4];
940 u32 encryptedVerifierHash[4];
941 u32 rc4key[2];
942
943 } oldoffice01_t;
944
945 typedef struct
946 {
947 u32 version;
948 u32 encryptedVerifier[4];
949 u32 encryptedVerifierHash[5];
950 u32 rc4key[2];
951
952 } oldoffice34_t;
953
954 typedef struct
955 {
956 u32 salt_buf[128];
957 u32 salt_len;
958
959 u32 pc_digest[5];
960 u32 pc_offset;
961
962 } pstoken_t;
963
964 typedef struct
965 {
966 u32 version;
967 u32 algorithm;
968
969 /* key-file handling */
970 u32 keyfile_len;
971 u32 keyfile[8];
972
973 u32 final_random_seed[8];
974 u32 transf_random_seed[8];
975 u32 enc_iv[4];
976 u32 contents_hash[8];
977
978 /* specific to version 1 */
979 u32 contents_len;
980 u32 contents[75000];
981
982 /* specific to version 2 */
983 u32 expected_bytes[8];
984
985 } keepass_t;
986
987 typedef struct
988 {
989 u32 digest[4];
990 u32 out[4];
991
992 } pdf14_tmp_t;
993
994 typedef struct
995 {
996 union
997 {
998 u32 dgst32[16];
999 u64 dgst64[8];
1000 };
1001
1002 u32 dgst_len;
1003 u32 W_len;
1004
1005 } pdf17l8_tmp_t;
1006
1007 typedef struct
1008 {
1009 u32 digest_buf[4];
1010
1011 } phpass_tmp_t;
1012
1013 typedef struct
1014 {
1015 u32 digest_buf[4];
1016
1017 } md5crypt_tmp_t;
1018
1019 typedef struct
1020 {
1021 u32 alt_result[8];
1022
1023 u32 p_bytes[4];
1024 u32 s_bytes[4];
1025
1026 } sha256crypt_tmp_t;
1027
1028 typedef struct
1029 {
1030 u64 l_alt_result[8];
1031
1032 u64 l_p_bytes[2];
1033 u64 l_s_bytes[2];
1034
1035 } sha512crypt_tmp_t;
1036
1037 typedef struct
1038 {
1039 u32 ipad[5];
1040 u32 opad[5];
1041
1042 u32 dgst[10];
1043 u32 out[10];
1044
1045 } wpa_tmp_t;
1046
1047 typedef struct
1048 {
1049 u64 dgst[8];
1050
1051 } bitcoin_wallet_tmp_t;
1052
1053 typedef struct
1054 {
1055 u32 ipad[5];
1056 u32 opad[5];
1057
1058 u32 dgst[5];
1059 u32 out[4];
1060
1061 } dcc2_tmp_t;
1062
1063 typedef struct
1064 {
1065 u32 E[18];
1066
1067 u32 P[18];
1068
1069 u32 S0[256];
1070 u32 S1[256];
1071 u32 S2[256];
1072 u32 S3[256];
1073
1074 } bcrypt_tmp_t;
1075
1076 typedef struct
1077 {
1078 u32 digest[2];
1079
1080 u32 P[18];
1081
1082 u32 S0[256];
1083 u32 S1[256];
1084 u32 S2[256];
1085 u32 S3[256];
1086
1087 } pwsafe2_tmp_t;
1088
1089 typedef struct
1090 {
1091 u32 digest_buf[8];
1092
1093 } pwsafe3_tmp_t;
1094
1095 typedef struct
1096 {
1097 u32 digest_buf[5];
1098
1099 } androidpin_tmp_t;
1100
1101 typedef struct
1102 {
1103 u32 ipad[5];
1104 u32 opad[5];
1105
1106 u32 dgst[10];
1107 u32 out[10];
1108
1109 } androidfde_tmp_t;
1110
1111 typedef struct
1112 {
1113 u32 ipad[16];
1114 u32 opad[16];
1115
1116 u32 dgst[64];
1117 u32 out[64];
1118
1119 } tc_tmp_t;
1120
1121 typedef struct
1122 {
1123 u64 ipad[8];
1124 u64 opad[8];
1125
1126 u64 dgst[32];
1127 u64 out[32];
1128
1129 } tc64_tmp_t;
1130
1131 typedef struct
1132 {
1133 u32 ipad[4];
1134 u32 opad[4];
1135
1136 u32 dgst[32];
1137 u32 out[32];
1138
1139 } pbkdf2_md5_tmp_t;
1140
1141 typedef struct
1142 {
1143 u32 ipad[5];
1144 u32 opad[5];
1145
1146 u32 dgst[32];
1147 u32 out[32];
1148
1149 } pbkdf2_sha1_tmp_t;
1150
1151 typedef struct
1152 {
1153 u32 ipad[8];
1154 u32 opad[8];
1155
1156 u32 dgst[32];
1157 u32 out[32];
1158
1159 } pbkdf2_sha256_tmp_t;
1160
1161 typedef struct
1162 {
1163 u64 ipad[8];
1164 u64 opad[8];
1165
1166 u64 dgst[16];
1167 u64 out[16];
1168
1169 } pbkdf2_sha512_tmp_t;
1170
1171 typedef struct
1172 {
1173 u64 out[8];
1174
1175 } ecryptfs_tmp_t;
1176
1177 typedef struct
1178 {
1179 u64 ipad[8];
1180 u64 opad[8];
1181
1182 u64 dgst[16];
1183 u64 out[16];
1184
1185 } oraclet_tmp_t;
1186
1187 typedef struct
1188 {
1189 u32 ipad[5];
1190 u32 opad[5];
1191
1192 u32 dgst[5];
1193 u32 out[5];
1194
1195 } agilekey_tmp_t;
1196
1197 typedef struct
1198 {
1199 u32 ipad[5];
1200 u32 opad[5];
1201
1202 u32 dgst1[5];
1203 u32 out1[5];
1204
1205 u32 dgst2[5];
1206 u32 out2[5];
1207
1208 } mywallet_tmp_t;
1209
1210 typedef struct
1211 {
1212 u32 ipad[5];
1213 u32 opad[5];
1214
1215 u32 dgst[5];
1216 u32 out[5];
1217
1218 } sha1aix_tmp_t;
1219
1220 typedef struct
1221 {
1222 u32 ipad[8];
1223 u32 opad[8];
1224
1225 u32 dgst[8];
1226 u32 out[8];
1227
1228 } sha256aix_tmp_t;
1229
1230 typedef struct
1231 {
1232 u64 ipad[8];
1233 u64 opad[8];
1234
1235 u64 dgst[8];
1236 u64 out[8];
1237
1238 } sha512aix_tmp_t;
1239
1240 typedef struct
1241 {
1242 u32 ipad[8];
1243 u32 opad[8];
1244
1245 u32 dgst[8];
1246 u32 out[8];
1247
1248 } lastpass_tmp_t;
1249
1250 typedef struct
1251 {
1252 u64 digest_buf[8];
1253
1254 } drupal7_tmp_t;
1255
1256 typedef struct
1257 {
1258 u32 ipad[5];
1259 u32 opad[5];
1260
1261 u32 dgst[5];
1262 u32 out[5];
1263
1264 } lotus8_tmp_t;
1265
1266 typedef struct
1267 {
1268 u32 out[5];
1269
1270 } office2007_tmp_t;
1271
1272 typedef struct
1273 {
1274 u32 out[5];
1275
1276 } office2010_tmp_t;
1277
1278 typedef struct
1279 {
1280 u64 out[8];
1281
1282 } office2013_tmp_t;
1283
1284 typedef struct
1285 {
1286 u32 digest_buf[5];
1287
1288 } saph_sha1_tmp_t;
1289
1290 typedef struct
1291 {
1292 u32 block[16];
1293
1294 u32 dgst[8];
1295
1296 u32 block_len;
1297 u32 final_len;
1298
1299 } seven_zip_tmp_t;
1300
1301 typedef struct
1302 {
1303 u32 KEK[5];
1304
1305 u32 lsb[4];
1306 u32 cipher[4];
1307
1308 } axcrypt_tmp_t;
1309
1310 typedef struct
1311 {
1312 u32 tmp_digest[8];
1313
1314 } keepass_tmp_t;
1315
1316 typedef struct
1317 {
1318 u32 Kc[16];
1319 u32 Kd[16];
1320
1321 u32 iv[2];
1322
1323 } bsdicrypt_tmp_t;
1324
1325 typedef struct
1326 {
1327 u32 dgst[17][5];
1328
1329 } rar3_tmp_t;
1330
1331 typedef struct
1332 {
1333 u32 user[16];
1334
1335 } cram_md5_t;
1336
1337 typedef struct
1338 {
1339 u32 iv_buf[4];
1340 u32 iv_len;
1341
1342 u32 salt_buf[4];
1343 u32 salt_len;
1344
1345 u32 crc;
1346
1347 u32 data_buf[96];
1348 u32 data_len;
1349
1350 u32 unpack_size;
1351
1352 } seven_zip_t;
1353
1354 typedef struct
1355 {
1356 u32 key;
1357 u64 val;
1358
1359 } hcstat_table_t;
1360
1361 typedef struct
1362 {
1363 u32 cs_buf[0x100];
1364 u32 cs_len;
1365
1366 } cs_t;
1367
1368 typedef struct
1369 {
1370 u32 cmds[0x100];
1371
1372 } kernel_rule_t;
1373
1374 typedef struct
1375 {
1376 u32 gidvid;
1377 u32 il_pos;
1378
1379 } plain_t;
1380
1381 typedef struct
1382 {
1383 u32 i[16];
1384
1385 u32 pw_len;
1386
1387 u32 alignment_placeholder_1;
1388 u32 alignment_placeholder_2;
1389 u32 alignment_placeholder_3;
1390
1391 } pw_t;
1392
1393 typedef struct
1394 {
1395 u32 i;
1396
1397 } bf_t;
1398
1399 typedef struct
1400 {
1401 u32 i[8];
1402
1403 u32 pw_len;
1404
1405 } comb_t;
1406
1407 typedef struct
1408 {
1409 u32 b[32];
1410
1411 } bs_word_t;
1412
1413 typedef struct
1414 {
1415 uint4 P[64];
1416
1417 } scrypt_tmp_t;