From 3dde11267615db62172415df20c3d89e5fb93ba3 Mon Sep 17 00:00:00 2001 From: Nathan N Date: Tue, 12 Dec 2023 11:17:33 -0500 Subject: [PATCH] Fix edge case -- 0.5% of UIDs got wrong result --- applications/main/nfc/plugins/supported_cards/saflok.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/main/nfc/plugins/supported_cards/saflok.c b/applications/main/nfc/plugins/supported_cards/saflok.c index 55edd2efa..1b40d5de8 100644 --- a/applications/main/nfc/plugins/supported_cards/saflok.c +++ b/applications/main/nfc/plugins/supported_cards/saflok.c @@ -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; }