Skip to content

Iterated sha1#5899

Merged
magnumripper merged 2 commits intoopenwall:bleeding-jumbofrom
magnumripper:iterated-sha1
Nov 19, 2025
Merged

Iterated sha1#5899
magnumripper merged 2 commits intoopenwall:bleeding-jumbofrom
magnumripper:iterated-sha1

Conversation

@magnumripper
Copy link
Member

Add iterated-sha1 format(s). Optionally salted ($s.$p) and optionally iterated. Actually they can even do raw-sha1 if formatted right!

salted-sha1 and SSHA512 are ($p.$s)
XSHA and XSHA512 are ($s.$p)
Copy link
Member

@solardiz solardiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a full review, but I skimmed.

Where are these hashes used? Why specifically 1024 iterations? Do we need default iteration counts at all, or should we require the field?

This is optionally salted ($s.$p) and optionally iterated.

Canonical ciphertext: $sisha1$iter$<salt><hash> where salt length can be
1-16 bytes and inferred from total length (note: no field delimiter).

Raw ciphertext: The last of the ciphertext is always the SHA-1 hash and
anything before that is the salt. 4 bytes salt defaults to 1 iteration
(this is XSHA). Other salt lengths default to 1024 iterations.

No salt still means 1024 iterations but you can force this format to
do single raw sha1 using $sisha1$1$<hash> because, well, why not?
@magnumripper magnumripper merged commit 82ec652 into openwall:bleeding-jumbo Nov 19, 2025
33 of 34 checks passed
@magnumripper magnumripper deleted the iterated-sha1 branch November 19, 2025 09:21
@solardiz
Copy link
Member

I still would like to know what the motivation was for adding this, and why the 1024 default. We also need a NEWS entry.

@magnumripper
Copy link
Member Author

I think it started out in some CTF but the idea now was to have a flexible format (btw the dynamic format can't do iterations).

The 1024 for other lengths was arbitrary. Maybe always default to 1 (not iterated) is more logical? Then it's like raw-sha1 (when no salt) and XSHA (salted) would be supported without any special exception (and it's obsolete anyway I guess).

On another note I toyed with the idea we could have a --default-iterations=N option but it would be hard/impossible to warn when it's actually not ending up being used.

@solardiz
Copy link
Member

btw the dynamic format can't do iterations

Ideally, we'd have more maintainable code for dynamic format, so that we could reasonably add iterations to there, and also support many different ways iterations can be implemented (e.g., binary vs. hex as input to each iteration). But that's currently unrealistic - that code is too messy as it is.

The 1024 for other lengths was arbitrary. Maybe always default to 1 (not iterated) is more logical?

I think there should be no default iteration count. Just refuse to work without it specified. I suggest that you revise the code added here to remove any default iteration counts.

we could have a --default-iterations=N option

I think we shouldn't have that. It's more confusing and error-prone than useful.

@solardiz
Copy link
Member

I think the special case for length 48 makes with 1 iteration makes sense. It's syntax we used in the XSHA format anyway, so it's good the OpenCL format would be suggested as a possible alternative.

On CPU and with auto-detection, will the XSHA or the iterated format be picked up by default for those hashes? Which one is faster? We want the faster one to be the default.

@magnumripper
Copy link
Member Author

Turns out the old XSHA format is uppercase (only). And actually it's way faster than this CPU format, as it's more optimized.

On CPU and with auto-detection, will the XSHA or the iterated format be picked up by default for those hashes?

This new one (if made supporting uppercase), then Tiger and only then XSHA.

A problem with running this OpenCL format for XSHA is that the internal mask will default to not being used (target 0). You need to use --mask-internal-target=10000 or so to get max. speed. The reason is once we know the max. loaded iteration count, mask mode is initialized already. I've been contemplating some fix for that before (would be great for many other formats as well).

Perhaps we should simply not accept any bare ciphertexts.

@solardiz
Copy link
Member

Oh, uppercase and Tiger...

Perhaps we should simply not accept any bare ciphertexts.

Well, or we could require uppercase for those 48 hex strings. Can we set a mask-internal-target upon seeing the first one of those in valid unless it had already been set (such as from the command line)?

XSHA on GPU is pretty much the only immediate use case for this PR's additions, I think. So it feels unreasonable not to support it well.

@magnumripper
Copy link
Member Author

we could require uppercase for those

That's not a bad idea. I will look into this. Also check what xsha format pot entries look like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants