Search code examples
pythonnfcapdu

Steps to make NFC ePassport APDU authentication work?


I'm working on a project where a mobile app has to communicate with ePassport via NFC. We have to pull out just the basic data about users like first and last name, DOB, photo, etc. After reading similar posts, reading the specs on icao.int and the code of the library pyPassport, I'm still not sure what should be the first APDU command to be sent to ePassport. How to begin?

According to what I've read, it looks like it should be get challenge command 00 84 00 00 08 (somewhere is B4 instead of 84), but unfortunately I always get 63 00 response (no information given).

I know that before getting the data, I need to do the BAC. I saw the examples in the spec from above and I think I could code the BAC, but how to get to it? Does anybody know the flow/steps of how to begin and which authentification needs to be done (passive/active)?


Solution

  • I'm not exactly sure why you got 6300 response but I think it is because the epassport application is not yet selected. I could be wrong though.

    BAC is the combination of GET CHALLENGE (00 84 00 00 08) and EXTERNAL AUTHENTICATE commands. You only need BAC authentication in order to read basic passport holder info.

    Here is the sequence of commands you need to send to read data from a passport:

    1. Select - select the epassport application
    2. Get Challenge
    3. External Authenticate
    4. Read Binary (protected by secure messaging) - read the DG1 file which contains basic passport holder info
    5. Read Binary (protected by secure messaging) - read the DG2 file which contains the photo of the passport holder info

    I can provide more details if needed. But for the meantime, you may also refer to ICAO Doc 9303, Machine Readable Travel Documents Part 3 Volume 2 for BAC specifications.