Skip to content

Optimize removal of current salt during cracking - #6046

Open
timc995 wants to merge 1 commit into
openwall:bleeding-jumbofrom
timc995:optimize-salt-removal
Open

timc995 wants to merge 1 commit into
openwall:bleeding-jumbofrom
timc995:optimize-salt-removal

Conversation

@timc995

@timc995 timc995 commented Oct 1, 2026

Copy link
Copy Markdown

crk_remove_salt() currently searches the salt list from the head each time
a salt is removed. With very large numbers of unique salts and a candidate
that cracks many of them, this produces near-quadratic behavior.

This change tracks the link pointing to the currently processed salt in
crk_salt_loop(), allowing the normal current-salt removal path to unlink it
in O(1). The existing list search remains as a fallback for other callers.

I encountered this with a dynamic format where each username effectively
forms a unique salt.

Benchmarks:

~500k unique salts, 2,783 cracks

  • before: 7m45s
  • after: 1m07s

~1M unique salts, 5,459 cracks

  • before: 29m38s
  • after: 2m11s

~1M zero-hit baseline

  • about 2m14s

Correctness check:

  • patched and unpatched 1M runs both produced 5,459 cracks
  • sorted pot files were identical (diff produced no output)

Comment thread src/cracker.c
@solardiz

solardiz commented Oct 1, 2026

Copy link
Copy Markdown
Member

Wow. Thanks. I wonder how this remained that way for so long. I guess we were primarily testing crack removal speed with large unsalted hash lists, and secondarily perhaps with descrypt where it's 4096 salts.

@timc995 timc995 closed this Oct 1, 2026
@timc995
timc995 force-pushed the optimize-salt-removal branch from cae9b59 to 99d3af8 Compare October 1, 2026 20:12
@timc995 timc995 reopened this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants