Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 25 Jan 2015 12:50:36 +0530
From: Sayantan Datta <std2048@...il.com>
To: john-dev <john-dev@...ts.openwall.com>
Subject: Re: Redesign Self-test for implementing compare on device.

On Sun, Jan 25, 2015 at 7:35 AM, magnum <john.magnum@...hmail.com> wrote:

> Solar,
>
> On 2015-01-18 15:28, Sayantan Datta wrote:
> > First, when salt is NULL, why does the return value of crypt_all() has
> > match *count the way it is after crypt_all() call ? Can't we remove this
> > restriction ? Here's the previously discussed idea on this issue:
> >
> https://github.com/magnumripper/JohnTheRipper/issues/1030#issuecomment-70404396
>
> Perhaps that wording in formats.h is merely reflecting the current
> self-test's requirement? I can't see any reason why we couldn't lift
> that restriction. Can you? I asked Sayantan to bring this up on the ML
> to avoid us making decisions you would later reject or dislike.
>
> magnum
>
>
Here's is a patch of the reworked self-test. It is backwards compatible and
takes into account the newer issues.

Regards,
Sayantan

[ CONTENT OF TYPE text/html SKIPPED ]

diff --git a/src/formats.c b/src/formats.c
index 377d07f..7dd91ae 100644
--- a/src/formats.c
+++ b/src/formats.c
@@ -523,6 +523,7 @@ static char *fmt_self_test_body(struct fmt_main *format,
 		if (index == 0)
 			format->methods.clear_keys();
 		fmt_set_key(current->plaintext, index);
+		fprintf(stderr, "Self test:%s %d\n", current->plaintext, index);
 
 #if !defined(BENCH_BUILD) && (defined(HAVE_OPENCL) || defined(HAVE_CUDA))
 		advance_cursor();
@@ -530,35 +531,40 @@ static char *fmt_self_test_body(struct fmt_main *format,
 		{
 			int count = index + 1;
 			int match = format->methods.crypt_all(&count, NULL);
-/* If salt is NULL, the return value must always match *count the way it is
- * after the crypt_all() call. */
-			if (match != count)
-				return "crypt_all";
-		}
-		for (size = 0; size < PASSWORD_HASH_SIZES; size++)
-		if (format->methods.binary_hash[size] &&
-		    format->methods.get_hash[size](index) !=
-		    format->methods.binary_hash[size](binary)) {
-			sprintf(s_size, "get_hash[%d](%d)", size, index);
-			return s_size;
-		}
 
-		if (!format->methods.cmp_all(binary, index + 1)) {
-			sprintf(s_size, "cmp_all(%d)", index + 1);
-			return s_size;
-		}
-		if (!format->methods.cmp_one(binary, index)) {
-			sprintf(s_size, "cmp_one(%d)", index);
-			return s_size;
-		}
-		if (!format->methods.cmp_exact(ciphertext, index)) {
-			sprintf(s_size, "cmp_exact(%d)", index);
-			return s_size;
-		}
-		if (strncmp(format->methods.get_key(index), plaintext,
-			format->params.plaintext_length)) {
-			sprintf(s_size, "get_key(%d)", index);
-			return s_size;
+			if (!format->methods.cmp_all(binary, match)) {
+				sprintf(s_size, "cmp_all(%d)", match);
+				return s_size;
+			}
+
+			for (i = 0; i < match; i++) {
+				if (format->methods.cmp_one(binary, i))
+					break;
+			}
+
+			if (i == match) {
+				sprintf(s_size, "cmp_one(%d)", i);
+				return s_size;
+			}
+
+			for (size = 0; size < PASSWORD_HASH_SIZES; size++)
+				if (format->methods.binary_hash[size] &&
+				    format->methods.get_hash[size](i) !=
+				    format->methods.binary_hash[size](binary)) {
+					sprintf(s_size, "get_hash[%d](%d)", size, i);
+					return s_size;
+			}
+
+			if (!format->methods.cmp_exact(ciphertext, i)) {
+				sprintf(s_size, "cmp_exact(%d)", i);
+				return s_size;
+			}
+
+			if (strncmp(format->methods.get_key(i), plaintext,
+				format->params.plaintext_length)) {
+				sprintf(s_size, "get_key(%d)", i);
+				return s_size;
+			}
 		}
 
 /* Remove some old keys to better test cmp_all() */

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ