newlogic / smartscanner-core

ID scanning Android app and library. Supports MRZ, NFC, Barcodes, and ID PASS Lite cards.
Apache License 2.0
72 stars 19 forks source link

Add boolean flag to control DG2 read #75

Closed typelogic closed 3 years ago

typelogic commented 3 years ago

Issue

For issue#70 adding a flag to read DG2 or not.

[70] [Add flag to read e-passport photoAdd flag to read e-passport photo]

Changes

The existing code base has an inherent logic that deals when a read permission is not satisfied and as a result, a data group is unreadable. Inserting the new flag into this logic results in a minimal change.

  1. Pass a boolean flag to the NFCDocumentTag constructor here
  2. The flag will propagate to PassportNFC instance
  3. The flag is used in PassportNFC::getDG( ) method to control the DG2 read.

The verifyHash() will skip the hash check for DG2 (ie, modified flow will not read DG2) in use cases where the photo from DG2 is not needed. For other cases where the photo is retrieved (because it needs to be displayed in a UI), then verifyHash() will read DG2 to calculate its value and compare (ie, original flow).