Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfc: NTAG21x complete emulation #1313

Merged
merged 39 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7158b30
nfc: Refactor Mifare Ultralight feature flags
GMMan Jun 9, 2022
0973207
nfc: Refactor MFUL PWD_AUTH and add AUTHLIM counter
GMMan Jun 10, 2022
98c2190
nfc: Add MFUL EV1 VCSL command emulation
GMMan Jun 10, 2022
7f64628
nfc: Enforce message size check in MFUL emulation
GMMan Jun 10, 2022
cd0e3fb
nfc: Add MFUL auth counter serialization
GMMan Jun 10, 2022
3eb7634
nfc: Fix MFUL INCR_CNT emulation
GMMan Jun 10, 2022
4bed98e
nfc: Fix MFUL READ_CNT emulation
GMMan Jun 10, 2022
fba99c3
nfc: Refactor MFUL emulation and implement full write support
GMMan Jun 10, 2022
b4b3a00
nfc: Fix Mifare Ultralight serialization
GMMan Jun 10, 2022
4cfa709
nfc: Add MFUL OTP/CC handling
GMMan Jun 11, 2022
0cdfb9b
nfc: Make sure MF0UL21 dynamic lock byte 3 also reads 0xBD
GMMan Jun 11, 2022
1147762
nfc: Small MFUL refactor and fix CFGLCK behavior
GMMan Jun 11, 2022
207bff6
WIP: nfc: MFUL read support with ASCII mirror and auth roll-over
GMMan Jun 12, 2022
b2673f6
nfc: Simplify MFUL read emulation, fix mirror range check
GMMan Jun 13, 2022
e530ddf
nfc: Minor
GMMan Jun 13, 2022
b23b3e5
nfc: Implement MFUL auth and ASCII mirror for FAST_READ
GMMan Jun 13, 2022
f353c75
nfc: Fix MFUL read roll-over with AUTH0 set
GMMan Jun 13, 2022
b4602e4
nfc: Implement MFUL read counter increment
GMMan Jun 13, 2022
7640ee0
nfc: Align ASCII mirror to NTAG21x behavior
GMMan Jun 13, 2022
49a1e4d
nfc: Handle invalid command in MFUL emulation
GMMan Jun 13, 2022
5d166a0
nfc: Fix MFUL static lock check
GMMan Jun 13, 2022
e013430
nfc: Refactor MFUL emulation to use cached config pages
GMMan Jun 13, 2022
47c54dd
nfc: Refactor MFUL auth counter to count up instead of down
GMMan Jun 13, 2022
dadd8d1
nfc: Add missing NULL check
GMMan Jun 13, 2022
3d70efc
WIP: nfc: Various MFUL emulation behavior tweaks
GMMan Jun 13, 2022
3f38df5
WIP: nfc: More MFUL emulation behavior adjustments
GMMan Jun 13, 2022
061184a
nfc: Match AUTHLIM emulation to NTAG21x behavior
GMMan Jun 14, 2022
4cb4c4e
nfc: Fix MFUL dynamic lock emulation
GMMan Jun 14, 2022
53ee923
nfc: Fix typo in MFUL read counters
GMMan Jun 14, 2022
67cbee1
nfc: Fix typo in MFUL FAST_READ emulation
GMMan Jun 14, 2022
b9965fc
nfc: Increase emulation TX buffer size
GMMan Jun 14, 2022
a46d152
nfc: Fix MFUL negative verification counter overflow
GMMan Jun 14, 2022
dfa337e
nfc: Change auth counter kv name
GMMan Jun 14, 2022
d70a138
nfc: Fix NTAG I2C FAST_READ emulation
GMMan Jun 14, 2022
0996347
nfc: Fix NTAG21x config reload behavior
GMMan Jun 15, 2022
3b84493
Merge branch 'dev' into ntag21x-full-emu
GMMan Jun 15, 2022
bbfbe4b
Merge branch 'dev' into ntag21x-full-emu
skotopes Jun 21, 2022
880019a
Merge branch 'dev' into ntag21x-full-emu
skotopes Jun 21, 2022
47bf695
Merge branch 'dev' into ntag21x-full-emu
skotopes Jun 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions applications/nfc/nfc_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ static bool nfc_device_save_mifare_ul_data(FlipperFormat* file, NfcDevice* dev)
}
}
if(!pages_saved) break;

// Write authentication counter
uint32_t auth_counter = data->curr_authlim;
if(!flipper_format_write_uint32(file, "Failed authentication attempts", &auth_counter, 1))
break;

saved = true;
} while(false);

Expand Down Expand Up @@ -169,6 +175,12 @@ bool nfc_device_load_mifare_ul_data(FlipperFormat* file, NfcDevice* dev) {
}
}
if(!pages_parsed) break;

// Read authentication counter
uint32_t auth_counter;
if(!flipper_format_read_uint32(file, "Failed authentication attempts", &auth_counter, 1))
auth_counter = 0;

parsed = true;
} while(false);

Expand Down
6 changes: 1 addition & 5 deletions applications/nfc/nfc_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,7 @@ void nfc_worker_emulate_mifare_ul(NfcWorker* nfc_worker) {
MfUltralightEmulator emulator = {};
mf_ul_prepare_emulation(&emulator, &nfc_worker->dev_data->mf_ul_data);
while(nfc_worker->state == NfcWorkerStateEmulateMifareUltralight) {
emulator.auth_success = false;
if(emulator.data.type >= MfUltralightTypeNTAGI2C1K) {
// Sector index needs to be reset
emulator.curr_sector = 0;
}
mf_ul_reset_emulation(&emulator, true);
furi_hal_nfc_emulate_nfca(
nfc_data->uid,
nfc_data->uid_len,
Expand Down
2 changes: 1 addition & 1 deletion firmware/targets/f7/furi_hal/furi_hal_nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ bool furi_hal_nfc_emulate_nfca(
uint8_t buff_rx[256];
uint16_t buff_rx_size = 256;
uint16_t buff_rx_len = 0;
uint8_t buff_tx[256];
uint8_t buff_tx[1040];
uint16_t buff_tx_len = 0;
uint32_t data_type = FURI_HAL_NFC_TXRX_DEFAULT;

Expand Down
Loading