[GH-ISSUE #1939] fmt_self_test is required for lm-opencl/mask #1290

Closed
opened 2026-10-14 03:42:55 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @crioux on GitHub (Dec 7, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1939

Originally assigned to: @magnumripper on GitHub.

I noted that self-tests were always running even when i turned on 'skip-self-tests'. Yes, I know they are good hygeine and I should not turn them off, but in the case of LM-opencl, they are slow and impact performance. So I wanted to turn them off. I found that things acted differently when I did.

If I apply this patch, things stop working correctly with --skip-self-tests:

@@ -1606,12 +1616,16 @@ static void john_run(void)
                }

                if (!(options.flags & FLG_STDOUT)) {
-                       char *where = fmt_self_test(database.format, &database);
-                       if (where) {
-                               fprintf(stderr, "Self test failed (%s)\n",
-                                   where);
-                               error();
+                       if (!(options.flags & FLG_NOTESTS))
+                       {
+                               char *where = fmt_self_test(database.format, &database);
+                               if (where) {
+                                       fprintf(stderr, "Self test failed (%s)\n",
+                                       where);
+                                       error();
+                               }
                        }
+
                        trigger_reset = 1;
                        log_init(LOG_NAME, options.activepot,
                                 options.session);

Specifically, without this patch, things work as expected:

john  --skip-self-tests --internal-codepage=ascii --mask=?a --format=lm-opencl --devices=0 --min-length=3 --max-length=7 pwfile2.txt
Device 0: Tahiti [AMD Radeon R9 200 / HD 7900 Series]
Using default input encoding: UTF-8
Loaded 21 password hashes with no different salts (LM-opencl [DES BS OpenCL])
Remaining 18 password hashes with no different salts
MMMMM            (fivem)
MMMM             (fourm)
MMM              (threem)
ZZZZ             (fourz)

But, with the patch (which only removes one call to fmt_self_test), this happens instead (after removing john.pot):

john --skip-self-tests --internal-codepage=ascii --mask=?a --format=lm-opencl --devices=0 --min-length=3 --max-length=7 pwfile2.txt
Device 0: Tahiti [AMD Radeon R9 200 / HD 7900 Series]
Using default input encoding: UTF-8
0g 0:00:00:13 5.10% (7) (ETA: 11:36:43) 0g/s 36865Mp/s 5149Mc/s 108135MC/s ##B4PJI..##B4PJI
0g 0:00:00:15 6.03% (7) (ETA: 11:36:35) 0g/s 36609Mp/s 5113Mc/s 107384MC/s ##[\RNO..##[\RNO
0g 0:00:00:15 6.03% (7) (ETA: 11:36:35) 0g/s 36609Mp/s 5113Mc/s 107384MC/s ##[\RNO..##[\RNO
Session aborted
Loaded 21 password hashes with no different salts (LM-opencl [DES BS OpenCL])

Note that it is skipping right past the iteration and going to 7 characters right away. Not sure what this has to do with the self test, but it seems awfully odd that dropping a call to fmt_self_test would change the cracking behavior.

Originally created by @crioux on GitHub (Dec 7, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1939 Originally assigned to: @magnumripper on GitHub. I noted that self-tests were always running even when i turned on 'skip-self-tests'. Yes, I know they are good hygeine and I should not turn them off, but in the case of LM-opencl, they are slow and impact performance. So I wanted to turn them off. I found that things acted differently when I did. If I apply this patch, things stop working correctly with --skip-self-tests: ``` @@ -1606,12 +1616,16 @@ static void john_run(void) } if (!(options.flags & FLG_STDOUT)) { - char *where = fmt_self_test(database.format, &database); - if (where) { - fprintf(stderr, "Self test failed (%s)\n", - where); - error(); + if (!(options.flags & FLG_NOTESTS)) + { + char *where = fmt_self_test(database.format, &database); + if (where) { + fprintf(stderr, "Self test failed (%s)\n", + where); + error(); + } } + trigger_reset = 1; log_init(LOG_NAME, options.activepot, options.session); ``` Specifically, without this patch, things work as expected: ``` john --skip-self-tests --internal-codepage=ascii --mask=?a --format=lm-opencl --devices=0 --min-length=3 --max-length=7 pwfile2.txt Device 0: Tahiti [AMD Radeon R9 200 / HD 7900 Series] Using default input encoding: UTF-8 Loaded 21 password hashes with no different salts (LM-opencl [DES BS OpenCL]) Remaining 18 password hashes with no different salts MMMMM (fivem) MMMM (fourm) MMM (threem) ZZZZ (fourz) ``` But, with the patch (which only removes one call to fmt_self_test), this happens instead (after removing john.pot): ``` john --skip-self-tests --internal-codepage=ascii --mask=?a --format=lm-opencl --devices=0 --min-length=3 --max-length=7 pwfile2.txt Device 0: Tahiti [AMD Radeon R9 200 / HD 7900 Series] Using default input encoding: UTF-8 0g 0:00:00:13 5.10% (7) (ETA: 11:36:43) 0g/s 36865Mp/s 5149Mc/s 108135MC/s ##B4PJI..##B4PJI 0g 0:00:00:15 6.03% (7) (ETA: 11:36:35) 0g/s 36609Mp/s 5113Mc/s 107384MC/s ##[\RNO..##[\RNO 0g 0:00:00:15 6.03% (7) (ETA: 11:36:35) 0g/s 36609Mp/s 5113Mc/s 107384MC/s ##[\RNO..##[\RNO Session aborted Loaded 21 password hashes with no different salts (LM-opencl [DES BS OpenCL]) ``` Note that it is skipping right past the iteration and going to 7 characters right away. Not sure what this has to do with the self test, but it seems awfully odd that dropping a call to fmt_self_test would change the cracking behavior.
bsakaguchi 2026-10-14 03:42:55 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@crioux commented on GitHub (Dec 7, 2015):

yes, i understand that fmt_self_tests INTERNALLY checks for FLG_NOTESTS, but it does so after it already does all the autotuning. The autotuning is performed more than once in this case, and that's what I'm trying to avoid. However, it would seem this code path is somehow required for correct behavior. Hence, it's not really the self test itself that is the problem, but some weird requirement that fmt_self_test is run in order to have things work at all. Not trying to understand this one right now without more context :)

<!-- gh-comment-id:162636515 --> @crioux commented on GitHub (Dec 7, 2015): yes, i understand that fmt_self_tests INTERNALLY checks for FLG_NOTESTS, but it does so after it already does all the autotuning. The autotuning is performed more than once in this case, and that's what I'm trying to avoid. However, it would seem this code path is somehow required for correct behavior. Hence, it's not really the self test itself that is the problem, but some weird requirement that fmt_self_test is run in order to have things work at all. Not trying to understand this one right now without more context :)
Author
Owner

@magnumripper commented on GitHub (Dec 7, 2015):

I believe the problem is in the format, not in core. I'm about to apply some heavy changes that make all these problems easier to fix, I just need to regression test it better.

<!-- gh-comment-id:162704694 --> @magnumripper commented on GitHub (Dec 7, 2015): I believe the problem is in the format, not in core. I'm about to apply some heavy changes that make all these problems easier to fix, I just need to regression test it better.
Author
Owner

@crioux commented on GitHub (Jun 3, 2016):

Another data point on this one. If you create a four character long LM password (such as 'AAAA'):

foura:1002:DCF9CAA6DBC2F2DFAAD3B435B51404EE:NO PASSWORD*********************:::

And then add that one word to a dictionary file, and run the following command line, it finds the password:

john --wordlist=g:\temp\four.dic g:\temp\pwfile_busted.txt --format=LM-opencl --encoding=ascii --nolog --verbosity=5

but with skip-self-tests, it does not.

john --wordlist=g:\temp\four.dic g:\temp\pwfile_busted.txt --format=LM-opencl --encoding=ascii --nolog --verbosity=5 --skip-self-tests
<!-- gh-comment-id:223692535 --> @crioux commented on GitHub (Jun 3, 2016): Another data point on this one. If you create a four character long LM password (such as 'AAAA'): ``` foura:1002:DCF9CAA6DBC2F2DFAAD3B435B51404EE:NO PASSWORD*********************::: ``` And then add that one word to a dictionary file, and run the following command line, it finds the password: ``` john --wordlist=g:\temp\four.dic g:\temp\pwfile_busted.txt --format=LM-opencl --encoding=ascii --nolog --verbosity=5 ``` but with skip-self-tests, it does not. ``` john --wordlist=g:\temp\four.dic g:\temp\pwfile_busted.txt --format=LM-opencl --encoding=ascii --nolog --verbosity=5 --skip-self-tests ```
Author
Owner

@crioux commented on GitHub (Jun 3, 2016):

The weird part, is that for six and seven character long LM-opencl passwords, it seems to work. Not sure how that's a thing. If you use regular LM (no gpu), it works fine without self tests.

<!-- gh-comment-id:223693067 --> @crioux commented on GitHub (Jun 3, 2016): The weird part, is that for six and seven character long LM-opencl passwords, it seems to work. Not sure how that's a thing. If you use regular LM (no gpu), it works fine without self tests.
Author
Owner

@magnumripper commented on GitHub (Aug 18, 2016):

This issue is obsolete. Latest code only calls reset() once if --skip-self-tests is used.

<!-- gh-comment-id:240845673 --> @magnumripper commented on GitHub (Aug 18, 2016): This issue is obsolete. Latest code only calls reset() once if --skip-self-tests is used.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1290
No description provided.