Prepare remove of hash_type variable

This commit is contained in:
jsteube
2019-02-12 15:30:42 +01:00
parent 8b8cc78b69
commit 75f7172cca
32 changed files with 535 additions and 471 deletions
+28 -5
View File
@@ -9,6 +9,7 @@
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "inc_hash_constants.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 3;
@@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1;
static const u32 DGST_SIZE = DGST_SIZE_4_5;
static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE;
static const char *HASH_NAME = "Django (SHA-1)";
static const u32 HASH_TYPE = HASH_TYPE_SHA1;
static const u32 HASH_TYPE = HASH_TYPE_GENERIC;
static const u64 KERN_TYPE = 120;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_PRECOMPUTE_INIT
@@ -89,9 +90,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
digest[3] = hex_to_u32 (hash_pos + 24);
digest[4] = hex_to_u32 (hash_pos + 32);
decoder_apply_options (hashconfig, digest);
digest[0] = byte_swap_32 (digest[0]);
digest[1] = byte_swap_32 (digest[1]);
digest[2] = byte_swap_32 (digest[2]);
digest[3] = byte_swap_32 (digest[3]);
digest[4] = byte_swap_32 (digest[4]);
decoder_apply_optimizer (hashconfig, digest);
if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE)
{
digest[0] -= SHA1M_A;
digest[1] -= SHA1M_B;
digest[2] -= SHA1M_C;
digest[3] -= SHA1M_D;
digest[4] -= SHA1M_E;
}
const u8 *salt_pos = token.buf[1];
const int salt_len = token.len[1];
@@ -118,9 +130,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
tmp[3] = digest[3];
tmp[4] = digest[4];
encoder_apply_optimizer (hashconfig, tmp);
if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE)
{
tmp[0] += SHA1M_A;
tmp[1] += SHA1M_B;
tmp[2] += SHA1M_C;
tmp[3] += SHA1M_D;
tmp[4] += SHA1M_E;
}
encoder_apply_options (hashconfig, tmp);
tmp[0] = byte_swap_32 (tmp[0]);
tmp[1] = byte_swap_32 (tmp[1]);
tmp[2] = byte_swap_32 (tmp[2]);
tmp[3] = byte_swap_32 (tmp[3]);
tmp[4] = byte_swap_32 (tmp[4]);
char tmp_salt[SALT_MAX];