AndyQ / NFCPassportReader

NFCPassportReader for iOS 13
MIT License
733 stars 235 forks source link

Add support for bigger than expected response sizes #201

Closed petteri-huusko-op closed 5 months ago

petteri-huusko-op commented 7 months ago

This should fix issue https://github.com/AndyQ/NFCPassportReader/issues/174

petteri-huusko-op commented 7 months ago

This fix is based on Finnish E-ID card spec (FINEID S1) Chapter 3.3. https://dvv.fi/documents/16079645/17324992/S1v40+(1).pdf/56a167fe-9f26-1fda-7d76-cfbbb29d184e/S1v40+(1).pdf?t=1679058112446

I don't have access to the actual ISO 7816 spec, but the above document cites it as normative source.

If my understanding is correct, the spec calls for to use GET RESPONSE (INS 0xC0) to read a command response in cases where the response length is unknown or greater than 256.

I do not have a list of commands which may have unknown length, so the implementation here reads while commands response sw1 indicates more data available (i.e. while sw1 == 0x61).

This works at least with the sample Finnish E-ID documents at my disposal.

AndyQ commented 5 months ago

Thanks for the PR