vsmartcard icon indicating copy to clipboard operation
vsmartcard copied to clipboard

[remote-reader] Fix ATR for 14443 Type B cards

Open mildsunrise opened this issue 2 years ago • 5 comments

Hi, thanks for the project! It has been very useful so far :)

For Type B cards, the Android app is currently calling IsoDep#getHiLayerResponse() to get the data to use as historical bytes in the generated wrapped ATR. According to the documentation, this method returns "a subset of the data in the ATTRIB response".

This is not compliant to the PC/SC spec; in the section defining what the wrapped ATR should be, it reads:

PC/SC part 3 section 3.1.3.2.3

For 14443 Type B smartcards, the historical data should be constructed from two fields of the ATQB (the application data and the protocol info) and a nibble from ATTRIB. This pull request implements this correctly by grabbing the necessary info from NfcB.

mildsunrise avatar Mar 13 '23 19:03 mildsunrise

Thank you. Could it be that the maximum frame size is miscalculated? ISO 14443-3: grafik It looks like a maximum frame size code of, e.g., 0 should be mapped to a maximum frame size of 16 bytes.

frankmorgner avatar Mar 14 '23 11:03 frankmorgner

you are completely right, I forgot to to translate the maximum frame size code into actual size. done.

another thing I forgot to mention is that this code has the edge case where it can't differentiate between MBLI=0 and MBLI=1. right now it's returning the 2nd thing, maybe it would be better to be conservative and return MBLI=0...

mildsunrise avatar Mar 14 '23 15:03 mildsunrise

I don't have experience on which value to choose as best guess, so I'd leave this up to you.

frankmorgner avatar Mar 14 '23 15:03 frankmorgner

I also don't have much experience... I'll ask around

mildsunrise avatar Mar 14 '23 16:03 mildsunrise

Hi! Any updates on this?

frankmorgner avatar Apr 12 '23 01:04 frankmorgner