mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #2666] descrypt-opencl should allow for use of a generic kernel (not force per-salt kernels) #1726
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#1726
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @solardiz on GitHub (Aug 14, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2666
Often it is important to minimize startup time rather than maximize runtime performance. Right now, descrypt-opencl always(?) uses per-salt kernels, which typically take up to ~2 hours to build from source and up to tens of minutes to "build from binary". It should be possible to request use a generic kernel instead - a kernel that would run slower (needing pointer indirection for the salts), but would only be built once. We used to have that, but lost it since. We should reintroduce it as an option (maybe even as the default), and should print a "Note: ..." to the user indicating how to enable the other behavior.
IIRC, previously the HARDCODE_SALT setting controlled this, but now it's at 0 yet we do hard-code salts into the multiple kernels.
Now there's also the USE_BASIC_KERNEL setting, currently only enabled when the device is a CPU, or on OS X. I thought that maybe this was what we needed. I tried setting "--device" to a CPU to test it, but first I got unrealistically good speeds for a CPU (200M+ c/s on a machine that only does under 80M with C+intrinsics) with AMD OpenCL and a segfault with Intel's. Restarting these, I also got an instant segfault with AMD's. So this is actually unreliable at least with those (outdated versions of) OpenCL backends. Trying it on NVIDIA GPU (by forcing "#define USE_BASIC_KERNEL 1" in the source), I got:
I'd rather leave (re)implementing this to someone familiar with the code. ;-)
@magnumripper commented on GitHub (Nov 22, 2025):
https://github.com/openwall/john/pull/5902#issuecomment-3565101416
For defaulting to revert to bs_b when more than n salts are loaded, we need a value of n. Actually counting missing (not cached yet) kernels is a great idea except it's probably somewhat complicated. Making it even more complicated: For eg. a hundred salts even cached binaries
willmay be slow. So maybe cached binaries (or some cached binaries) should merely increase n accordingly? A rough assumption could be that a cached binary takes half the time to build (edit: cached is sometimes much faster, but it depends on runtime).For a starter, I guess we could simply always print a notice when more than 10 salts are loaded (the current threshold for printing that "Building %d per-salt kernels, one dot per three salts" at all, is 10). I can take care of that. So what exact message should I add? Something like "Notice: Setting environment variable JOHN_DES_KERNEL=bs_b will speed up loading at expense of slower cracking.".
@solardiz commented on GitHub (Nov 22, 2025):
I agree that's a good start, and maybe all we need long-term as well because any magic like what I had suggested would be complicated and confusing. Your suggested message looks fine to me.
However,
JOHN_DES_KERNEL=bs_bis unnecessarily cryptic, exposing implementation detail/naming to the user, and is specific to just this one format. Maybe we should use a uniform way of altering formats' configuration injohn.conf(we already have a few settings like this in there), and refer to that in the message.@magnumripper commented on GitHub (Nov 23, 2025):
Oh and BTW on my 5080, our DEScrypt-opencl does 1113M/1091M c/s while hashcat somehow manages to reach 4389.5 MH/sEdit: I accidentally ran john with bs_b at first. JtR and Hashcat are almost exactly as fast, at ~4388M c/s but Hashcat does it without salt-specific kernels. If we can achieve performance without salt-specific kernels, this problem becomes obsolete...
@magnumripper commented on GitHub (Nov 23, 2025):
And for LM:
@solardiz commented on GitHub (Nov 23, 2025):
Someone should implement the loop rolling as mentioned in #1908, I guess. Then per-salt kernels may probably provide a further optional speedup. (Even on CPU, I estimate that a ~7% speedup is possible through code specialization per salt. We just don't bother for now.)
@magnumripper commented on GitHub (Dec 5, 2025):
I implemented such rolling (if I understood it correctly, looking at Hashcat's current kernel) and it made no difference at all. But this was on 5080 using a recent driver.
@magnumripper commented on GitHub (Dec 5, 2025):
Looking at it again, I'm not sure I did anything right at all. In https://github.com/openwall/john/issues/1908#issuecomment-2131311023 you said "Looking at our code now, we have two kinds of kernels - with fully unrolled DES and with 2 rounds unrolled (which is quite natural as it allows for fixed indices to be used). We do not have a rolled version. We should probably implement that.".
I am completely lost - the one with 2 rounds unrolled is otherwise rolled, no? So that would be exactly what Atom said? This all is apparently above my skills. I'm not even sure what exactly is a round - is s1 a round or is it s1..s8 together? Or is it even H1+H2?