Skip to content
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

TagReader keeps failing on reading DG2 from older dutch passport. #206

Open
Azmat520 opened this issue Mar 14, 2024 · 4 comments
Open

TagReader keeps failing on reading DG2 from older dutch passport. #206

Azmat520 opened this issue Mar 14, 2024 · 4 comments

Comments

@Azmat520
Copy link

Azmat520 commented Mar 14, 2024

Hi Andy,

I've encountered an issue with NFC reader:
I consistently receive a 'Session Invalidated' error when reading DG2 with Dutch passports from 2015 and 2016.
However, it works perfectly with passports from 2018.

Your assistance would be greatly appreciated!

See log for more detail:
PS: The following log repeats itself like 3-4 times when reading DG2 before I get session invalidated by user. It seems like the package is having trouble reading the DG2 of the passports from these years and keeps trying before iOS invalidates it.

2024-03-14 12:56:28.967553+0100 Runner[676:61907] [tagReader] TagReader - Amount of data left to read - 3672
2024-03-14 12:56:28.968375+0100 Runner[676:61907] [CoreNFC] -[NFCTagReaderSession setAlertMessage:]:101 (null)
2024-03-14 12:56:28.968520+0100 Runner[676:61907] [tagReader] TagReader - data bytes remaining: 3672, will read : 160
2024-03-14 12:56:28.968581+0100 Runner[676:61907] [tagReader] TagReader - sending [0x00, 0xB0, 0x2C, 0x64, 0xA0]
2024-03-14 12:56:28.968665+0100 Runner[676:61907] [secureMessaging] SSC: 00000000000000BE
2024-03-14 12:56:28.968704+0100 Runner[676:61907] [secureMessaging] Increment SSC with 1
2024-03-14 12:56:28.968767+0100 Runner[676:61907] [secureMessaging] SSC: 00000000000000BF
2024-03-14 12:56:28.968776+0100 Runner[676:61907] [secureMessaging] Mask class byte and pad command header
2024-03-14 12:56:28.968855+0100 Runner[676:61907] [secureMessaging] CmdHeader: 0CB02C64800000000000000000000000
2024-03-14 12:56:28.968882+0100 Runner[676:61907] [secureMessaging] Build DO'97
2024-03-14 12:56:28.968937+0100 Runner[676:61907] [secureMessaging] DO97: [151, 1, 160]
2024-03-14 12:56:28.968980+0100 Runner[676:61907] [secureMessaging] Concatenate CmdHeader and DO97
2024-03-14 12:56:28.970058+0100 Runner[676:61907] [secureMessaging] M: 0CB02C648000000000000000000000009701A0
2024-03-14 12:56:28.970076+0100 Runner[676:61907] [secureMessaging] Compute MAC of M
2024-03-14 12:56:28.970087+0100 Runner[676:61907] [secureMessaging] Concatenate SSC and M and add padding
2024-03-14 12:56:28.970229+0100 Runner[676:61907] [secureMessaging] N: 000000000000000000000000000000BF0CB02C648000000000000000000000009701A080000000000000000000000000
2024-03-14 12:56:28.970347+0100 Runner[676:61907] [openSSL] aesMac - mac - 599A806B9549ADE358588C78B4765F8600000000000000000000000000000000
2024-03-14 12:56:28.970362+0100 Runner[676:61907] [secureMessaging] Compute MAC over N with KSmac
2024-03-14 12:56:28.970418+0100 Runner[676:61907] [secureMessaging] CC: 599A806B9549ADE3
2024-03-14 12:56:28.970430+0100 Runner[676:61907] [secureMessaging] Build DO'8E
2024-03-14 12:56:28.970489+0100 Runner[676:61907] [secureMessaging] DO8E: 8E08599A806B9549ADE3
2024-03-14 12:56:28.970663+0100 Runner[676:61907] [secureMessaging] Construct and send protected APDU
2024-03-14 12:56:28.970762+0100 Runner[676:61907] [secureMessaging] ProtectedAPDU: 0CB02C640D9701A08E08599A806B9549ADE300
2024-03-14 12:56:28.970830+0100 Runner[676:61907] [tagReader] TagReader - [SM] [0x0C, 0xB0, 0x2C, 0x64, 0x0D, 0x97, 0x01, 0xA0, 0x8E, 0x08, 0x59, 0x9A, 0x80, 0x6B, 0x95, 0x49, 0xAD, 0xE3, 0x00]
2024-03-14 12:56:28.970973+0100 Runner[676:61907] [passportReader] tagReaderSession:failed to connect to tag - Session invalidated
error is Unknown error: Session invalidated
2024-03-14 12:56:28.975699+0100 Runner[676:61416] flutter: NFC scan error PlatformException(Unknown(Error Domain=NFCError Code=103 "Session invalidated" UserInfo={NSLocalizedDescription=Session invalidated}), CustomNFCError, Stacktrace: ["0 Runner 0x0000000104fbf03c $s6Runner9wrapError33_B10FFED2E8B44F5DE265B338CDAFC393LLySayypSgGypF + 1300", "1 Runner 0x0000000104fc10d0 $s6Runner17NfcReaderApiSetupC5setUp15binaryMessenger3apiySo013FlutterBinaryI0_p_AA0bcD0_pSgtFZyypSg_yAJctcfU_ys6ResultOySDySSSgAJGSgs5Error_pGcfU_ + 444", "2 Runner 0x0000000104fd1548 $s6Runner9NFCReaderC7readNFC3mrz10completionyAA3MrzV_ys6ResultOySDySSSgypSgGSgs5Error_pGctFyyYaYbcfU_TY3_ + 1564", "3 Runner 0x0000000104fd17e9 $s6Runner9NFCReaderC7readNFC3mrz10completionyAA3MrzV_ys6ResultOySDySSSgypSgGSgs5Error_pGctFyyYaYbcfU_TATQ0_ + 1", "4 Runner 0x0000000104f5b229 $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ0_ + 1", "5 Runner 0x0000000104f5db3d $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_ + 1", "6 libswift_Concurrency.dylib 0x00000001c4f033a1 31E32FAC-2DC9-326E-84FE-D7F092C3BAE9 + 295841"], null)
2024-03-14 12:56:31.743951+0100 Runner[676:61413] [passportReader] tagReaderSession:didInvalidateWithError - Session invalidated by user

@rbrouwer
Copy link

rbrouwer commented Apr 8, 2024

iOS invalidates the NFC session after a certain time out. How ReadId can read it quicker (to avoid this issue) I do not know.

It also isn't only Dutch passports, but there are more documents that are slow enough that the entire transaction takes too long.

@Azmat520
Copy link
Author

iOS invalidates the NFC session after a certain time out. How ReadId can read it quicker (to avoid this issue) I do not know.

It also isn't only Dutch passports, but there are more documents that are slow enough that the entire transaction takes too long.

True! Sorry for the confusion, I should have been clearer. The log that I shared repeats itself about 3 or 4 times at "Reading DG2...". It seems like the package is having trouble reading the DG2 data from passports of these years and keeps retrying before iOS invalidates it. (I also updated my description)

@rbrouwer
Copy link

The method to read a datagroup is to sent a select-command. That command is then followed by 1 or many read-command. After the first read command, the first bytes are read to see how long the DataGroup is and based on that it will repeatedly sent more read-commands. The read-command only reads 160 bytes in your case. DG2 is about 4KB, so it will do that several times.

Those few lines says a lot about that "repeating":

TagReader - Amount of data left to read - 3672
data bytes remaining: 3672, will read : 160

So in your case, it would have repeated that for another 22 times if iOS didn't "Invalidate Session". As much as I would love this fixed and know how to either make iOS not do that or how to make it read quicker (or the reading handling this and reconnecting and continuing where it left off), nothing in that log is anything that shouldn't happen.

It isn't retrying!

@Azmat520
Copy link
Author

Azmat520 commented May 2, 2024

The method to read a datagroup is to sent a select-command. That command is then followed by 1 or many read-command. After the first read command, the first bytes are read to see how long the DataGroup is and based on that it will repeatedly sent more read-commands. The read-command only reads 160 bytes in your case. DG2 is about 4KB, so it will do that several times.

Those few lines says a lot about that "repeating":

TagReader - Amount of data left to read - 3672
data bytes remaining: 3672, will read : 160

So in your case, it would have repeated that for another 22 times if iOS didn't "Invalidate Session". As much as I would love this fixed and know how to either make iOS not do that or how to make it read quicker (or the reading handling this and reconnecting and continuing where it left off), nothing in that log is anything that shouldn't happen.

It isn't retrying!

aha, thanks for the explanation.
So if I understand it correctly, it's just some documents takes long time to read and cause this issue. Which I can not do much about it right now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants