-
Notifications
You must be signed in to change notification settings - Fork 3.1k
NFC FeliCa Standard: Service Directory Traverse + Dump All Unencrypted-Readable Services' Blocks #4254
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
`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.
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.
This reverts commit ee3f7bf.
@zinongli vector is closer to m-array (ARRAY_DEF). |
Thanks. I'll try it over the weekend. |
I lost to my lack of patience. The switch was easier than I imagined. But I could be wrong. This should be ready for review. I've tested on my end and it works the same as before the switch from dynamic vector to m-array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zinongli thanks for the improvements. However, there are 2 issues I've noticed:
unit tests fail on FeliCa protocol:
when running emulation of a Suica card dump, NFC Tools reports read error, and in logs there's the following - nvm, also present on dev
473966 [D][FelicaListener] Field On
473998 [D][FelicaListener] Activated
474017 [D][FelicaListener] Activated
474033 [D][FelicaListener] Activated
474056 [D][FelicaListener] Rx Done
474071 [D][FelicaListener] Activated
474081 [D][FelicaListener] Activated
474093 [D][FelicaListener] Activated
474097 [D][FelicaListener] Rx Done
474099 [E][FelicaListener] FeliCa incorrect command
474102 [E][FelicaListener] Processing error: 1
Thanks! I'll look into it. |
OK I believe I know where the bug is. The unit test feeds the poller a A partially relevant question: are |
and a small bug fix for the Lite auth workflow
Was this Manufacturer Code / PMm introduced in #3673 gained from an actual tag or was this dump artificially and randomly generated? My code failed unit test also because this unforeseen IC code 0x4E (the second byte in Manufacturer Code / PMm) was not recorded in any database. Not in pm3 or nullablevoidptr's doc. If this indeed came from a FeliCa Lite-S I can add it into my workflow switch loop. But from the evidence I have, it seems to me very unlikely to be from an actual Lite-S PMm. Please let me know if you have any recollection of where this dump came from. @RebornedBrain For the time being, I will edit this dump for unit test to have a documented Lite-S IC code so that the unit test will be directed to the Lite poller workflow. And this PR can pass unit test now. |
if(felica_event->type == FelicaPollerEventTypeReady || | ||
felica_event->type == FelicaPollerEventTypeIncomplete) { | ||
felica_copy(&poller_context->data, felica_poller->data); | ||
felica_copy(poller_context->data.data, felica_poller->data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nested data structure was intended to mimic how it was handled in MfUltralight's poller sync since we need proper allocation for FelicaData
Hi, I've checked the dump, and looks like you're right, PMm is wrong. I was able to find the card, which I used while implementing Felica Lite-S, here it is:
As you can see it has those |
Thanks @RebornedBrain ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @zinongli @RebornedBrain - LGTM now. Hope with this new functionality we'll be able to bring more exciting FeliCa features and parsers.
Thanks a lot! By the way some of the SubGhz fixes got carried over hahaha |
@zinongli I took liberty to push some static analysis fixes to your branch - they affect your code too, check them out (nothing major) |
Oh of course, thanks for fixing them! |
What's new
Traverse:
felica_poller_state_handler_traverse_system
to be among other felica poller states inlib/nfc/protocols/felica.c
. It intercepts after activation and auth, before read blocks.felica_poller_list_service_by_cursor
andfelica_poller_prepare_tx_buffer_raw
infelica_poller_i.c
. Very similar logic to other felica poller states.DynamicVector
). If there are existing solutions I would be happy to switch and not having to create my own.Block dump:
SimpleArray
.TextBox
prints the blocks read.felica_data_format_version = 1
). Because previous implementation treated all the FeliCa tags as FeliCa Lite, if we detect the data format version is one, we temporarily assume the tag to be Lite, proceed to parse and load the same way it was done before.Check list:
This PR is intended for future support for automatic dump of all publicly readable services. Before we dump we need to know what is out there.This is done.Example dump file from reading a FeliCa Standard:
Example video of the new rendering for FeliCa Standard (the first tag read) and the backward support for an old file of a Suica (file name was Sui) mistakenly read as FeliCa Lite and got rendered regardless:
https://github.com/user-attachments/assets/40f8b034-1f57-43de-b473-40ed0cae1f09
Reference:
1, 2
My POC on PM3: 1, 2
Thanks for the guidance from @baconwaifu and @dogtopus, and tireless testing by @ry4000.
Verification
FeliCa Standard:
FeliCa Lite:
Backward compatibility:
Checklist (For Reviewer)