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 01:45:58 +0000 +++ john-1.7.9.6-newform/src/AFS_fmt.c 2012-07-18 04:12:23 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 1996-2001 by Solar Designer + * Copyright (c) 1996-2001,2012 by Solar Designer */ #include @@ -281,7 +281,7 @@ return buffer[index].key; } -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { int index, pos, length; char xor[8]; @@ -378,6 +378,8 @@ buffer[index].aligned.binary[0] = block[0] | 0x01010101; buffer[index].aligned.binary[1] = block[1] | 0x01010101; } + + return count; } static int cmp_all(void *binary, int count) 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 01:46:04 +0000 +++ john-1.7.9.6-newform/src/BF_fmt.c 2012-07-18 04:12:29 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 1996-2001,2008,2010,2011 by Solar Designer + * Copyright (c) 1996-2001,2008,2010-2012 by Solar Designer */ #include @@ -225,7 +225,7 @@ return saved_key[index]; } -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { if (keys_mode != saved_salt.subtype) { int i; @@ -237,6 +237,8 @@ } BF_std_crypt(&saved_salt, count); + + return count; } static int cmp_all(void *binary, int count) 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 01:46:06 +0000 +++ john-1.7.9.6-newform/src/BSDI_fmt.c 2012-07-18 03:37:07 +0000 @@ -315,9 +315,10 @@ #if DES_BS -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { DES_bs_crypt(saved_count, count); + return count; } static int cmp_one(void *binary, int index) @@ -332,7 +333,7 @@ #else -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { int index; @@ -344,6 +345,8 @@ for (index = 0; index < count; index++) DES_std_crypt(buffer[index].KS, buffer[index].binary); + + return count; } static int cmp_all(void *binary, int count) 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 01:46:10 +0000 +++ john-1.7.9.6-newform/src/DES_fmt.c 2012-07-18 04:01:18 +0000 @@ -72,22 +72,22 @@ #endif -#if DES_BS - -#if DES_bs_mt +#if DES_BS && DES_bs_mt struct fmt_main fmt_DES; #endif static void init(struct fmt_main *self) { +#if DES_BS DES_bs_init(0, DES_bs_cpt); #if DES_bs_mt fmt_DES.params.min_keys_per_crypt = DES_bs_min_kpc; fmt_DES.params.max_keys_per_crypt = DES_bs_max_kpc; #endif -} - +#else + DES_std_init(); #endif +} static int valid(char *ciphertext, struct fmt_main *self) { @@ -195,6 +195,12 @@ DES_bs_set_salt(*(ARCH_WORD *)salt); } +static int crypt_all(int count, struct db_salt *salt) +{ + DES_bs_crypt_25(count); + return count; +} + static int cmp_one(void *binary, int index) { return DES_bs_cmp_one((ARCH_WORD_32 *)binary, 32, index); @@ -263,13 +269,15 @@ DES_std_set_salt(*(ARCH_WORD *)salt); } -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { int index; for (index = 0; index < count; index++) DES_std_crypt(buffer[index].aligned.data.KS, buffer[index].aligned.data.binary); + + return count; } static int cmp_all(void *binary, int count) @@ -364,11 +372,7 @@ #endif tests }, { -#if DES_BS init, -#else - DES_std_init, -#endif fmt_default_done, fmt_default_reset, fmt_default_prepare, @@ -400,11 +404,7 @@ #endif get_key, fmt_default_clear_keys, -#if DES_BS - DES_bs_crypt_25, -#else crypt_all, -#endif { get_hash_0, get_hash_1, 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 01:46:15 +0000 +++ john-1.7.9.6-newform/src/MD5_fmt.c 2012-07-18 03:45:46 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 1996-2001,2008,2010,2011 by Solar Designer + * Copyright (c) 1996-2001,2008,2010-2012 by Solar Designer */ #include @@ -195,6 +195,12 @@ return saved_key[index]; } +static int crypt_all(int count, struct db_salt *salt) +{ + MD5_std_crypt(count); + return count; +} + static int cmp_all(void *binary, int count) { #if MD5_std_mt @@ -269,7 +275,7 @@ set_key, get_key, fmt_default_clear_keys, - MD5_std_crypt, + crypt_all, { get_hash_0, get_hash_1, 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-17 16:51:27 +0000 +++ john-1.7.9.6-newform/src/bench.c 2012-07-18 03:20:44 +0000 @@ -179,7 +179,7 @@ } if (salts > 1) format->methods.set_salt(two_salts[index & 1]); - format->methods.crypt_all(max); + (void)format->methods.crypt_all(max, NULL); format->methods.cmp_all(binary, max); add32to64(&count, max); 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 01:46:18 +0000 +++ john-1.7.9.6-newform/src/c3_fmt.c 2012-07-18 04:12:39 +0000 @@ -1,6 +1,6 @@ /* * This file is part of John the Ripper password cracker, - * Copyright (c) 2009-2011 by Solar Designer + * Copyright (c) 2009-2012 by Solar Designer * * Generic crypt(3) support, as well as support for glibc's crypt_r(3) and * Solaris' MT-safe crypt(3C) with OpenMP parallelization. @@ -341,7 +341,7 @@ return saved_key[index]; } -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { int index; @@ -393,6 +393,8 @@ strnzcpy(crypt_out[index], crypt(saved_key[index], saved_salt), BINARY_SIZE); #endif + + return count; } static int cmp_all(void *binary, int count) 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 01:59:45 +0000 +++ john-1.7.9.6-newform/src/cracker.c 2012-07-18 03:19:27 +0000 @@ -233,7 +233,7 @@ static int crk_password_loop(struct db_salt *salt) { struct db_password *pw; - int index; + int match, index; #if !OS_TIMER sig_timer_emu_tick(); @@ -244,7 +244,7 @@ if (event_pending) if (crk_process_event()) return 1; - crk_methods.crypt_all(crk_key_index); + match = crk_methods.crypt_all(crk_key_index, salt); { int64 effective_count; @@ -252,11 +252,14 @@ status_update_crypts(&effective_count); } + if (!match) + return 0; + if (!salt->bitmap) { pw = salt->list; do { - if (crk_methods.cmp_all(pw->binary, crk_key_index)) - for (index = 0; index < crk_key_index; index++) + if (crk_methods.cmp_all(pw->binary, match)) + for (index = 0; index < match; index++) if (crk_methods.cmp_one(pw->binary, index)) if (crk_methods.cmp_exact(crk_methods.source( pw->source, pw->binary), index)) { @@ -267,7 +270,7 @@ } } while ((pw = pw->next)); } else - for (index = 0; index < crk_key_index; index++) { + for (index = 0; index < match; index++) { int hash = salt->index(index); if (salt->bitmap[hash / (sizeof(*salt->bitmap) * 8)] & (1U << (hash % (sizeof(*salt->bitmap) * 8)))) { 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 01:46:22 +0000 +++ john-1.7.9.6-newform/src/dummy.c 2012-07-18 03:39:54 +0000 @@ -228,8 +228,9 @@ return saved_key[index]; } -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { + return count; } 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 01:48:21 +0000 +++ john-1.7.9.6-newform/src/formats.c 2012-07-18 03:21:02 +0000 @@ -135,7 +135,8 @@ format->methods.set_salt(salt); format->methods.set_key(current->plaintext, index); - format->methods.crypt_all(index + 1); + if (format->methods.crypt_all(index + 1, NULL) != index + 1) + 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 01:44:33 +0000 +++ john-1.7.9.6-newform/src/formats.h 2012-07-18 03:40:22 +0000 @@ -13,10 +13,11 @@ #include "params.h" /* - * The reset() format method accepts a pointer to struct db_main, yet we can't - * just include loader.h here because that would be a circular dependency. + * Some format methods accept pointers to these, yet we can't just include + * loader.h here because that would be a circular dependency. */ struct db_main; +struct db_salt; /* * Format property flags. @@ -170,10 +171,18 @@ * a call to clear_keys() the keys are undefined. */ void (*clear_keys)(void); -/* Calculates the ciphertexts for given salt and plaintexts. This may - * always calculate at least min_keys_per_crypt ciphertexts regardless of - * the requested count, for some formats. */ - void (*crypt_all)(int count); +/* Computes the ciphertexts for given salt and plaintexts. + * For implementation reasons, this may happen to always compute at least + * min_keys_per_crypt ciphertexts even if the requested count is lower, + * although it is preferable for implementations to obey the count whenever + * practical and also for callers not to call crypt_all() with fewer than + * 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. + * 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); /* 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 01:46:20 +0000 +++ john-1.7.9.6-newform/src/trip_fmt.c 2012-07-18 03:52:13 +0000 @@ -481,10 +481,11 @@ #endif } -static void crypt_all(int count) +static int crypt_all(int count, struct db_salt *salt) { crypt_link_by_salt(count); crypt_traverse_by_salt(count); + return count; } #if DES_BS only in patch2: unchanged: --- john-1.7.9.6/src/DES_bs.h 2012-07-14 13:36:44 +0000 +++ john-1.7.9.6-newform/src/DES_bs.h 2012-07-18 03:51:22 +0000 @@ -13,6 +13,9 @@ #include "arch.h" #include "common.h" +/* For struct db_salt */ +#include "loader.h" + #ifndef DES_BS_ALGORITHM_NAME #define DES_BS_ALGORITHM_NAME ARCH_BITS_STR "/" ARCH_BITS_STR " BS" #endif @@ -146,7 +149,7 @@ extern void DES_bs_crypt_25(int keys_cou /* * Another special-case version: a non-zero IV, no salts, no iterations. */ -extern void DES_bs_crypt_LM(int keys_count); +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 only in patch2: unchanged: --- john-1.7.9.6/src/DES_bs_b.c 2011-11-19 02:57:47 +0000 +++ john-1.7.9.6-newform/src/DES_bs_b.c 2012-07-18 03:51:00 +0000 @@ -1452,7 +1452,7 @@ static MAYBE_INLINE void DES_bs_finalize #define kd [0] #endif -void DES_bs_crypt_LM(int keys_count) +int DES_bs_crypt_LM(int keys_count, struct db_salt *salt) { #if DES_bs_mt int t, n = (keys_count + (DES_BS_DEPTH - 1)) / DES_BS_DEPTH; @@ -1559,5 +1559,7 @@ void DES_bs_crypt_LM(int keys_count) k += 96; } while (--rounds); } + + return keys_count; } #endif only in patch2: unchanged: --- john-1.7.9.6/src/x86-64.S 2011-11-23 04:41:37 +0000 +++ john-1.7.9.6-newform/src/x86-64.S 2012-07-18 07:28:35 +0000 @@ -1,7 +1,7 @@ /* * This file contains the core of a bitslice DES implementation for x86-64/SSE2. * It is part of John the Ripper password cracker, - * Copyright (c) 2000-2001,2005,2006,2008,2011 by Solar Designer + * Copyright (c) 2000-2001,2005,2006,2008,2011,2012 by Solar Designer * Redistribution and use in source and binary forms, with or without * modification, are permitted. (This is a heavily cut-down "BSD license".) * @@ -1177,6 +1177,7 @@ DES_bs_finalize_keys_expand_loop: DO_ALIGN(6) .globl DES_bs_crypt_LM DES_bs_crypt_LM: + pushq %rdi movdqa mask01,%xmm7 movdqa mask02,%xmm8 leaq DES_bs_all_xkeys(%rip),v_ptr @@ -1331,6 +1332,7 @@ DES_bs_crypt_LM_loop: S8(B(4), B(26), B(14), B(20)) subl $1,rounds jnz DES_bs_crypt_LM_loop + popq %rax ret #endif only in patch2: unchanged: --- john-1.7.9.6/src/x86-mmx.S 2011-10-21 10:42:30 +0000 +++ john-1.7.9.6-newform/src/x86-mmx.S 2012-07-18 03:54:59 +0000 @@ -1,7 +1,7 @@ /* * This file contains the core of a bitslice DES implementation for x86/MMX. * It is part of John the Ripper password cracker, - * Copyright (c) 2000-2001,2005,2006,2008,2011 by Solar Designer + * Copyright (c) 2000-2001,2005,2006,2008,2011,2012 by Solar Designer * Redistribution and use in source and binary forms, with or without * modification, are permitted. (This is a heavily cut-down "BSD license".) * @@ -1386,6 +1386,7 @@ DES_bs_crypt_LM_loop: decl rounds jnz DES_bs_crypt_LM_loop popl %esi + movl 4(%esp),%eax #ifdef EMMS emms #endif only in patch2: unchanged: --- john-1.7.9.6/src/x86-sse.S 2011-10-21 10:42:30 +0000 +++ john-1.7.9.6-newform/src/x86-sse.S 2012-07-18 03:56:35 +0000 @@ -1,7 +1,7 @@ /* * This file contains the core of a bitslice DES implementation for x86/SSE2. * It is part of John the Ripper password cracker, - * Copyright (c) 2000-2001,2005,2006,2008,2011 by Solar Designer + * Copyright (c) 2000-2001,2005,2006,2008,2011,2012 by Solar Designer * Redistribution and use in source and binary forms, with or without * modification, are permitted. (This is a heavily cut-down "BSD license".) * @@ -1384,6 +1384,7 @@ DES_bs_crypt_LM_loop: decl rounds jnz DES_bs_crypt_LM_loop popl %esi + movl 4(%esp),%eax ret #endif