--- rawSHA512_ng_fmt.c 2013-04-17 08:02:56.654480553 +0400 +++ rawSHA512_ng_fmt.c-hotcold 2013-04-17 08:17:18.848483191 +0400 @@ -181,12 +181,12 @@ }; static uint64_t (*saved_key)[16]; -static uint64_t *crypt_key[ 8]; +static uint64_t *crypt_key_hot; +static uint64_t (*crypt_key_cold)[7][2]; static void init(struct fmt_main *self) { - int i; #ifdef _OPENMP int omp_t; @@ -196,8 +196,8 @@ self->params.max_keys_per_crypt *= omp_t; #endif saved_key = mem_calloc_tiny(sizeof(*saved_key) * self->params.max_keys_per_crypt, MEM_ALIGN_CACHE); - for (i = 0; i < 8; i++) - crypt_key[i] = mem_calloc_tiny(sizeof(uint64_t) * self->params.max_keys_per_crypt, MEM_ALIGN_CACHE); + crypt_key_hot = mem_calloc_tiny(sizeof(*crypt_key_hot) * self->params.max_keys_per_crypt, MEM_ALIGN_CACHE); + crypt_key_cold = mem_calloc_tiny(sizeof(*crypt_key_cold) * self->params.max_keys_per_crypt / 2, MEM_ALIGN_CACHE); } @@ -285,13 +285,13 @@ static int binary_hash_5 (void *binary) { return *(uint32_t *) binary & 0xffffff; } static int binary_hash_6 (void *binary) { return *(uint32_t *) binary & 0x7ffffff; } -static int get_hash_0 (int index) { return crypt_key[0][index] & 0xf; } -static int get_hash_1 (int index) { return crypt_key[0][index] & 0xff; } -static int get_hash_2 (int index) { return crypt_key[0][index] & 0xfff; } -static int get_hash_3 (int index) { return crypt_key[0][index] & 0xffff; } -static int get_hash_4 (int index) { return crypt_key[0][index] & 0xfffff; } -static int get_hash_5 (int index) { return crypt_key[0][index] & 0xffffff; } -static int get_hash_6 (int index) { return crypt_key[0][index] & 0x7ffffff; } +static int get_hash_0 (int index) { return crypt_key_hot[index] & 0xf; } +static int get_hash_1 (int index) { return crypt_key_hot[index] & 0xff; } +static int get_hash_2 (int index) { return crypt_key_hot[index] & 0xfff; } +static int get_hash_3 (int index) { return crypt_key_hot[index] & 0xffff; } +static int get_hash_4 (int index) { return crypt_key_hot[index] & 0xfffff; } +static int get_hash_5 (int index) { return crypt_key_hot[index] & 0xffffff; } +static int get_hash_6 (int index) { return crypt_key_hot[index] & 0x7ffffff; } static void set_key (char *key, int index) @@ -456,14 +456,14 @@ SHA512_STEP(c, d, e, f, g, h, a, b, 78, 0x5fcb6fab3ad6faec); SHA512_STEP(b, c, d, e, f, g, h, a, 79, 0x6c44198c4a475817); - _mm_store_si128 ((__m128i *) &crypt_key[0][index], a); - _mm_store_si128 ((__m128i *) &crypt_key[1][index], b); - _mm_store_si128 ((__m128i *) &crypt_key[2][index], c); - _mm_store_si128 ((__m128i *) &crypt_key[3][index], d); - _mm_store_si128 ((__m128i *) &crypt_key[4][index], e); - _mm_store_si128 ((__m128i *) &crypt_key[5][index], f); - _mm_store_si128 ((__m128i *) &crypt_key[6][index], g); - _mm_store_si128 ((__m128i *) &crypt_key[7][index], h); + _mm_store_si128 ((__m128i *) &crypt_key_hot[index], a); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][0][0], b); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][1][0], c); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][2][0], d); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][3][0], e); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][4][0], f); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][5][0], g); + _mm_store_si128 ((__m128i *) &crypt_key_cold[index >> 1][6][0], h); } #if FMT_MAIN_VERSION > 10 @@ -481,7 +481,7 @@ #else for (i=0; i < 2; i++) #endif - if (((uint64_t *) binary)[0] == crypt_key[0][i]) + if (((uint64_t *) binary)[0] == crypt_key_hot[i]) return 1; return 0; @@ -490,7 +490,7 @@ static int cmp_one (void *binary, int index) { - return (((uint64_t *) binary)[0] == crypt_key[0][index]); + return (((uint64_t *) binary)[0] == crypt_key_hot[index]); } @@ -501,8 +501,11 @@ bin = (uint64_t *) get_binary (source); + if (((uint64_t *) bin)[0] != crypt_key_hot[index]) + return 0; + for (i=1; i < 8; i++) - if (((uint64_t *) bin)[i] != crypt_key[i][index]) + if (((uint64_t *) bin)[i] != crypt_key_cold[index >> 1][i - 1][index & 1]) return 0; return 1;