cppcheck duplicateCondition

This commit is contained in:
Philippe Teuwen 2025-03-24 21:44:21 +01:00
commit 6491b37d7a

View file

@ -989,24 +989,21 @@ static int CmdEM4x70Recover(const char *Cmd) {
result = recover_em4x70(&recover_ctx.opts, &recover_ctx.data); result = recover_em4x70(&recover_ctx.opts, &recover_ctx.data);
if (PM3_EOVFLOW == result) { if (PM3_EOVFLOW == result) {
PrintAndLogEx(ERR, "Found more than %d potential keys. This is unexpected and likely a code failure.", MAXIMUM_ID48_RECOVERED_KEY_COUNT); PrintAndLogEx(ERR, "Found more than %d potential keys. This is unexpected and likely a code failure.", MAXIMUM_ID48_RECOVERED_KEY_COUNT);
return result;
} else if (PM3_SUCCESS != result) { } else if (PM3_SUCCESS != result) {
PrintAndLogEx(ERR, "No potential keys recovered. This is unexpected and likely a code failure."); PrintAndLogEx(ERR, "No potential keys recovered. This is unexpected and likely a code failure.");
return result;
} }
} }
// generate alternate authentication for each potential key -- no error paths, sub-second execution // generate alternate authentication for each potential key -- no error paths, sub-second execution
if (PM3_SUCCESS == result) {
fill_buffer_prng_bytes(&recover_ctx.alt_nonce, sizeof(ID48LIB_NONCE)); fill_buffer_prng_bytes(&recover_ctx.alt_nonce, sizeof(ID48LIB_NONCE));
for (uint8_t i = 0; i < recover_ctx.data.potential_key_count; ++i) { for (uint8_t i = 0; i < recover_ctx.data.potential_key_count; ++i) {
// generate the alternate frn/grn for the alternate nonce // generate the alternate frn/grn for the alternate nonce
id48lib_generator(&recover_ctx.data.potential_keys[i], &recover_ctx.alt_nonce, &recover_ctx.alt_frn[i], &recover_ctx.alt_grn[i]); id48lib_generator(&recover_ctx.data.potential_keys[i], &recover_ctx.alt_nonce, &recover_ctx.alt_frn[i], &recover_ctx.alt_grn[i]);
} }
}
// display alternate authentication for each potential key -- no error paths // display alternate authentication for each potential key -- no error paths
if (PM3_SUCCESS == result) {
PrintAndLogEx(INFO, "Recovered %d potential keys:", recover_ctx.data.potential_key_count); PrintAndLogEx(INFO, "Recovered %d potential keys:", recover_ctx.data.potential_key_count);
for (uint8_t i = 0; i < recover_ctx.data.potential_key_count; ++i) { for (uint8_t i = 0; i < recover_ctx.data.potential_key_count; ++i) {
// generate an alternative authentication based on the potential key // generate an alternative authentication based on the potential key
@ -1040,9 +1037,9 @@ static int CmdEM4x70Recover(const char *Cmd) {
); );
} }
printf("\n"); printf("\n");
}
// which of those keys actually validates? // which of those keys actually validates?
if (PM3_SUCCESS == result && recover_ctx.opts.verify) { if (recover_ctx.opts.verify) {
// TODO: automatic verification against a present tag. // TODO: automatic verification against a present tag.
// Updates ctx.potential_keys_validated[10] and ctx.keys_validated_count // Updates ctx.potential_keys_validated[10] and ctx.keys_validated_count
PrintAndLogEx(WARNING, "Automatic verification against tag is not yet implemented."); PrintAndLogEx(WARNING, "Automatic verification against tag is not yet implemented.");