1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Fix some missing sign conversions

This commit is contained in:
jsteube 2016-09-30 17:41:40 +02:00
parent 683077b42a
commit a5f842c4b5
9 changed files with 97 additions and 114 deletions

View File

@ -69,4 +69,5 @@
} \
}
#endif // _DYNALOADER_H
#endif // _DYNALOADER_H

View File

@ -21,11 +21,11 @@ u64 mydivc64 (const u64 dividend, const u64 divisor);
char *filename_from_filepath (char *filepath);
void naive_replace (char *s, const u8 key_char, const u8 replace_char);
void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char);
void naive_replace (char *s, const char key_char, const char replace_char);
void naive_escape (char *s, size_t s_max, const char key_char, const char escape_char);
void hc_sleep_ms (const int msec);
void hc_sleep (const int sec);
void hc_sleep_ms (const u32 msec);
void hc_sleep (const u32 sec);
void setup_environment_variables ();
void setup_umask ();

View File

@ -77,29 +77,29 @@ typedef enum amplifier_count
typedef enum vendor_id
{
VENDOR_ID_AMD = (1 << 0),
VENDOR_ID_APPLE = (1 << 1),
VENDOR_ID_INTEL_BEIGNET = (1 << 2),
VENDOR_ID_INTEL_SDK = (1 << 3),
VENDOR_ID_MESA = (1 << 4),
VENDOR_ID_NV = (1 << 5),
VENDOR_ID_POCL = (1 << 6),
VENDOR_ID_AMD_USE_INTEL = (1 << 7),
VENDOR_ID_GENERIC = (1 << 31)
VENDOR_ID_AMD = (1u << 0),
VENDOR_ID_APPLE = (1u << 1),
VENDOR_ID_INTEL_BEIGNET = (1u << 2),
VENDOR_ID_INTEL_SDK = (1u << 3),
VENDOR_ID_MESA = (1u << 4),
VENDOR_ID_NV = (1u << 5),
VENDOR_ID_POCL = (1u << 6),
VENDOR_ID_AMD_USE_INTEL = (1u << 7),
VENDOR_ID_GENERIC = (1u << 31)
} vendor_id_t;
typedef enum status_rc
{
STATUS_INIT = 0,
STATUS_AUTOTUNE = 1,
STATUS_RUNNING = 2,
STATUS_PAUSED = 3,
STATUS_EXHAUSTED = 4,
STATUS_CRACKED = 5,
STATUS_ABORTED = 6,
STATUS_QUIT = 7,
STATUS_BYPASS = 8,
STATUS_INIT = 0,
STATUS_AUTOTUNE = 1,
STATUS_RUNNING = 2,
STATUS_PAUSED = 3,
STATUS_EXHAUSTED = 4,
STATUS_CRACKED = 5,
STATUS_ABORTED = 6,
STATUS_QUIT = 7,
STATUS_BYPASS = 8,
} status_rc_t;
@ -240,57 +240,57 @@ typedef enum salt_type
typedef enum opti_type
{
OPTI_TYPE_ZERO_BYTE = (1 << 1),
OPTI_TYPE_PRECOMPUTE_INIT = (1 << 2),
OPTI_TYPE_PRECOMPUTE_MERKLE = (1 << 3),
OPTI_TYPE_PRECOMPUTE_PERMUT = (1 << 4),
OPTI_TYPE_MEET_IN_MIDDLE = (1 << 5),
OPTI_TYPE_EARLY_SKIP = (1 << 6),
OPTI_TYPE_NOT_SALTED = (1 << 7),
OPTI_TYPE_NOT_ITERATED = (1 << 8),
OPTI_TYPE_PREPENDED_SALT = (1 << 9),
OPTI_TYPE_APPENDED_SALT = (1 << 10),
OPTI_TYPE_SINGLE_HASH = (1 << 11),
OPTI_TYPE_SINGLE_SALT = (1 << 12),
OPTI_TYPE_BRUTE_FORCE = (1 << 13),
OPTI_TYPE_RAW_HASH = (1 << 14),
OPTI_TYPE_SLOW_HASH_SIMD = (1 << 15),
OPTI_TYPE_USES_BITS_8 = (1 << 16),
OPTI_TYPE_USES_BITS_16 = (1 << 17),
OPTI_TYPE_USES_BITS_32 = (1 << 18),
OPTI_TYPE_USES_BITS_64 = (1 << 19)
OPTI_TYPE_ZERO_BYTE = (1u << 1),
OPTI_TYPE_PRECOMPUTE_INIT = (1u << 2),
OPTI_TYPE_PRECOMPUTE_MERKLE = (1u << 3),
OPTI_TYPE_PRECOMPUTE_PERMUT = (1u << 4),
OPTI_TYPE_MEET_IN_MIDDLE = (1u << 5),
OPTI_TYPE_EARLY_SKIP = (1u << 6),
OPTI_TYPE_NOT_SALTED = (1u << 7),
OPTI_TYPE_NOT_ITERATED = (1u << 8),
OPTI_TYPE_PREPENDED_SALT = (1u << 9),
OPTI_TYPE_APPENDED_SALT = (1u << 10),
OPTI_TYPE_SINGLE_HASH = (1u << 11),
OPTI_TYPE_SINGLE_SALT = (1u << 12),
OPTI_TYPE_BRUTE_FORCE = (1u << 13),
OPTI_TYPE_RAW_HASH = (1u << 14),
OPTI_TYPE_SLOW_HASH_SIMD = (1u << 15),
OPTI_TYPE_USES_BITS_8 = (1u << 16),
OPTI_TYPE_USES_BITS_16 = (1u << 17),
OPTI_TYPE_USES_BITS_32 = (1u << 18),
OPTI_TYPE_USES_BITS_64 = (1u << 19)
} opti_type_t;
typedef enum opts_type
{
OPTS_TYPE_PT_UNICODE = (1 << 0),
OPTS_TYPE_PT_UPPER = (1 << 1),
OPTS_TYPE_PT_LOWER = (1 << 2),
OPTS_TYPE_PT_ADD01 = (1 << 3),
OPTS_TYPE_PT_ADD02 = (1 << 4),
OPTS_TYPE_PT_ADD80 = (1 << 5),
OPTS_TYPE_PT_ADDBITS14 = (1 << 6),
OPTS_TYPE_PT_ADDBITS15 = (1 << 7),
OPTS_TYPE_PT_GENERATE_LE = (1 << 8),
OPTS_TYPE_PT_GENERATE_BE = (1 << 9),
OPTS_TYPE_PT_NEVERCRACK = (1 << 10), // if we want all possible results
OPTS_TYPE_PT_BITSLICE = (1 << 11),
OPTS_TYPE_ST_UNICODE = (1 << 12),
OPTS_TYPE_ST_UPPER = (1 << 13),
OPTS_TYPE_ST_LOWER = (1 << 14),
OPTS_TYPE_ST_ADD01 = (1 << 15),
OPTS_TYPE_ST_ADD02 = (1 << 16),
OPTS_TYPE_ST_ADD80 = (1 << 17),
OPTS_TYPE_ST_ADDBITS14 = (1 << 18),
OPTS_TYPE_ST_ADDBITS15 = (1 << 19),
OPTS_TYPE_ST_GENERATE_LE = (1 << 20),
OPTS_TYPE_ST_GENERATE_BE = (1 << 21),
OPTS_TYPE_ST_HEX = (1 << 22),
OPTS_TYPE_ST_BASE64 = (1 << 23),
OPTS_TYPE_HASH_COPY = (1 << 24),
OPTS_TYPE_HOOK12 = (1 << 25),
OPTS_TYPE_HOOK23 = (1 << 26)
OPTS_TYPE_PT_UNICODE = (1u << 0),
OPTS_TYPE_PT_UPPER = (1u << 1),
OPTS_TYPE_PT_LOWER = (1u << 2),
OPTS_TYPE_PT_ADD01 = (1u << 3),
OPTS_TYPE_PT_ADD02 = (1u << 4),
OPTS_TYPE_PT_ADD80 = (1u << 5),
OPTS_TYPE_PT_ADDBITS14 = (1u << 6),
OPTS_TYPE_PT_ADDBITS15 = (1u << 7),
OPTS_TYPE_PT_GENERATE_LE = (1u << 8),
OPTS_TYPE_PT_GENERATE_BE = (1u << 9),
OPTS_TYPE_PT_NEVERCRACK = (1u << 10), // if we want all possible results
OPTS_TYPE_PT_BITSLICE = (1u << 11),
OPTS_TYPE_ST_UNICODE = (1u << 12),
OPTS_TYPE_ST_UPPER = (1u << 13),
OPTS_TYPE_ST_LOWER = (1u << 14),
OPTS_TYPE_ST_ADD01 = (1u << 15),
OPTS_TYPE_ST_ADD02 = (1u << 16),
OPTS_TYPE_ST_ADD80 = (1u << 17),
OPTS_TYPE_ST_ADDBITS14 = (1u << 18),
OPTS_TYPE_ST_ADDBITS15 = (1u << 19),
OPTS_TYPE_ST_GENERATE_LE = (1u << 20),
OPTS_TYPE_ST_GENERATE_BE = (1u << 21),
OPTS_TYPE_ST_HEX = (1u << 22),
OPTS_TYPE_ST_BASE64 = (1u << 23),
OPTS_TYPE_HASH_COPY = (1u << 24),
OPTS_TYPE_HOOK12 = (1u << 25),
OPTS_TYPE_HOOK23 = (1u << 26)
} opts_type_t;
@ -334,10 +334,10 @@ typedef enum hlfmt_name
typedef enum outfile_fmt
{
OUTFILE_FMT_HASH = (1 << 0),
OUTFILE_FMT_PLAIN = (1 << 1),
OUTFILE_FMT_HEXPLAIN = (1 << 2),
OUTFILE_FMT_CRACKPOS = (1 << 3)
OUTFILE_FMT_HASH = (1u << 0),
OUTFILE_FMT_PLAIN = (1u << 1),
OUTFILE_FMT_HEXPLAIN = (1u << 2),
OUTFILE_FMT_CRACKPOS = (1u << 3)
} outfile_fmt_t;
@ -779,17 +779,10 @@ typedef struct cpu_set
} cpu_set_t;
#endif
typedef struct
{
u32 bitmap_shift;
u32 collisions;
} bitmap_result_t;
/* AES context. */
typedef struct aes_context
{
u32 bits;
int bits;
u32 rek[60];
u32 rdk[60];

View File

@ -73,7 +73,7 @@ void set_cpu_affinity (char *cpu_affinity)
do
{
uint cpu_id = atoi (next);
int cpu_id = atoi (next);
if (cpu_id == 0)
{

View File

@ -9,14 +9,6 @@
#include "logging.h"
#include "bitmap.h"
int sort_by_bitmap (const void *p1, const void *p2)
{
const bitmap_result_t *b1 = (const bitmap_result_t *) p1;
const bitmap_result_t *b2 = (const bitmap_result_t *) p2;
return b1->collisions - b2->collisions;
}
static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, const u32 bitmap_size, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d, const u64 collisions_max)
{
u64 collisions = 0;

View File

@ -4,3 +4,4 @@
*/
#include "common.h"

View File

@ -55,10 +55,10 @@
extern hc_global_data_t data;
extern int SUPPRESS_OUTPUT;
extern bool SUPPRESS_OUTPUT;
extern const int DEFAULT_BENCHMARK_ALGORITHMS_CNT;
extern const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT;
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
const int comptime = COMPTIME;
const char *version_tag = VERSION_TAG;
@ -653,8 +653,8 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
{
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
{
u32 salt_len = (u32) hashes->salts_buf[0].salt_len;
char *salt_buf = (char *) hashes->salts_buf[0].salt_buf;
u32 salt_len = (u32) hashes->salts_buf[0].salt_len;
u8 *salt_buf = (u8 *) hashes->salts_buf[0].salt_buf;
u32 css_cnt_salt = mask_ctx->css_cnt + salt_len;
@ -789,7 +789,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
if (dictionary_files != NULL)
{
qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
@ -946,7 +946,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
user_options->rule_buf_l = user_options->rule_buf_r;
user_options->rule_buf_r = tmpc;
int tmpi = user_options_extra->rule_len_l;
u32 tmpi = user_options_extra->rule_len_l;
user_options_extra->rule_len_l = user_options_extra->rule_len_r;
user_options_extra->rule_len_r = tmpi;
@ -995,7 +995,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
if (dictionary_files != NULL)
{
qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
@ -1067,7 +1067,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
if (dictionary_files != NULL)
{
qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
@ -1209,7 +1209,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
{
outfile_write_open (outfile_ctx);
SUPPRESS_OUTPUT = 1;
SUPPRESS_OUTPUT = true;
potfile_read_open (potfile_ctx);
@ -1217,7 +1217,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
potfile_read_close (potfile_ctx);
SUPPRESS_OUTPUT = 0;
SUPPRESS_OUTPUT = false;
}
/**
@ -1252,8 +1252,6 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
potfile_hash_free (potfile_ctx, hashconfig);
//if (user_options->quiet == false) log_info_nn ("");
return 0;
}
@ -1959,7 +1957,7 @@ int main (int argc, char **argv)
}
else
{
for (int algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++)
for (u32 algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++)
{
user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos];
@ -2037,7 +2035,7 @@ int main (int argc, char **argv)
user_options_destroy (user_options);
u32 rc_final = -1;
int rc_final = -1;
if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2;
if (status_ctx->devices_status == STATUS_QUIT) rc_final = 2;

View File

@ -16,7 +16,7 @@ u32 get_random_num (const u32 min, const u32 max)
{
if (min == max) return (min);
return ((rand () % (max - min)) + min);
return (((u32) rand () % (max - min)) + min);
}
u32 mydivc32 (const u32 dividend, const u32 divisor)
@ -57,13 +57,13 @@ char *filename_from_filepath (char *filepath)
return ptr;
}
void naive_replace (char *s, const u8 key_char, const u8 replace_char)
void naive_replace (char *s, const char key_char, const char replace_char)
{
const size_t len = strlen (s);
for (size_t in = 0; in < len; in++)
{
const u8 c = s[in];
const char c = s[in];
if (c == key_char)
{
@ -72,7 +72,7 @@ void naive_replace (char *s, const u8 key_char, const u8 replace_char)
}
}
void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char)
void naive_escape (char *s, size_t s_max, const char key_char, const char escape_char)
{
char s_escaped[1024] = { 0 };
@ -82,7 +82,7 @@ void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_cha
for (size_t in = 0, out = 0; in < len; in++, out++)
{
const u8 c = s[in];
const char c = s[in];
if (c == key_char)
{
@ -99,7 +99,7 @@ void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_cha
strncpy (s, s_escaped, s_max - 1);
}
void hc_sleep_ms (const int msec)
void hc_sleep_ms (const u32 msec)
{
#if defined (_WIN)
Sleep (msec);
@ -108,7 +108,7 @@ void hc_sleep_ms (const int msec)
#endif
}
void hc_sleep (const int sec)
void hc_sleep (const u32 sec)
{
#if defined (_WIN)
Sleep (sec * 1000);

View File

@ -1082,8 +1082,6 @@ void status_display (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const h
void status_benchmark_automate (status_ctx_t *status_ctx, opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig)
{
if (status_ctx == NULL) status_ctx = status_ctx; // make gcc happy, for now...
if (status_ctx->devices_status == STATUS_INIT)
{
log_error ("ERROR: status view is not available during initialization phase");