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