diff -u john-1.7.9.6-newform/src/AFS_fmt.c john-1.7.9.6-newform/src/AFS_fmt.c --- john-1.7.9.6-newform/src/AFS_fmt.c 2012-07-18 04:12:23 +0000 +++ john-1.7.9.6-newform/src/AFS_fmt.c 2012-07-21 12:16:46 +0000 @@ -281,8 +281,9 @@ return buffer[index].key; } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; int index, pos, length; char xor[8]; ARCH_WORD_32 space[(PLAINTEXT_LENGTH + SALT_SIZE + 8) / 4 + 1]; diff -u john-1.7.9.6-newform/src/BF_fmt.c john-1.7.9.6-newform/src/BF_fmt.c --- john-1.7.9.6-newform/src/BF_fmt.c 2012-07-18 04:12:29 +0000 +++ john-1.7.9.6-newform/src/BF_fmt.c 2012-07-21 12:19:26 +0000 @@ -225,8 +225,10 @@ return saved_key[index]; } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; + if (keys_mode != saved_salt.subtype) { int i; diff -u john-1.7.9.6-newform/src/BSDI_fmt.c john-1.7.9.6-newform/src/BSDI_fmt.c --- john-1.7.9.6-newform/src/BSDI_fmt.c 2012-07-18 03:37:07 +0000 +++ john-1.7.9.6-newform/src/BSDI_fmt.c 2012-07-21 12:18:38 +0000 @@ -315,8 +315,9 @@ #if DES_BS -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; DES_bs_crypt(saved_count, count); return count; } @@ -333,8 +334,9 @@ #else -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; int index; if (current_salt != saved_salt) diff -u john-1.7.9.6-newform/src/DES_bs.h john-1.7.9.6-newform/src/DES_bs.h --- john-1.7.9.6-newform/src/DES_bs.h 2012-07-18 03:51:22 +0000 +++ john-1.7.9.6-newform/src/DES_bs.h 2012-07-21 12:38:31 +0000 @@ -149,7 +149,7 @@ /* * Another special-case version: a non-zero IV, no salts, no iterations. */ -extern int DES_bs_crypt_LM(int keys_count, struct db_salt *salt); +extern int DES_bs_crypt_LM(int *keys_count, struct db_salt *salt); /* * Converts an ASCII ciphertext to binary to be used with one of the diff -u john-1.7.9.6-newform/src/DES_bs_b.c john-1.7.9.6-newform/src/DES_bs_b.c --- john-1.7.9.6-newform/src/DES_bs_b.c 2012-07-18 09:03:48 +0000 +++ john-1.7.9.6-newform/src/DES_bs_b.c 2012-07-21 12:48:16 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 1996-2001,2003,2010,2011 by Solar Designer + * Copyright (c) 1996-2001,2003,2010-2012 by Solar Designer */ #include "arch.h" @@ -1452,8 +1452,9 @@ #define kd [0] #endif -int DES_bs_crypt_LM(int keys_count, struct db_salt *salt) +int DES_bs_crypt_LM(int *pcount, struct db_salt *salt) { + int keys_count = *pcount; #if DES_bs_mt int retval = (salt && salt->bitmap) ? 0 : keys_count; int t, n = (keys_count + (DES_BS_DEPTH - 1)) / DES_BS_DEPTH; diff -u john-1.7.9.6-newform/src/DES_fmt.c john-1.7.9.6-newform/src/DES_fmt.c --- john-1.7.9.6-newform/src/DES_fmt.c 2012-07-18 04:01:18 +0000 +++ john-1.7.9.6-newform/src/DES_fmt.c 2012-07-21 12:19:55 +0000 @@ -195,8 +195,9 @@ DES_bs_set_salt(*(ARCH_WORD *)salt); } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; DES_bs_crypt_25(count); return count; } @@ -269,8 +270,9 @@ DES_std_set_salt(*(ARCH_WORD *)salt); } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; int index; for (index = 0; index < count; index++) diff -u john-1.7.9.6-newform/src/MD5_fmt.c john-1.7.9.6-newform/src/MD5_fmt.c --- john-1.7.9.6-newform/src/MD5_fmt.c 2012-07-18 03:45:46 +0000 +++ john-1.7.9.6-newform/src/MD5_fmt.c 2012-07-21 12:20:13 +0000 @@ -195,8 +195,9 @@ return saved_key[index]; } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; MD5_std_crypt(count); return count; } diff -u john-1.7.9.6-newform/src/bench.c john-1.7.9.6-newform/src/bench.c --- john-1.7.9.6-newform/src/bench.c 2012-07-18 03:20:44 +0000 +++ john-1.7.9.6-newform/src/bench.c 2012-07-21 12:45:11 +0000 @@ -97,7 +97,7 @@ #endif struct tms buf; clock_t start_real, start_virtual, end_real, end_virtual; - int64 count; + int64 crypts; char *ciphertext; void *salt, *two_salts[2]; int index, max; @@ -166,11 +166,13 @@ start_real = times(&buf); start_virtual = buf.tms_utime + buf.tms_stime; start_virtual += buf.tms_cutime + buf.tms_cstime; - count.lo = count.hi = 0; + crypts.lo = crypts.hi = 0; index = salts; max = format->params.max_keys_per_crypt; do { + int count = max; + if (!--index) { index = salts; if (!(++current)->ciphertext) @@ -179,10 +181,10 @@ } if (salts > 1) format->methods.set_salt(two_salts[index & 1]); - (void)format->methods.crypt_all(max, NULL); - format->methods.cmp_all(binary, max); + format->methods.cmp_all(binary, + format->methods.crypt_all(&count, NULL)); - add32to64(&count, max); + add32to64(&crypts, count); #if !OS_TIMER sig_timer_emu_tick(); #endif @@ -197,7 +199,7 @@ results->real = end_real - start_real; results->virtual = end_virtual - start_virtual; - results->count = count; + results->crypts = crypts; for (index = 0; index < 2; index++) MEM_FREE(two_salts[index]); @@ -205,12 +207,12 @@ return event_abort ? "" : NULL; } -void benchmark_cps(int64 *count, clock_t time, char *buffer) +void benchmark_cps(int64 *crypts, clock_t time, char *buffer) { unsigned int cps_hi, cps_lo; int64 tmp; - tmp = *count; + tmp = *crypts; mul64by32(&tmp, clk_tck); cps_hi = div64by32lo(&tmp, time); @@ -282,8 +284,8 @@ puts("DONE"); - benchmark_cps(&results_m.count, results_m.real, s_real); - benchmark_cps(&results_m.count, results_m.virtual, s_virtual); + benchmark_cps(&results_m.crypts, results_m.real, s_real); + benchmark_cps(&results_m.crypts, results_m.virtual, s_virtual); #if !defined(__DJGPP__) && !defined(__BEOS__) printf("%s:\t%s c/s real, %s c/s virtual\n", msg_m, s_real, s_virtual); @@ -297,8 +299,8 @@ goto next; } - benchmark_cps(&results_1.count, results_1.real, s_real); - benchmark_cps(&results_1.count, results_1.virtual, s_virtual); + benchmark_cps(&results_1.crypts, results_1.real, s_real); + benchmark_cps(&results_1.crypts, results_1.virtual, s_virtual); #if !defined(__DJGPP__) && !defined(__BEOS__) printf("%s:\t%s c/s real, %s c/s virtual\n\n", msg_1, s_real, s_virtual); diff -u john-1.7.9.6-newform/src/best.c john-1.7.9.6-newform/src/best.c --- john-1.7.9.6-newform/src/best.c 2012-07-17 16:53:12 +0000 +++ john-1.7.9.6-newform/src/best.c 2012-07-21 12:49:58 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 1996-99,2003,2006,2011 by Solar Designer + * Copyright (c) 1996-99,2003,2006,2011,2012 by Solar Designer */ /* @@ -65,7 +65,7 @@ fprintf(stderr, "FAILED\n"); } else { - tmp = results.count; + tmp = results.crypts; mul64by32(&tmp, clk_tck * 10); #ifdef _OPENMP virtual = div64by32lo(&tmp, results.real); @@ -73,8 +73,8 @@ virtual = div64by32lo(&tmp, results.virtual); #endif - benchmark_cps(&results.count, results.real, s_real); - benchmark_cps(&results.count, results.virtual, s_virtual); + benchmark_cps(&results.crypts, results.real, s_real); + benchmark_cps(&results.crypts, results.virtual, s_virtual); fprintf(stderr, "%s c/s real, %s c/s virtual\n", s_real, s_virtual); diff -u john-1.7.9.6-newform/src/c3_fmt.c john-1.7.9.6-newform/src/c3_fmt.c --- john-1.7.9.6-newform/src/c3_fmt.c 2012-07-18 04:12:39 +0000 +++ john-1.7.9.6-newform/src/c3_fmt.c 2012-07-21 12:20:25 +0000 @@ -341,8 +341,9 @@ return saved_key[index]; } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; int index; #if defined(_OPENMP) && defined(__GLIBC__) diff -u john-1.7.9.6-newform/src/cracker.c john-1.7.9.6-newform/src/cracker.c --- john-1.7.9.6-newform/src/cracker.c 2012-07-18 03:19:27 +0000 +++ john-1.7.9.6-newform/src/cracker.c 2012-07-21 12:35:04 +0000 @@ -233,7 +233,7 @@ static int crk_password_loop(struct db_salt *salt) { struct db_password *pw; - int match, index; + int count, match, index; #if !OS_TIMER sig_timer_emu_tick(); @@ -244,11 +244,13 @@ if (event_pending) if (crk_process_event()) return 1; - match = crk_methods.crypt_all(crk_key_index, salt); + count = crk_key_index; + match = crk_methods.crypt_all(&count, salt); + crk_last_key = count; { int64 effective_count; - mul32by32(&effective_count, salt->count, crk_key_index); + mul32by32(&effective_count, salt->count, count); status_update_crypts(&effective_count); } @@ -298,7 +300,7 @@ if (crk_password_loop(salt)) return 1; } while ((salt = salt->next)); - crk_last_key = crk_key_index; crk_key_index = 0; + crk_key_index = 0; crk_last_salt = NULL; crk_fix_state(); @@ -401,7 +403,7 @@ char *crk_get_key2(void) { - if (crk_key_index > 1) + if (crk_key_index > 1 && crk_key_index < crk_last_key) return crk_methods.get_key(crk_key_index - 1); else if (crk_last_key > 1) diff -u john-1.7.9.6-newform/src/dummy.c john-1.7.9.6-newform/src/dummy.c --- john-1.7.9.6-newform/src/dummy.c 2012-07-18 03:39:54 +0000 +++ john-1.7.9.6-newform/src/dummy.c 2012-07-21 12:20:59 +0000 @@ -228,9 +228,9 @@ return saved_key[index]; } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { - return count; + return *pcount; } static int cmp_all(void *binary, int count) diff -u john-1.7.9.6-newform/src/formats.c john-1.7.9.6-newform/src/formats.c --- john-1.7.9.6-newform/src/formats.c 2012-07-18 03:21:02 +0000 +++ john-1.7.9.6-newform/src/formats.c 2012-07-21 12:13:15 +0000 @@ -135,8 +135,11 @@ format->methods.set_salt(salt); format->methods.set_key(current->plaintext, index); - if (format->methods.crypt_all(index + 1, NULL) != index + 1) - return "crypt_all"; + { + int count = index + 1; + if (format->methods.crypt_all(&count, NULL) != count) + return "crypt_all"; + } for (size = 0; size < PASSWORD_HASH_SIZES; size++) if (format->methods.binary_hash[size] && diff -u john-1.7.9.6-newform/src/formats.h john-1.7.9.6-newform/src/formats.h --- john-1.7.9.6-newform/src/formats.h 2012-07-18 03:40:22 +0000 +++ john-1.7.9.6-newform/src/formats.h 2012-07-21 12:36:27 +0000 @@ -163,7 +163,12 @@ /* Sets a plaintext, with index from 0 to fmt_params.max_keys_per_crypt - 1 */ void (*set_key)(char *key, int index); -/* Returns a plaintext previously set with set_key() */ +/* Returns a plaintext previously set with and potentially altered by + * set_key() (e.g., converted to all-uppercase and truncated at 7 for LM + * hashes). The plaintext may also have been generated or altered by + * crypt_all(). Depending on crypt_all() implementation, the index used here + * does not have to match an index previously used with set_key(), although + * for most formats it does. See the description of crypt_all() below. */ char *(*get_key)(int index); /* Allow the previously set keys to be dropped if that would help improve @@ -179,10 +184,21 @@ * min_keys_per_crypt keys whenever practical. * Returns the last output index for which there might be a match (against the * supplied salt's hashes) plus 1. A return value of zero indicates no match. + * Note that output indices don't have to match input indices (although they + * may and usually do). The indices passed to get_key(), get_hash[](), + * cmp_one(), and cmp_exact() must be in the 0 to crypt_all() return value + * minus 1 range, although for infrequent status reporting get_key() may also + * be called on indices previously supplied to set_key() as well as on indices + * up to the updated *count minus 1 even if they're beyond this range. + * The count passed to cmp_all() must be equal to crypt_all()'s return value. * If an implementation does not use the salt parameter or if salt is NULL * (as it may be during self-test and benchmark), the return value must always - * be exactly count. */ - int (*crypt_all)(int count, struct db_salt *salt); + * match *count the way it is after the crypt_all() call. + * The count is passed by reference and must be updated by crypt_all() if it + * computes other than the requested count (such as if it generates additional + * candidate passwords on its own). The updated count is used for c/s rate + * calculation. The return value is thus in the 0 to updated *count range. */ + int (*crypt_all)(int *count, struct db_salt *salt); /* These functions calculate a hash out of a ciphertext that has just been * generated with the crypt_all() method. To be used while cracking. */ diff -u john-1.7.9.6-newform/src/trip_fmt.c john-1.7.9.6-newform/src/trip_fmt.c --- john-1.7.9.6-newform/src/trip_fmt.c 2012-07-18 03:52:13 +0000 +++ john-1.7.9.6-newform/src/trip_fmt.c 2012-07-21 12:20:41 +0000 @@ -481,8 +481,9 @@ #endif } -static int crypt_all(int count, struct db_salt *salt) +static int crypt_all(int *pcount, struct db_salt *salt) { + int count = *pcount; crypt_link_by_salt(count); crypt_traverse_by_salt(count); return count; diff -u john-1.7.9.6-newform/src/x86-64.S john-1.7.9.6-newform/src/x86-64.S --- john-1.7.9.6-newform/src/x86-64.S 2012-07-18 07:28:35 +0000 +++ john-1.7.9.6-newform/src/x86-64.S 2012-07-21 13:08:57 +0000 @@ -1177,7 +1177,7 @@ DO_ALIGN(6) .globl DES_bs_crypt_LM DES_bs_crypt_LM: - pushq %rdi + movl (%rdi),%r8d movdqa mask01,%xmm7 movdqa mask02,%xmm8 leaq DES_bs_all_xkeys(%rip),v_ptr @@ -1332,7 +1332,7 @@ S8(B(4), B(26), B(14), B(20)) subl $1,rounds jnz DES_bs_crypt_LM_loop - popq %rax + xchgq %r8,%rax ret #endif diff -u john-1.7.9.6-newform/src/x86-mmx.S john-1.7.9.6-newform/src/x86-mmx.S --- john-1.7.9.6-newform/src/x86-mmx.S 2012-07-18 03:54:59 +0000 +++ john-1.7.9.6-newform/src/x86-mmx.S 2012-07-21 12:39:48 +0000 @@ -1385,11 +1385,12 @@ S8(B(4), B(26), B(14), B(20)) decl rounds jnz DES_bs_crypt_LM_loop + movl 8(%esp),%eax popl %esi - movl 4(%esp),%eax #ifdef EMMS emms #endif + movl (%eax),%eax ret #endif diff -u john-1.7.9.6-newform/src/x86-sse.S john-1.7.9.6-newform/src/x86-sse.S --- john-1.7.9.6-newform/src/x86-sse.S 2012-07-18 03:56:35 +0000 +++ john-1.7.9.6-newform/src/x86-sse.S 2012-07-21 12:40:11 +0000 @@ -1383,8 +1383,9 @@ S8(B(4), B(26), B(14), B(20), a6_p) decl rounds jnz DES_bs_crypt_LM_loop + movl 8(%esp),%eax popl %esi - movl 4(%esp),%eax + movl (%eax),%eax ret #endif only in patch2: unchanged: --- john-1.7.9.6/src/bench.h 2011-11-06 13:17:58 +0000 +++ john-1.7.9.6-newform/src/bench.h 2012-07-21 12:48:00 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 1996-99,2006,2009,2011 by Solar Designer + * Copyright (c) 1996-99,2006,2009,2011,2012 by Solar Designer */ /* @@ -23,8 +23,8 @@ struct bench_results { /* Elapsed real and processor time */ clock_t real, virtual; -/* Number of passwords tried */ - int64 count; +/* Number of ciphertexts computed */ + int64 crypts; }; /* @@ -54,7 +54,7 @@ extern char *benchmark_format(struct fmt /* * Converts benchmarked c/s into an ASCII string. */ -extern void benchmark_cps(int64 *count, clock_t time, char *buffer); +extern void benchmark_cps(int64 *crypts, clock_t time, char *buffer); /* * Benchmarks all the registered cracking algorithms and prints the results