1 /* 2 * Developed by Claudio André <claudioandre.br at gmail.com> in 2012 3 * 4 * More information at http://openwall.info/wiki/john/OpenCL-SHA-512 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 _CRYPTSHA512_H 15 #define _CRYPTSHA512_H 16 17 #include "opencl_device_info.h" 18 #include "opencl_sha512.h" 19 20 /* *** 21 * IMPORTANT => due to optimizations 22 * len(salt) + len(key) MUST BE less than 40 bytes. 23 * 24 * - if the user has a 16 bytes salt, he will never be able to crack a 25 * password of 24 bytes. If the salt has less than 16 bytes 26 * JtR will be able to crack a 24 bytes password without problems. 27 * 28 * So, for safety, the format claims its limit is, in fact, 29 * - PLAINTEXT_LENGTH 23 30 *** */ 31 32 //Constants. 33 #define SALT_LENGTH 16 34 #define SALT_ALIGN 8 35 #define PLAINTEXT_LENGTH 23 36 #define CIPHERTEXT_LENGTH 86 37 #define BUFFER_ARRAY 8 38 #define SALT_ARRAY (SALT_LENGTH / 8) 39 #define PLAINTEXT_ARRAY ((PLAINTEXT_LENGTH + 7) / 8) 40 #define BINARY_SIZE 64 41 #define BINARY_ALIGN sizeof(uint64_t) 42 #define SEED 1024 43 #define STEP 0 44 45 #define HASH_LOOPS (7*3*2) 46 47 #define KEYS_PER_CORE_CPU 128 48 #define KEYS_PER_CORE_GPU 1 49 50 //Data types. 51 typedef union buffer_64_u { 52 uint8_t mem_08[8]; 53 uint16_t mem_16[4]; 54 uint32_t mem_32[2]; 55 uint64_t mem_64[1]; 56 } buffer_64; 57 58 typedef struct { 59 uint32_t rounds; 60 uint32_t length; 61 uint32_t final; 62 buffer_64 salt[SALT_ARRAY]; 63 } sha512_salt; 64 65 #define SALT_SIZE sizeof(sha512_salt) 66 67 typedef struct { 68 uint32_t length; 69 buffer_64 pass[PLAINTEXT_ARRAY]; 70 } sha512_password; 71 72 typedef struct { 73 uint64_t v[8]; //512 bits 74 } sha512_hash; 75 76 typedef struct { 77 uint64_t H[8]; //512 bits 78 uint32_t total; 79 uint32_t buflen; 80 buffer_64 buffer[16]; //1024bits 81 #if __CPU__ 82 uint64_t safety_trail; //To avoid memory override 83 #endif 84 } sha512_ctx; 85 86 typedef struct { 87 buffer_64 alt_result[8]; 88 buffer_64 temp_result[SALT_ARRAY]; 89 buffer_64 p_sequence[PLAINTEXT_ARRAY]; 90 } sha512_buffers; 91 92 #ifndef _OPENCL_COMPILER 93 static const char *warn[] = { 94 "xfer: ", ", crypt: ", ", xfer back: ", 95 ", prep: ", ", pp: ", ", final: ", ", var: ", "/" 96 }; 97 #endif 98 99 #endif /* _CRYPTSHA512_H */ 100