Skip to content
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

Fix edge case -- 0.5% of UIDs got wrong result #4

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Fix edge case -- 0.5% of UIDs got wrong result #4

merged 1 commit into from
Dec 12, 2023

Conversation

henrygab
Copy link
Contributor

The carry bit should have been applied to the summation before saving the result.

Only a small percentage of UIDs affected, because required that both carry_sum low byte was 0xff and that carry flag from prior addition was non-zero.

The old code was almost, but not quite, doing simple addition of large (48-bit) numbers.  However, the carry bit was not properly handled.  Specifically, when the temporary 16-bit `carry_sum` would have low eight bits of `0xff` and `carry_sum` from prior addition was non-zero.

Frankly, I'm not sure if this is a bug, or intentionally slightly different from just doing addition and checking the carry flag?

It just looked like it was 99.5% implementing addition of multi-byte values.  Then, the proxmark code actually ***did*** just use multi-byte addition.   It could be a bug in this code (and fixed with this change), or maybe the KDF intentionally did this, and the author of the proxmark version of the code didn't notice this edge case, and thought the KDF was properly implementing addition?
@noproto
Copy link
Owner

noproto commented Dec 12, 2023

Verified, nice catch! 🎉

@noproto noproto merged commit f15ce7f into noproto:master Dec 12, 2023
@henrygab henrygab deleted the fix_addition branch December 13, 2023 01:51
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