diff --git a/src/loader.c b/src/loader.c index f0880bc..0685b61 100644 --- a/src/loader.c +++ b/src/loader.c @@ -1578,10 +1578,17 @@ static int ldr_cracked_hash(char *ciphertext) while (*p) { hash <<= 1; hash += (unsigned char)*p++ | 0x20; /* ASCII case insensitive */ +#if CRACKED_HASH_LOG <= 12 if (hash >> (2 * CRACKED_HASH_LOG - 1)) { hash ^= hash >> CRACKED_HASH_LOG; hash &= CRACKED_HASH_SIZE - 1; } +#else + if (hash & 0xff000000U) { + hash ^= hash >> 13; + hash &= 0xffffffU; + } +#endif } hash ^= hash >> CRACKED_HASH_LOG; @@ -1693,13 +1700,20 @@ static void ldr_show_pw_line(struct db_main *db, char *line) if (format) { split = format->methods.split; unify = format->params.flags & FMT_SPLIT_UNIFIES_CASE; - if (format->params.flags & FMT_UNICODE) - pers_opts.store_utf8 = cfg_get_bool(SECTION_OPTIONS, - NULL, "UnicodeStoreUTF8", 0); - else - pers_opts.store_utf8 = pers_opts.target_enc != ASCII && - cfg_get_bool(SECTION_OPTIONS, NULL, - "CPstoreUTF8", 0); + if (format->params.flags & FMT_UNICODE) { + static int setting = -1; + if (setting < 0) + setting = cfg_get_bool(SECTION_OPTIONS, NULL, + "UnicodeStoreUTF8", 0); + pers_opts.store_utf8 = setting; + } else { + static int setting = -1; + if (setting < 0) + setting = pers_opts.target_enc != ASCII && + cfg_get_bool(SECTION_OPTIONS, NULL, + "CPstoreUTF8", 0); + pers_opts.store_utf8 = setting; + } } else { split = fmt_default_split; count = 1; diff --git a/src/params.h b/src/params.h index 5be5aba..b0f277b 100644 --- a/src/params.h +++ b/src/params.h @@ -253,7 +253,7 @@ extern unsigned int password_hash_thresholds[PASSWORD_HASH_SIZES]; /* * Cracked password hash size, used while loading. */ -#define CRACKED_HASH_LOG 16 +#define CRACKED_HASH_LOG 25 #define CRACKED_HASH_SIZE (1 << CRACKED_HASH_LOG) /* @@ -280,9 +280,14 @@ extern unsigned int password_hash_thresholds[PASSWORD_HASH_SIZES]; /* * Hash and buffer sizes for unique. */ -#define UNIQUE_HASH_LOG 21 +#if ARCH_BITS >= 64 +#define UNIQUE_HASH_LOG 25 +#define UNIQUE_BUFFER_SIZE 0x80000000U +#else +#define UNIQUE_HASH_LOG 24 +#define UNIQUE_BUFFER_SIZE 0x40000000 +#endif #define UNIQUE_HASH_SIZE (1 << UNIQUE_HASH_LOG) -#define UNIQUE_BUFFER_SIZE 0x8000000 /* * Maximum number of GECOS words per password to load. diff --git a/src/unique.c b/src/unique.c index 7ab8f1c..ebd8117 100644 --- a/src/unique.c +++ b/src/unique.c @@ -20,8 +20,8 @@ * files are 'proper' LM format (7 char and upcase). No auto * trimming/upcasing is done. * -mem=num. A number that overrides the UNIQUE_HASH_LOG value from within - * params.h. The default is 21. valid range from 13 to 25. 25 - * will use a 2GB memory buffer, and 33 entry million hash table + * params.h. The default is 24 or 25. valid range from 13 to 25. + * 25 will use a 2GB memory buffer, and 33 entry million hash table * Each number doubles size. */ @@ -446,7 +446,7 @@ int unique(int argc, char **argv) #if defined (__MINGW32__) puts(""); #endif - puts("Usage: unique [-v] [-inp=fname] [-cut=len] [-mem=num] OUTPUT-FILE [-ex_file=FNAME2] [-ex_file_only=FNAME2]\n\n" + printf("Usage: unique [-v] [-inp=fname] [-cut=len] [-mem=num] OUTPUT-FILE [-ex_file=FNAME2] [-ex_file_only=FNAME2]\n\n" " reads from stdin 'normally', but can be overridden by optional -inp=\n" " If -ex_file=XX is used, then data from file XX is also used to\n" " unique the data, but nothing is ever written to XX. Thus, any data in\n" @@ -455,11 +455,12 @@ int unique(int argc, char **argv) " -cut=len Will trim each input lines to 'len' bytes long, prior to running\n" " the unique algorithm. The 'trimming' is done on any -ex_file[_only] file\n" " -mem=num. A number that overrides the UNIQUE_HASH_LOG value from within\n" - " params.h. The default is 21. This can be raised, up to 25 (memory usage\n" + " params.h. The default is %u. Valid range is from 13 to 25 (memory usage\n" " doubles each number). If you go TOO large, unique will swap and thrash and\n" " work VERY slow\n" "\n" - " -v is for 'verbose' mode, outputs line counts during the run"); + " -v is for 'verbose' mode, outputs line counts during the run\n", + UNIQUE_HASH_LOG); if (argc <= 1) return 0;