>From 3e07602cdc709efa55cf04aff5100a369f69e70c Mon Sep 17 00:00:00 2001 From: magnum Date: Thu, 26 Sep 2013 12:33:21 +0200 Subject: [PATCH] External mode node distribution: Avoid modulo operation. --- src/external.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/external.c b/src/external.c index cf1b395..8fce6a3 100644 --- a/src/external.c +++ b/src/external.c @@ -227,6 +227,7 @@ void do_external_crack(struct db_main *db) { unsigned char *internal; c_int *external; + int my_words, their_words; log_event("Proceeding with external mode: %.100s", ext_mode); @@ -245,20 +246,38 @@ void do_external_crack(struct db_main *db) crk_init(db, fix_state, NULL); + my_words = options.node_max - options.node_min + 1; + their_words = options.node_min - 1; + + if (seq) { +/* Restored session. seq is right after a word we've actually used. */ + int for_node = seq % options.node_count + 1; + if (for_node < options.node_min || + for_node > options.node_max) { +/* We assume that seq is at the beginning of other nodes' block */ + their_words = options.node_count - my_words; + } else { + my_words = options.node_max - for_node + 1; + their_words = 0; + } + } + do { c_execute_fast(f_generate); if (!ext_word[0]) break; -/* - * The skipping of other nodes' candidate passwords can be optimized, such as - * to avoid the modulo division like it's done for dist_words in wordlist.c. - */ if (options.node_count) { - int for_node = seq++ % options.node_count + 1; - if (for_node < options.node_min || - for_node > options.node_max) + seq++; + if (their_words) { + their_words--; continue; + } + if (--my_words == 0) { + my_words = + options.node_max - options.node_min + 1; + their_words = options.node_count - my_words; + } } if (f_filter) { -- 1.8.1.2