Skip to content

Add a valid_luhn() function, and use it for SL3 #5787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

magnumripper
Copy link
Member

@magnumripper magnumripper commented Jun 11, 2025

#5767 (comment)

I wanted to base it on https://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#C which is nice code, but it appears the licensing would be tricky so here's instead my C implementation of the pseudo code on Wikipedia.

There were actually a mockup SL3 test vector featuring an incorrect Luhn so I had to correct that as well.

This will be used by SL3 to start with, for rejecting hashes with an
invalid IMEI.
That digit isn't used by the algo (and only specifying 14 digits without
Luhn is and was accepted) but this change will somewhat lower the risk
of misidentifying other hashes as SL3.

There were actually a mockup test vector featuring an incorrect Luhn so
I had to correct that as well.

See openwall#5767
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.

I didn't verify correctness of the Luhn algorithm implementation vs. Wikipedia or whatever, but I skimmed the code and it looks reasonable to me.

@magnumripper magnumripper merged commit 9f941f8 into openwall:bleeding-jumbo Jun 12, 2025
32 of 33 checks passed
@magnumripper magnumripper deleted the luhn branch June 12, 2025 06:56
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