-
-
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
Fix APDU length in emvcore - excessive Lc with no data packet #171
Comments
sometimes it true, sometimes not. commands on different cards and via different channels needs to have different apdu sructure and sometimes it not as iso said. in real life terminals have different "kernels" that make APDUs with a their hardcoded way. |
P.S. I have tried bank certification device on pm3 and it passes all public part several most commonly used card's standard. |
devnied/EMV-NFC-Paycard-Enrollment#17 I have not remembered from where i have copied my list. so i cant share it (im not sure if it can be shared) |
Hi, thanks for such quick response.
There is this 6-byte APDU for read record. I noticed one of these "checks" introduced in EMVReadRecord - "trying to reissue command without Le":
that workaround would work in my case - the resulting APDU will be 5 bytes, the 5th Lc will be treated as Le by card. But as far as I understand the execution does not reach this point because the exception is raised before. I checked my reader (Sumup) against the same HCE card. It sends 5 bytes APDU for reading AFL, and it works. Also the same setup but with official repo client works in my case (5 byte APDU):
And executing the commands by hand in RRG repo client works as well:
|
maybe ill add |
Oh, I have missed the fact it is 0x67 not not 0x6F... I have added 0x6F00 here to EMVReadRecord:
and that did the trick for my case:
But that is not really elegant solution in my opinion, also may be a bit misguiding in future - there is actually Lc which is treated as Le by the card in practice... |
looks it done, thanks |
Lets see what @jslawek says |
It works, thanks! |
EMV search leaves the rf field on afterwards, even if it doesnt find a tag |
Hi,
the EMV APDUs with no data (just headers) are incorrectly generated with excessive Lc byte.
According to specification, APDU consists of:
There are 4 possible cases for APDU packet:
In case there is no data, the emvcore generates APDU packet with excessive Lc, thus making it one byte (0x00) longer, and then adds Le at the end. For example, an APDU "read first record from SFI" generated in emvcore:
but should be
Many cards process this one byte longer, incorrect APDU, but there are some that respond with 0x6F00 and the EMV exchange communication stops.
I think the easiest fix would be to take EMVExchange approach from the main repo:
https://github.com/Proxmark/proxmark3/blob/master/client/emv/emvcore.c#L368-L374
In case the APDU is 5 byte len, it is assumed the Le is there already, and the code generates correct len APDUs. Current RRG repo code adds the Le anyway and makes it 6 bytes incorrectly.
By the way, the EMVExchange call to EMVExchangeEx has a typo anyway - the fifth parameter should not be channel (it is the first parameter), but rather IncludeLe bool:
The text was updated successfully, but these errors were encountered: