1 /*
2  * This software is Copyright (c) 2015 magnum
3  * and it is hereby released to the general public under the following terms:
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted.
6  *
7  * JimF  (Feb, 2016)
8  * bumped salt to 2 limb (115 byte max). Originally this was 1 limb  and 'should'
9  * have only allowed 51 byte salts. But a bug in code listed 52 as max salt size.
10  * this has been fixed, and now 2 limb salts work just fine.
11  */
12 #ifndef _OPENCL_PBKDF2_HMAC_MD5_H
13 #define _OPENCL_PBKDF2_HMAC_MD5_H
14 
15 /*
16  * The MD5 block size used for HMAC dictates (for optimised code) a max.
17  * plaintext length of 64 and a max. salt length of 52. (should have actually
18  * only been 51! but it has been bumped 2 to md4 limbs and 115 byte salt.)
19  *
20  * These structs do NOT have space for any cstring trailing NULL
21  */
22 
23 #ifndef PLAINTEXT_LENGTH
24 #define PLAINTEXT_LENGTH	64
25 #endif
26 
27 typedef struct {
28 	unsigned int dk[((OUTLEN + 15) / 16) * 16 / sizeof(unsigned int)];
29 } pbkdf2_out;
30 
31 typedef struct {
32 	unsigned int  length;
33 	unsigned int  outlen;
34 	unsigned int  iterations;
35 	unsigned char salt[179];
36 } pbkdf2_salt;
37 
38 #ifndef _OPENCL_COMPILER
39 #define MAYBE_VECTOR_UINT unsigned int
40 #endif
41 
42 typedef struct {
43 	MAYBE_VECTOR_UINT W[4];
44 	MAYBE_VECTOR_UINT ipad[4];
45 	MAYBE_VECTOR_UINT opad[4];
46 	MAYBE_VECTOR_UINT out[4];
47 	unsigned int iter_cnt;
48 	unsigned int pass;
49 } pbkdf2_state;
50 
51 #endif
52