Log MFC nonces for use with mfkey32v2 (#1390)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Eric Betts 2022-07-16 23:13:51 -07:00 committed by GitHub
parent c29ab50016
commit edc6ca0c8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -622,6 +622,19 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
break;
}
uint32_t nr = nfc_util_bytes2num(tx_rx->rx_data, 4);
uint32_t ar = nfc_util_bytes2num(&tx_rx->rx_data[4], 4);
FURI_LOG_D(
TAG,
"%08x key%c block %d nt/nr/ar: %08x %08x %08x",
emulator->cuid,
access_key == MfClassicKeyA ? 'A' : 'B',
sector_trailer_block,
nonce,
nr,
ar);
// Check if we store valid key
if(access_key == MfClassicKeyA) {
if(FURI_BIT(emulator->data.key_a_mask, mf_classic_get_sector_by_block(block)) ==
@ -637,8 +650,6 @@ bool mf_classic_emulator(MfClassicEmulator* emulator, FuriHalNfcTxRxContext* tx_
}
}
uint32_t nr = nfc_util_bytes2num(tx_rx->rx_data, 4);
uint32_t ar = nfc_util_bytes2num(&tx_rx->rx_data[4], 4);
crypto1_word(&emulator->crypto, nr, 1);
uint32_t cardRr = ar ^ crypto1_word(&emulator->crypto, 0, 0);
if(cardRr != prng_successor(nonce, 64)) {