Merge pull request #668 from noproto/patch-1

Fix edge case -- 0.5% of UIDs got wrong result
This commit is contained in:
MMX 2023-12-14 01:06:03 +03:00 committed by GitHub
commit 09a66e2285
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,8 +62,8 @@ void generate_saflok_key(const uint8_t* uid, uint8_t* key) {
uint8_t carry_sum = 0;
for(int i = KEY_LENGTH - 1; i >= 0; i--, magickal_index--) {
uint16_t keysum = temp_key[i] + magic_table[magickal_index];
temp_key[i] = (keysum & 0xFF) + carry_sum;
uint16_t keysum = temp_key[i] + magic_table[magickal_index] + carry_sum;
temp_key[i] = (keysum & 0xFF);
carry_sum = keysum >> 8;
}