Fix emulating empty keys as 0s

This commit is contained in:
Astra 2023-04-27 00:28:21 +03:00
parent 0a32cd2528
commit 102dd690b7

View file

@ -892,11 +892,25 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
MfClassicSectorTrailer* sector_trailer = MfClassicSectorTrailer* sector_trailer =
(MfClassicSectorTrailer*)emulator->data.block[sector_trailer_block].value; (MfClassicSectorTrailer*)emulator->data.block[sector_trailer_block].value;
if(cmd == MF_CLASSIC_AUTH_KEY_A_CMD) { if(cmd == MF_CLASSIC_AUTH_KEY_A_CMD) {
key = nfc_util_bytes2num(sector_trailer->key_a, 6); if(mf_classic_is_key_found(
access_key = MfClassicKeyA; &emulator->data, mf_classic_get_sector_by_block(block), MfClassicKeyA)) {
key = nfc_util_bytes2num(sector_trailer->key_a, 6);
access_key = MfClassicKeyA;
} else {
FURI_LOG_D(TAG, "Key not known");
command_processed = true;
break;
}
} else { } else {
key = nfc_util_bytes2num(sector_trailer->key_b, 6); if(mf_classic_is_key_found(
access_key = MfClassicKeyB; &emulator->data, mf_classic_get_sector_by_block(block), MfClassicKeyB)) {
key = nfc_util_bytes2num(sector_trailer->key_b, 6);
access_key = MfClassicKeyB;
} else {
FURI_LOG_D(TAG, "Key not known");
command_processed = true;
break;
}
} }
uint32_t nonce = prng_successor(DWT->CYCCNT, 32) ^ 0xAA; uint32_t nonce = prng_successor(DWT->CYCCNT, 32) ^ 0xAA;