-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Remove broken --par
option from lf em 4x70
#2376
Comments
The only unaffected ARM entry points are What gets corrupted
if Notably,
|
Great write-up and findings! Is there a way to do a regression test for these things? So we can capture it with the |
A regression test is a good idea. At present, I don't see where em4x70 could have much testing without a tag present? Or, maybe I'm not understanding the regression test yet. |
if we have some dumps, we can do some tests to make sure the offline commands works. |
Ok. Ah... Maybe also add a command to directly expose calculation of challenge / response? |
... and added Should be ready to merge within a few hours, if all goes well. |
Nice, some heads up, We use two different styles when adding a self test function.
which both should give a outcome line like:
If added like this we can now easily add a run of it in the |
I will leave the PR as-is, as it is functionally correct, mirrors existing tests, is validated to work, and improves the validation as per your request. The PR modeled the added tests based on those already in higher-value work
Some items that will provide greater value and are on my radar:
|
Update: After adding some logging to more easily see what bits are sent/received, it confirmed that ... this code is messy. The following is what currently occurs (not using the
Preliminary logs and notes are my em4x70_dev branch . Todo:
|
@cmolson was the one who created the commands, maybe he has some input ? |
Hi, Thanks for all the investigation, and sorry about the mess/confusion. The tag I was looking into (ID48?) was a slightly modified version of the EM4170 which is why I tried to make this code work for both. I think the differences were around sending parity with the commands. I still have all my tags and proxmark device, I need to get it set up again and re-familiarize myself with this to offer any useful input. I should be able to do this over the next few days. |
Oh, nothing to apologize for; Quite the opposite. It's only because of your foundational work that I made progress myself ... so thank you for making this possible! I have ID48 tags from my old vehicle, and XT27A tags that can be configured to ID48. What I've yet to acquire is any tag that requires use of the If you're going to poke and prod, consider using my dev branch ... It has a functional trace built-in that will show all bits sent, and all bits received (+start/stop timing for each). Or, if you have any extra V4070 tags (or an actual EM4170 tag ... both hinted as working differently), I'd be happy to do the poking and prodding, if you're open to loaning those out. |
I would be more than happy to send you a few of the various tags I bought. I will also try your branch with the tags I have, thanks! |
.... don't be a stranger, if you have some spares :) |
I need to figure out what exactly I have.. but I have two bags with 10 tags each. One is "ID48" and the other says "ID48 EM4170"... I only want to keep 2 of each. Let me know how to get your mailing addresses and I'll send you both some. |
if you on the discord server, do DM |
Ping me on Iceman's RFID discord server? I have a hunch what your discord id is, but not conclusive. (Mine is obvious. 🙂) |
Current usage
There are two variables used for parity:
command_parity
- global variable, client setsfalse
by defaultwith_parity
- Parameter toem4x70_send_nibble()
functionAll seven entry points in ARM source set global variable
command_parity
per inputetd->parity
.Client source defaults this value to
false
in all cases.Therefore, unless explicitly provided via
--par
for a command, the value in the ARM source ofcommand_parity
will always befalse
.ARM firmware reliance on
command_parity
Details
The value of this variable is only read in two locations:
send_command_and_read()
em4x70_send_nibble()
send_command_and_read()
This function calls
em4x70_send_nibble()
with the providedcommand, setting the function parameter
with_parity
equalto the global variable
command_parity
, and then immediatelylistens for a tag response.
em4x70_send_nibble()
This function's parameter
with_parity
does DIFFERENT things, using both parameterwith_parity
and the global variablecommand_parity
.When global
command_parity
isfalse
, all four bits of the nibble are sent. This is the default behavior with the client code.When global
command_parity
istrue
, only the three least significant bits of the nibble are sent. (Mask0x07
).When parameter
with_parity
istrue
, and extra bit is sent, which is the parity for the 3-bits (command_parity == true
) or 4-bits (command_parity == false
) that was sent.When parameter
with_parity
isfalse
, no additional parity bit is sent.#
command_parity
with_parity
false
false
false
true
true
false
true
true
Callers of em4x70_send_nibble()
This function is called by the following, with "Valid" indicating the code appears valid if
command_parity
is also set totrue
.with_parity
em4x70_send_word()
true
em4x70_send_word()
false
authenticate()
true
authenticate()
false
frn
send_pin()
true
write()
true
write()
true
send_command_and_read()
command_parity
In particular, if
command_parity
is true, then for each nybble of theword of data,
em4x70_send_word()
will only send the three least significantbits (+ two parity bits ... thus losing data). Then, when sending the parity
row, it will ALSO lost the most significant bit (and send a parity bit + zero bit).
In addition, the
authenticate()
command will similarly lose data fromthe last four bits of
frn
.Finally, the
write()
command will also lose data for much the same reason.Conclusion
The
--par
option is fundamentally broken, and thus is "dead code" as itfails to work in any situation where data is sent to the tag.
Therefore, removal of the
--par
option and related dead code will improvethe codebase.
The text was updated successfully, but these errors were encountered: