Skip to content

Commit

Permalink
nfc: Move code in case any other phases are timing sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
GMMan committed Dec 30, 2024
1 parent 980fc08 commit 892a19b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions lib/nfc/protocols/mf_classic/mf_classic_poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -1897,21 +1897,22 @@ NfcCommand mf_classic_poller_handler_nested_controller(MfClassicPoller* instance
dict_attack_ctx->nested_phase = MfClassicNestedPhaseDictAttack;
}
}
if(dict_attack_ctx->reuse_key_sector == instance->sectors_total) {
// Reset target sector to first sector whose key has not been found
for(dict_attack_ctx->reuse_key_sector = 0;
dict_attack_ctx->reuse_key_sector < instance->sectors_total &&
mf_classic_nested_is_target_key_found(instance, true);
dict_attack_ctx->reuse_key_sector++)
;
// Reset to sane value just in case we happen to have all of the keys
if(dict_attack_ctx->reuse_key_sector == instance->sectors_total) {
dict_attack_ctx->reuse_key_sector = 0;
}
}
if((dict_attack_ctx->nested_phase == MfClassicNestedPhaseDictAttack ||
dict_attack_ctx->nested_phase == MfClassicNestedPhaseDictAttackResume) &&
(dict_attack_ctx->nested_target_key < dict_target_key_max)) {
if(dict_attack_ctx->reuse_key_sector == instance->sectors_total) {
// Reset target sector to first sector whose key has not been found
for(dict_attack_ctx->reuse_key_sector = 0;
dict_attack_ctx->reuse_key_sector < instance->sectors_total &&
mf_classic_nested_is_target_key_found(instance, true);
dict_attack_ctx->reuse_key_sector++)
;
// Reset to sane value just in case we happen to have all of the keys
if(dict_attack_ctx->reuse_key_sector == instance->sectors_total) {
dict_attack_ctx->reuse_key_sector = 0;
}
}

bool is_last_iter_for_hard_key =
((!is_weak) && ((dict_attack_ctx->nested_target_key % 8) == 7));
if(initial_dict_attack_iter) {
Expand Down

0 comments on commit 892a19b

Please sign in to comment.