Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150507142449.GA12369@openwall.com>
Date: Thu, 7 May 2015 17:24:49 +0300
From: Solar Designer <solar@...nwall.com>
To: john-dev@...ts.openwall.com
Subject: Re: get_binary_*() and get_hash_*() methods

Aleksey,

On Thu, May 07, 2015 at 05:11:34PM +0300, Solar Designer wrote:
> On Thu, May 07, 2015 at 04:17:00PM +0300, Aleksey Cherepanov wrote:
> > May cmp_one() be called without cmp_all()?
> 
> You should assume that it may, yet you may choose to optimize for the
> case when cmp_all() is called first.

As you probably already figured out, cmp_all() is in fact skipped when
bitmaps and hash tables are in use.  Please see two versions of the loop
in crk_password_loop():

	if (!salt->bitmap) {
		pw = salt->list;
		do {
			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)) {
				if (crk_process_guess(salt, pw, index))
					return 1;
				else
					break;
			}
		} while ((pw = pw->next));
	} else
	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)))) {
			pw = salt->hash[hash >> PASSWORD_HASH_SHR];
			do {
				if (crk_methods.cmp_one(pw->binary, index))
				if (crk_methods.cmp_exact(crk_methods.source(
				    pw->source, pw->binary), index))
				if (crk_process_guess(salt, pw, index))
					return 1;
			} while ((pw = pw->next_hash));
		}
	}

Alexander

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.