NFC FeliCa: Service Directory Traverse + Dump All Unencrypted-Readable Services' Blocks (#4254)

* SimpleArray attached to FelicaData

* tx rx done. response parsing done (in log)

* dynamic vector as buffer. rendering begin

* On screen render for directory tree

* flags in render to indicate is_public_readable

* beautify render flags

* format

* offload dynamic vector into individual files

* saving. exposed dir tree writing for double use

* save: additional formatting

* save: clean up and some additional notes

* load done

* delete unnecessary debug log

* Load: safer way to handle backward compatibility

`parsed` being true is only contingent on whether the header (device type, UID, etc) are correctly read. The detailed data can be absent if saved from previous versions.

Side effects:
1. The data format version number must not increment.
2. Newer sections of dumps must be appended in the end of the file.

* format

* handle block reading according to IC type

Old version was aimed for FeliCa Lite dumping, which doesn't apply to FeliCa standard. Thus they need to be diverged in the poller run workflow.

* read block content works. rendering begin

* Render Refactor: dir & dump view from submenu

* Render: show IC type name

* IC parsing function cleanup

* Revert "IC parsing function cleanup"

This reverts commit ee3f7bf125b54b10d238b0aeb657ba15f27f93ba.

* Load: Standard dump. Fully backward compatible

* format

* sync API version

* format saved file

* delete unused variable

* clean ups

* IC type addition

* correction

* beautify attribute parsing

* correction

* Lite save: delete extra line

* correction: FeliCa link in Lite-S mode

* format

* Save: simplify printing

* update IC type parsing

* conform to api standard: const resp ptr to ptr

also slightly faster and more readable block dump loop

* disambiguate workflow type vs ic type

It was too confusing to have the ic name string telling you one thing and ic_type enum saying the other. Might as well use better naming to indicate the use case for the two things

* beautify on device render

* reject dynamic_vector, embrace m-array

* lint

* use full variable name

* partial fix: poller context's data proper init

* edit unit test dump IC code

and a small bug fix for the Lite auth workflow

* unit test felica dump PMm correction

* Fixes for static analysis warnings

---------

Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
Zinong Li
2025-10-01 18:54:08 +04:00
committed by GitHub
parent fad487df0e
commit 85b6b2b896
18 changed files with 1219 additions and 89 deletions

View File

@@ -1070,7 +1070,9 @@ Function,+,felica_crc_trim,void,BitBuffer*
Function,+,felica_free,void,FelicaData*
Function,+,felica_get_base_data,FelicaData*,const FelicaData*
Function,+,felica_get_device_name,const char*,"const FelicaData*, NfcDeviceNameType"
Function,+,felica_get_ic_name,void,"const FelicaData*, FuriString*"
Function,+,felica_get_uid,const uint8_t*,"const FelicaData*, size_t*"
Function,+,felica_get_workflow_type,void,FelicaData*
Function,+,felica_is_equal,_Bool,"const FelicaData*, const FelicaData*"
Function,+,felica_load,_Bool,"FelicaData*, FlipperFormat*, uint32_t"
Function,+,felica_poller_activate,FelicaError,"FelicaPoller*, FelicaData*"
@@ -1078,8 +1080,10 @@ Function,+,felica_poller_read_blocks,FelicaError,"FelicaPoller*, const uint8_t,
Function,+,felica_poller_sync_read,FelicaError,"Nfc*, FelicaData*, const FelicaCardKey*"
Function,+,felica_reset,void,FelicaData*
Function,+,felica_save,_Bool,"const FelicaData*, FlipperFormat*"
Function,+,felica_service_get_attribute_string,void,"const FelicaService*, FuriString*"
Function,+,felica_set_uid,_Bool,"FelicaData*, const uint8_t*, size_t"
Function,+,felica_verify,_Bool,"FelicaData*, const FuriString*"
Function,+,felica_write_directory_tree,void,"const FelicaData*, FuriString*"
Function,-,feof,int,FILE*
Function,-,feof_unlocked,int,FILE*
Function,-,ferror,int,FILE*
1 entry status name type params
1070 Function + felica_free void FelicaData*
1071 Function + felica_get_base_data FelicaData* const FelicaData*
1072 Function + felica_get_device_name const char* const FelicaData*, NfcDeviceNameType
1073 Function + felica_get_ic_name void const FelicaData*, FuriString*
1074 Function + felica_get_uid const uint8_t* const FelicaData*, size_t*
1075 Function + felica_get_workflow_type void FelicaData*
1076 Function + felica_is_equal _Bool const FelicaData*, const FelicaData*
1077 Function + felica_load _Bool FelicaData*, FlipperFormat*, uint32_t
1078 Function + felica_poller_activate FelicaError FelicaPoller*, FelicaData*
1080 Function + felica_poller_sync_read FelicaError Nfc*, FelicaData*, const FelicaCardKey*
1081 Function + felica_reset void FelicaData*
1082 Function + felica_save _Bool const FelicaData*, FlipperFormat*
1083 Function + felica_service_get_attribute_string void const FelicaService*, FuriString*
1084 Function + felica_set_uid _Bool FelicaData*, const uint8_t*, size_t
1085 Function + felica_verify _Bool FelicaData*, const FuriString*
1086 Function + felica_write_directory_tree void const FelicaData*, FuriString*
1087 Function - feof int FILE*
1088 Function - feof_unlocked int FILE*
1089 Function - ferror int FILE*