AndyQ / NFCPassportReader

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

Change in APDU data & instructions due to some passports are giving error while scanning #180

Open kmgoyani opened 1 year ago

kmgoyani commented 1 year ago

I'm scanning the passport of Denmark. It is giving me a timeout error while NFC tag reading. I have solved that issue by changing APDU data & instructions in the TagReader.swift file & readCardAccess() method as below.

let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: 0x00, instructionCode: 0xA4, p1Parameter: 0x00, p2Parameter: 0x0C, data: Data([0x3f, 0x00, 0x30, 0x04]), expectedResponseLength: 256)

It works for me.

Please provide me access of the pull request.

danydev commented 11 months ago

@AndyQ it sounds like a low hanging fruit, what do you think?

AndyQ commented 11 months ago

I'll take a look hopefully in the next day or so!

AndyQ commented 11 months ago

Took a look this morning and unfortunately that breaks PACE on all my test passports. It doesn't like the extra parameters - 0x30, 0x04.

I get 0x67 0x00 - Wrong length response

Going back a few PRs - we had a discussion about this when I was implementing PACE: https://github.com/AndyQ/NFCPassportReader/issues/44#issuecomment-602803793

danydev commented 11 months ago

Those cases where something work in a document and fail in another are kind of scary,

I'm wondering, in those cases, is there the ability to try one way, and then fallback to the other in case of failure?

If this is possible, we could aim on safely\easily increasing the supported documents over time.

AndyQ commented 10 months ago

I need to do some more testing but from previous experience, I typically, when you get a failure in a service, the passport often kills the connection and you have to restart then whole discovery phase again! (which is somewhat annoying).

Now I'm hoping that in this case, just trying to selecting the Master Card index with additional options (which may fail) may not do this but we'll see!

danydev commented 10 months ago

I see! In those other cases, where you have to restart the whole discovery phase, you also mean that he needs to do again the step where the passport is actually read, right? Damn that's pity.

Maybe, if this is the case, we could offer an API where the "alternative command" can be enabled somehow, so that a developer that knows the "type of the document" (i.e. issuer nationality in practice) could set this on the options to be able to read that kind of document (I'm thinking on cases where people already do ocr for the MRZ and they could easily extract the issuer as well for this scope)