Skip to content

Commit

Permalink
Log MFC nonces for use with mfkey32v2 (#1390)
Browse files Browse the repository at this point in the history
Co-authored-by: あく <[email protected]>
  • Loading branch information
bettse and skotopes authored Jul 17, 2022
1 parent c29ab50 commit edc6ca0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/nfc_protocols/mifare_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) ==
Expand All @@ -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)) {
Expand Down

0 comments on commit edc6ca0

Please sign in to comment.