rgex / bondi-androidpassport-reader

18 stars 3 forks source link

[Feature Request] Add Support for Travel Permit for Mainland Residents to HK, Macau, and Taiwan #7

Open StephDC opened 4 years ago

StephDC commented 4 years ago

The Travel Permit for Mainland Residents Traveling to and from Hong Kong and Macao SAR is a "passport card"-like identification documentation that as its name suggests, a mainland China resident need to use it when traveling to HK and Macao. This card shares a lot of common properties with a regular electronic passport, as it is read by the same machine that reads regular passports, allows cross-border travel, and records visa information with all other info that is needed in a regular passport card.

Another similar card that was issued to Chinese nationals are the Travel Permit for Mainland Residents Traveling to Taiwan Region. This permit card is issued by the same government subsidiary and shares similar, if not identical data structure to the permit shown above.

An initial attempt using this app to read the content of such permits gives charming result - The Image and Security information are shown without any issue.

However there is a minor issue regarding the display of the Information section. It seems that although some of the information was read correctly, it did not show those information in the correct space.

The Document type shows CS, which is correct. The Issued By shows the Document No. instead. The Document No. shows the name of the card owner. The Date of Expiry shows something in 2062 in one card, and was left empty in another card - maybe it parses something else as date and failed. The Gender shows 1 - I am a male so it may be correct, maybe not. I cannot tell. The Nationality shows AN which seems another piece of Nonsense. All other fields are shown empty.

Given these information that had been presented in the current status, it seems that only minor effort such as changing the parser for the data read from this card was needed to add the support for such permit.

I wonder if it would be possible for this app to also support these cards, and if there is anything that I could help to add support for them, such as offering a dump of DG1 on these cards (If there is a way to do it on the app it may be another good feature to have).

rgex commented 4 years ago

Does the card looks like this?: https://upload.wikimedia.org/wikipedia/commons/0/03/Home_Return_Permit_New_Back.jpg?1577100546241

The DG1 just contains the MRTD text. Like this: IDFRABERTHIER<<<<<<<<<<<<<<<<<<<<<<<\n8806923102858CORINNE<<<<<<<6512068F6

StephDC commented 4 years ago

No. The card you mentioned is the permit to allow HK & Macau personnel to visit mainland China and what I am mentioning is another card. In WP as well as official website of HK Immigration Dept, it is called "Exit-Entry Permit for Traveling to and from Hong Kong and Macau"(EEP). The translation I used is what the Certificate Authority of the card reads and I did not realize that the translation is different until I just googled it. However I think this card should be similar to the two cards I mentioned though.

A photo of this card:

https://upload.wikimedia.org/wikipedia/commons/1/1d/Biometric_Two-way_Permit_%28Front%29.jpg

Although the EEP or whatever is also taking the form of a TD1 card, there is only one single line of the MRTD text on this card. The order of information seems also slightly off, resulting in the app fail to correctly read and fill the information to the view.

rgex commented 4 years ago

I see the problem, the MRZ is not a standard one, and it appears not to have the name in it. It is possible the the name could be in the DG11 see this image: https://cloud.githubusercontent.com/assets/3996942/19279771/1038bee8-8fe3-11e6-8e2c-d8324b607b41.png

Have tried another passport reader? Did it showed the name correctly? It would be disturbing to me if the name is not on the chip. This would make the card not be very safe...

StephDC commented 4 years ago

I tried ReadID (nl.innovalor.nfciddocshowcase) and it worked fine reading my name out of it. In that app, the "Full name" shows my name in Chinese, and listed my romanized name in "Other names". According to the schematics you mentioned, it is likely that they did save the name in DG11.

That app however read all dates wrong, showing 6 characters in the field. The Surname is also messed up with some nonsense letters and numbers. I saw my DoB was read out and shown on "Personal Number" but it was also not presented there.

In the Bondi app, I did actually see part of my name on the "Document No." part. Maybe it was just parsed wrong and filled into somewhere else? One of my hypothesis is that the name is present in the DG1 but not all of DG1 is printed on the card - thus the "non-standard MRZ".

If there is any method that I could dump all of the information obtained from there into a file maybe we could figure out what went wrong with this card...