1 /*
2  * Developed by Claudio André <claudioandre.br at gmail.com> in 2012
3  *
4  * More information at http://openwall.info/wiki/john/OpenCL-RAWSHA-256
5  *
6  * Copyright (c) 2012-2015 Claudio André <claudioandre.br at gmail.com>
7  * This program comes with ABSOLUTELY NO WARRANTY; express or implied.
8  *
9  * This is free software, and you are welcome to redistribute it
10  * under certain conditions; as expressed here
11  * http://www.gnu.org/licenses/gpl-2.0.html
12  */
13 
14 #ifndef _RAWSHA256_H
15 #define _RAWSHA256_H
16 
17 #include "opencl_device_info.h"
18 #include "opencl_sha256.h"
19 
20 //Constants.
21 #define RAW_PLAINTEXT_LENGTH    55  /* 55 characters + 0x80 */
22 #define PLAINTEXT_LENGTH    RAW_PLAINTEXT_LENGTH
23 
24 #define BUFFER_SIZE             56  /* RAW_PLAINTEXT_LENGTH multiple of 4 */
25 
26 #ifdef _OPENCL_COMPILER
27 #define BINARY_SIZE             32
28 #endif
29 
30 #define HASH_PARTS      BINARY_SIZE / 4
31 #define SALT_SIZE               0
32 #define SALT_ALIGN              1
33 #define STEP            0
34 #define SEED            1024
35 
36 #define KEYS_PER_CORE_CPU       65536
37 #define KEYS_PER_CORE_GPU       512
38 
39 #define SPREAD_32(X0, X1, X2, X3, SIZE_MIN_1, X, Y) {                         \
40 	X = (X0) ^ (X1) ^ (X2);                                               \
41 	X = X & SIZE_MIN_1;                                                   \
42 	Y = (X + (X3)) ^ (X0);                                                \
43 	Y = Y & SIZE_MIN_1;                                                   \
44 }
45 
46 //Data types.
47 typedef union buffer_32_u {
48 	uint8_t mem_08[4];
49 	uint16_t mem_16[2];
50 	uint32_t mem_32[1];
51 } buffer_32;
52 
53 typedef struct {
54 	uint32_t v[8];              //256 bits
55 } sha256_hash;
56 
57 typedef struct {
58 	uint32_t buflen;
59 	buffer_32 buffer[16];       //512 bits
60 } sha256_ctx;
61 
62 #ifndef _OPENCL_COMPILER
63 static const char *warn[] = {
64 	"prep: ", ", xfer pass: ", ", idx: ", ", crypt: ", ", result: ",
65 	", mask xfer: ", " + "
66 };
67 #endif
68 
69 #endif                          /* _RAWSHA256_H */
70