mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-23 13:02:06 +00:00
Fix some broken strict-aliasing rules
This commit is contained in:
parent
b48056fa42
commit
42e440611a
@ -58,4 +58,12 @@ size_t base64_encode (u8 (*f) (const u8), const u8 *in_buf, const size_t in_len,
|
||||
void lowercase (u8 *buf, const size_t len);
|
||||
void uppercase (u8 *buf, const size_t len);
|
||||
|
||||
u16 v16a_from_v32 (const u32 v32);
|
||||
u16 v16b_from_v32 (const u32 v32);
|
||||
u32 v32_from_v16ab (const u16 v16a, const u16 v16b);
|
||||
|
||||
u32 v32a_from_v64 (const u64 v64);
|
||||
u32 v32b_from_v64 (const u64 v64);
|
||||
u64 v64_from_v32ab (const u32 v32a, const u32 v32b);
|
||||
|
||||
#endif // _CONVERT_H
|
||||
|
@ -75,6 +75,60 @@ typedef pthread_mutex_t hc_thread_mutex_t;
|
||||
typedef sem_t hc_thread_semaphore_t;
|
||||
#endif
|
||||
|
||||
// unions
|
||||
|
||||
typedef union vconv32
|
||||
{
|
||||
u64 v32;
|
||||
|
||||
struct
|
||||
{
|
||||
u16 v16a;
|
||||
u16 v16b;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
u8 v8a;
|
||||
u8 v8b;
|
||||
u8 v8c;
|
||||
u8 v8d;
|
||||
};
|
||||
|
||||
} vconv32_t;
|
||||
|
||||
typedef union vconv64
|
||||
{
|
||||
u64 v64;
|
||||
|
||||
struct
|
||||
{
|
||||
u32 v32a;
|
||||
u32 v32b;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
u16 v16a;
|
||||
u16 v16b;
|
||||
u16 v16c;
|
||||
u16 v16d;
|
||||
};
|
||||
|
||||
struct
|
||||
{
|
||||
u8 v8a;
|
||||
u8 v8b;
|
||||
u8 v8c;
|
||||
u8 v8d;
|
||||
u8 v8e;
|
||||
u8 v8f;
|
||||
u8 v8g;
|
||||
u8 v8h;
|
||||
};
|
||||
|
||||
} vconv64_t;
|
||||
|
||||
// enums
|
||||
|
||||
typedef enum loglevel
|
||||
|
@ -838,3 +838,59 @@ void uppercase (u8 *buf, const size_t len)
|
||||
{
|
||||
for (size_t i = 0; i < len; i++) buf[i] = (u8) toupper ((int) buf[i]);
|
||||
}
|
||||
|
||||
u16 v16a_from_v32 (const u32 v32)
|
||||
{
|
||||
vconv32_t v;
|
||||
|
||||
v.v32 = v32;
|
||||
|
||||
return v.v16a;
|
||||
}
|
||||
|
||||
u16 v16b_from_v32 (const u32 v32)
|
||||
{
|
||||
vconv32_t v;
|
||||
|
||||
v.v32 = v32;
|
||||
|
||||
return v.v16b;
|
||||
}
|
||||
|
||||
u32 v32_from_v16ab (const u16 v16a, const u16 v16b)
|
||||
{
|
||||
vconv32_t v;
|
||||
|
||||
v.v16a = v16a;
|
||||
v.v16b = v16b;
|
||||
|
||||
return v.v32;
|
||||
}
|
||||
|
||||
u32 v32a_from_v64 (const u64 v64)
|
||||
{
|
||||
vconv64_t v;
|
||||
|
||||
v.v64 = v64;
|
||||
|
||||
return v.v32a;
|
||||
}
|
||||
|
||||
u32 v32b_from_v64 (const u64 v64)
|
||||
{
|
||||
vconv64_t v;
|
||||
|
||||
v.v64 = v64;
|
||||
|
||||
return v.v32b;
|
||||
}
|
||||
|
||||
u64 v64_from_v32ab (const u32 v32a, const u32 v32b)
|
||||
{
|
||||
vconv64_t v;
|
||||
|
||||
v.v32a = v32a;
|
||||
v.v32b = v32b;
|
||||
|
||||
return v.v64;
|
||||
}
|
||||
|
@ -203,39 +203,37 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
tmp[2] = byte_swap_32 (tmp[2]);
|
||||
tmp[3] = byte_swap_32 (tmp[3]);
|
||||
|
||||
u16 *ptr = (u16 *) tmp;
|
||||
|
||||
u8 tmp_buf[32];
|
||||
|
||||
tmp_buf[ 0] = sig[0];
|
||||
tmp_buf[ 1] = int_to_base64 (((ptr[1]) >> 12) & 0x3f);
|
||||
tmp_buf[ 2] = int_to_base64 (((ptr[1]) >> 6) & 0x3f);
|
||||
tmp_buf[ 3] = int_to_base64 (((ptr[1]) >> 0) & 0x3f);
|
||||
tmp_buf[ 4] = int_to_base64 (((ptr[0]) >> 12) & 0x3f);
|
||||
tmp_buf[ 5] = int_to_base64 (((ptr[0]) >> 6) & 0x3f);
|
||||
tmp_buf[ 1] = int_to_base64 (((v16b_from_v32 (tmp[0])) >> 12) & 0x3f);
|
||||
tmp_buf[ 2] = int_to_base64 (((v16b_from_v32 (tmp[0])) >> 6) & 0x3f);
|
||||
tmp_buf[ 3] = int_to_base64 (((v16b_from_v32 (tmp[0])) >> 0) & 0x3f);
|
||||
tmp_buf[ 4] = int_to_base64 (((v16a_from_v32 (tmp[0])) >> 12) & 0x3f);
|
||||
tmp_buf[ 5] = int_to_base64 (((v16a_from_v32 (tmp[0])) >> 6) & 0x3f);
|
||||
tmp_buf[ 6] = sig[1];
|
||||
tmp_buf[ 7] = int_to_base64 (((ptr[0]) >> 0) & 0x3f);
|
||||
tmp_buf[ 8] = int_to_base64 (((ptr[3]) >> 12) & 0x3f);
|
||||
tmp_buf[ 9] = int_to_base64 (((ptr[3]) >> 6) & 0x3f);
|
||||
tmp_buf[10] = int_to_base64 (((ptr[3]) >> 0) & 0x3f);
|
||||
tmp_buf[11] = int_to_base64 (((ptr[2]) >> 12) & 0x3f);
|
||||
tmp_buf[ 7] = int_to_base64 (((v16a_from_v32 (tmp[0])) >> 0) & 0x3f);
|
||||
tmp_buf[ 8] = int_to_base64 (((v16b_from_v32 (tmp[1])) >> 12) & 0x3f);
|
||||
tmp_buf[ 9] = int_to_base64 (((v16b_from_v32 (tmp[1])) >> 6) & 0x3f);
|
||||
tmp_buf[10] = int_to_base64 (((v16b_from_v32 (tmp[1])) >> 0) & 0x3f);
|
||||
tmp_buf[11] = int_to_base64 (((v16a_from_v32 (tmp[1])) >> 12) & 0x3f);
|
||||
tmp_buf[12] = sig[2];
|
||||
tmp_buf[13] = int_to_base64 (((ptr[2]) >> 6) & 0x3f);
|
||||
tmp_buf[14] = int_to_base64 (((ptr[2]) >> 0) & 0x3f);
|
||||
tmp_buf[15] = int_to_base64 (((ptr[5]) >> 12) & 0x3f);
|
||||
tmp_buf[16] = int_to_base64 (((ptr[5]) >> 6) & 0x3f);
|
||||
tmp_buf[13] = int_to_base64 (((v16a_from_v32 (tmp[1])) >> 6) & 0x3f);
|
||||
tmp_buf[14] = int_to_base64 (((v16a_from_v32 (tmp[1])) >> 0) & 0x3f);
|
||||
tmp_buf[15] = int_to_base64 (((v16b_from_v32 (tmp[2])) >> 12) & 0x3f);
|
||||
tmp_buf[16] = int_to_base64 (((v16b_from_v32 (tmp[2])) >> 6) & 0x3f);
|
||||
tmp_buf[17] = sig[3];
|
||||
tmp_buf[18] = int_to_base64 (((ptr[5]) >> 0) & 0x3f);
|
||||
tmp_buf[19] = int_to_base64 (((ptr[4]) >> 12) & 0x3f);
|
||||
tmp_buf[20] = int_to_base64 (((ptr[4]) >> 6) & 0x3f);
|
||||
tmp_buf[21] = int_to_base64 (((ptr[4]) >> 0) & 0x3f);
|
||||
tmp_buf[22] = int_to_base64 (((ptr[7]) >> 12) & 0x3f);
|
||||
tmp_buf[18] = int_to_base64 (((v16b_from_v32 (tmp[2])) >> 0) & 0x3f);
|
||||
tmp_buf[19] = int_to_base64 (((v16a_from_v32 (tmp[2])) >> 12) & 0x3f);
|
||||
tmp_buf[20] = int_to_base64 (((v16a_from_v32 (tmp[2])) >> 6) & 0x3f);
|
||||
tmp_buf[21] = int_to_base64 (((v16a_from_v32 (tmp[2])) >> 0) & 0x3f);
|
||||
tmp_buf[22] = int_to_base64 (((v16b_from_v32 (tmp[3])) >> 12) & 0x3f);
|
||||
tmp_buf[23] = sig[4];
|
||||
tmp_buf[24] = int_to_base64 (((ptr[7]) >> 6) & 0x3f);
|
||||
tmp_buf[25] = int_to_base64 (((ptr[7]) >> 0) & 0x3f);
|
||||
tmp_buf[26] = int_to_base64 (((ptr[6]) >> 12) & 0x3f);
|
||||
tmp_buf[27] = int_to_base64 (((ptr[6]) >> 6) & 0x3f);
|
||||
tmp_buf[28] = int_to_base64 (((ptr[6]) >> 0) & 0x3f);
|
||||
tmp_buf[24] = int_to_base64 (((v16b_from_v32 (tmp[3])) >> 6) & 0x3f);
|
||||
tmp_buf[25] = int_to_base64 (((v16b_from_v32 (tmp[3])) >> 0) & 0x3f);
|
||||
tmp_buf[26] = int_to_base64 (((v16a_from_v32 (tmp[3])) >> 12) & 0x3f);
|
||||
tmp_buf[27] = int_to_base64 (((v16a_from_v32 (tmp[3])) >> 6) & 0x3f);
|
||||
tmp_buf[28] = int_to_base64 (((v16a_from_v32 (tmp[3])) >> 0) & 0x3f);
|
||||
tmp_buf[29] = sig[5];
|
||||
tmp_buf[30] = 0;
|
||||
|
||||
|
@ -156,8 +156,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
tmp[7] += SHA512M_H;
|
||||
}
|
||||
|
||||
u32 *ptr = (u32 *) tmp;
|
||||
|
||||
char tmp_salt[SALT_MAX * 2];
|
||||
|
||||
const int salt_len = generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, (u8 *) tmp_salt);
|
||||
@ -166,14 +164,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
const int line_len = snprintf (line_buf, line_size, "%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x",
|
||||
tmp_salt,
|
||||
ptr[ 1], ptr[ 0],
|
||||
ptr[ 3], ptr[ 2],
|
||||
ptr[ 5], ptr[ 4],
|
||||
ptr[ 7], ptr[ 6],
|
||||
ptr[ 9], ptr[ 8],
|
||||
ptr[11], ptr[10],
|
||||
ptr[13], ptr[12],
|
||||
ptr[15], ptr[14]);
|
||||
v32b_from_v64 (tmp[0]), v32a_from_v64 (tmp[0]),
|
||||
v32b_from_v64 (tmp[1]), v32a_from_v64 (tmp[1]),
|
||||
v32b_from_v64 (tmp[2]), v32a_from_v64 (tmp[2]),
|
||||
v32b_from_v64 (tmp[3]), v32a_from_v64 (tmp[3]),
|
||||
v32b_from_v64 (tmp[4]), v32a_from_v64 (tmp[4]),
|
||||
v32b_from_v64 (tmp[5]), v32a_from_v64 (tmp[5]),
|
||||
v32b_from_v64 (tmp[6]), v32a_from_v64 (tmp[6]),
|
||||
v32b_from_v64 (tmp[7]), v32a_from_v64 (tmp[7]));
|
||||
|
||||
return line_len;
|
||||
}
|
||||
|
@ -149,8 +149,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
tmp[7] += SHA512M_H;
|
||||
}
|
||||
|
||||
const u32 *ptr = (const u32 *) tmp;
|
||||
|
||||
char tmp_salt[SALT_MAX * 2];
|
||||
|
||||
const int salt_len = generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, (u8 *) tmp_salt);
|
||||
@ -159,14 +157,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
const int line_len = snprintf (line_buf, line_size, "0x0200%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x",
|
||||
tmp_salt,
|
||||
ptr[ 1], ptr[ 0],
|
||||
ptr[ 3], ptr[ 2],
|
||||
ptr[ 5], ptr[ 4],
|
||||
ptr[ 7], ptr[ 6],
|
||||
ptr[ 9], ptr[ 8],
|
||||
ptr[11], ptr[10],
|
||||
ptr[13], ptr[12],
|
||||
ptr[15], ptr[14]);
|
||||
v32b_from_v64 (tmp[0]), v32a_from_v64 (tmp[0]),
|
||||
v32b_from_v64 (tmp[1]), v32a_from_v64 (tmp[1]),
|
||||
v32b_from_v64 (tmp[2]), v32a_from_v64 (tmp[2]),
|
||||
v32b_from_v64 (tmp[3]), v32a_from_v64 (tmp[3]),
|
||||
v32b_from_v64 (tmp[4]), v32a_from_v64 (tmp[4]),
|
||||
v32b_from_v64 (tmp[5]), v32a_from_v64 (tmp[5]),
|
||||
v32b_from_v64 (tmp[6]), v32a_from_v64 (tmp[6]),
|
||||
v32b_from_v64 (tmp[7]), v32a_from_v64 (tmp[7]));
|
||||
|
||||
return line_len;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user