diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f50927c..6960800a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Changed `hf seos` - a failed MAC check with an empty privacy key slot now says so and how to load one, instead of "Likely wrong Priv Mac Key" (@antoniovazquezblanco) - Improved PM5 nonce-acquisition throughput for mfc by replacing the fixed 68-pair cap with a 2900 ms target budget (@nip-was-here) - Fixed PM5 tick-count reads across RTC second rollovers to prevent false receive timeouts - Fixed iso14443a - reject incomplete encrypted nonce frames instead of delaying nested authentication on PM5 (@nip-was-here) diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index ef2289514..6fac1b150 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -120,6 +120,11 @@ static bool seos_parse_key_index(const char *input, int *value) { return true; } +static bool seos_privacy_key_empty(int key_index) { + return (memcmp(keys[key_index].privEncKey, zeros, sizeof(zeros)) == 0) && + (memcmp(keys[key_index].privMacKey, zeros, sizeof(zeros)) == 0); +} + static int create_cmac(uint8_t *key, uint8_t *input, uint8_t *out, int input_len, int output_len, int encryption_algorithm) { uint8_t iv[16] = {0x00}; uint8_t mac[16] = {0x00}; @@ -750,7 +755,12 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t out: PrintAndLogEx(INFO, "--- " _CYAN_("MAC") " ---------------------------"); PrintAndLogEx(ERR, _RED_("MAC Verification Failed")); - PrintAndLogEx(ERR, _YELLOW_("Likely wrong Priv Mac Key")); + if (seos_privacy_key_empty(key_index)) { + PrintAndLogEx(ERR, _YELLOW_("Privacy key slot %d is empty"), key_index); + PrintAndLogEx(HINT, "Hint: Load one with `" _YELLOW_("hf seos managekeys --ki %d --privacy ") "`", key_index); + } else { + PrintAndLogEx(ERR, _YELLOW_("Likely wrong Priv Mac Key")); + } return PM3_ESOFT; } @@ -1630,7 +1640,7 @@ static int seos_print_keys(bool verbose) { PrintAndLogEx(INFO, "idx| privacy | auth"); PrintAndLogEx(INFO, "---+---------+-----"); for (uint8_t i = 0; i < ARRAYLEN(keys); i++) { - bool has_privacy = (memcmp(keys[i].privEncKey, zeros, sizeof(zeros)) != 0) || (memcmp(keys[i].privMacKey, zeros, sizeof(zeros)) != 0); + bool has_privacy = (seos_privacy_key_empty(i) == false); bool has_auth = (memcmp(keys[i].authKey, zeros, sizeof(zeros)) != 0); PrintAndLogEx(INFO, " %u | %c | %c", i, has_privacy ? 'Y' : ' ', has_auth ? 'Y' : ' '); }