Commit Graph
36 Commits
Author SHA1 Message Date
Philippe Teuwen c00e4801b7 make style 2026-02-06 13:43:41 +01:00
rashit_khamidullin 129d9e9ef7 fix hf ntag424 changefs SDM offset serialization bug
The changefs command was using memcpy on a fixed struct layout to
serialize
SDM settings, which caused SDM offset fields to be written incorrectly.
The struct's sdm_data[8][3] array was copied contiguously, but the NTAG
424
DNA specification (AN12196) requires certain offset fields to be
conditionally
omitted based on the SDM configuration.

This resulted in:
- Plain mode: MAC offsets not written correctly
- PICC mode: MAC offsets not written correctly
- Both modes producing cmac=0000000000000000

The fix replaces the memcpy-based approach with dynamic payload building
that
conditionally includes only the required SDM offset fields in the
correct order:
- UIDOffset (only if UID option + plain mode sdmMetaRead=0xE)
- SDMReadCtrOffset (only if counter option + plain mode)
- PICCDataOffset (only if encrypted PICC mode sdmMetaRead<=0x04)
- SDMMACInputOffset (only if file read enabled)
- SDMEncOffset + SDMEncLength (only if encrypted file data enabled)
- SDMMACOffset (only if file read enabled)
- SDMReadCtrLimit (only if limit option set)
2026-02-02 22:47:23 +01:00
Philippe Teuwen fd88967443 make style 2025-10-14 09:50:59 +02:00
Oleg Moiseenko 944a80d217 make style 2025-09-21 16:41:30 +03:00
iceman1001 dc44d0fda5 fix error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant] on MAC Xcode26.0 2025-06-12 17:37:02 +02:00
Shawn Hoffman bfbc2fd09d fix offset transferred in ntag424_read_data 2025-04-16 14:20:58 -07:00
iceman1001 ded9166393 missing breaks 2025-03-25 12:36:22 +01:00
iceman1001 ad292e8810 unify test - step 2 2025-03-25 10:17:42 +01:00
Shawn Hoffman e04d778c46 ntag424: let info cmd show if tag has tag tamper feature 2025-03-24 17:10:19 -07:00
Philippe Teuwen c37ca881e6 a few calloc checks, still many to go 2025-03-24 11:17:40 +01:00
iceman1001 9a114815d1 fix cppchecker warning with shadow 2025-03-22 15:45:17 +01:00
iceman1001 4aa8645a33 fixed order of checking 2024-05-14 12:00:19 +02:00
iceman1001 a9a3c0bea9 const params 2024-05-14 11:45:36 +02:00
iceman1001 482a6464a2 style. we use calloc 2024-01-07 20:47:07 +01:00
Philippe Teuwen 9f8c02bf96 fix CWE-562: Return of Stack Variable Address 2023-11-11 18:24:34 +01:00
iceman1001 ea249d7b17 fixes 2023-11-03 12:20:30 +01:00
Daniel Karling 5a750da4ef Removed wrapper for desfire_print_signature
Not needed now when the unused parameter is gone.
2023-10-31 08:19:17 +01:00
Daniel Karling ee3a223e37 Implemented 'info' command for NTAG424 2023-10-31 08:16:07 +01:00
iceman1001 b9dcd143d5 style 2023-10-30 13:11:52 +01:00
iceman1001 2763ead13b fix the free ctx calls 2023-10-30 13:05:46 +01:00
iceman1001 b0ee6ae67b fixes ntag424 2023-10-30 12:55:23 +01:00
Daniel Karling d4f8c42d3c Added additional command examples 2023-10-29 17:13:27 +01:00
Daniel Karling 912c126266 Added encrypted comms to ReadData and WriteData commands
This allows reading and writing to the "proprietary" file (number 3),
or file 2 if it's set to "full" communications mode.
2023-10-29 16:49:11 +01:00
Daniel Karling 6d290f1bae Less magic numbers, more refactoring 2023-10-29 13:50:31 +01:00
Daniel Karling 1eaf8d0e80 Fixed incorrect order of sdm access rights in command help 2023-10-28 10:33:30 +02:00
Daniel Karling 05a2302466 Implemented style 2023-10-27 18:09:38 +02:00
Daniel Karling ad875a8c01 Refactored communication encryption 2023-10-27 17:25:48 +02:00
Daniel Karling eb29e1a17e Cleanup
* Added some comments
 * Changed name of offsets to sdm_data since this is more apt. Not all
   of them are describing offsets
 * Fixed dumb bug in MAC refactor
2023-10-27 07:45:40 +02:00
Daniel Karling 011d1f6a44 Refactored MAC and IV calculations 2023-10-27 06:52:30 +02:00
Daniel Karling 70422937f2 Partial implementation of NTAG424 commands
Noteworthy stuff that's missing:
* Encrypted read/write to file.
* Handling of CC and Proprietary file

Stuff that works:
* Read/write file
* Get/change file settings
* Change auth keys
* Configuring SDM/SUN feature
2023-10-26 22:10:00 +02:00
iceman1001 89db5d3875 text 2023-10-02 20:59:01 +02:00
iceman1001 f1e228e739 fix cid 393261 2022-05-31 22:30:41 +02:00
iceman1001 f38a3ad762 adapt load dump file refactoring else where 2022-05-15 23:56:35 +02:00
iceman1001 8d9dd8b346 make style 2022-04-09 18:48:13 +02:00
iceman1001 26603ad80a text 2022-04-02 15:44:55 +02:00
iceman1001 fb5ba83569 added skeleton for HF NTAG424 category of commands 2022-04-02 14:06:16 +02:00