Skip to content

About

Open-source iOS app for reading and cryptographically verifying electronic passports (eMRTDs) using NFC, powered by gmrtd and GmrtdKit.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Inspekt.ID for iOS

CI Coverage Lines of Code Security Rating Maintainability Rating Reliability Rating Vulnerabilities Code Smells Technical Debt OpenSSF Scorecard License: MIT Platform: iOS 18.2+

Inspekt.ID reads and verifies the NFC chip in passports and identity cards (ICAO Doc 9303 eMRTDs) on iPhone, and explains the result in plain language. Everything is read and verified on the device.

It's the source of the official Inspekt.ID app, and a complete, real-world example of GmrtdKit, the Swift package around the gmrtd Go library.

Home screen    Result for the built-in sample document

Screenshots from the iOS Simulator. The result shown is gmrtd's built-in sample document, which deliberately fails verification (see Trying it without a document).

What it does

  1. Unlocks the chip with a key from the document: scan the MRZ (the machine-readable lines on the data page) with the camera, or enter the 6-digit CAN printed on some ID cards.
  2. Reads the chip over NFC using PACE or BAC: personal data (DG1), face image (DG2), additional details (DG11, DG12), security information (DG14) and the document security object (EF.SOD).
  3. Verifies it:
    • Passive Authentication checks that the data was signed by the issuing country and hasn't been altered, following the trust chain from the Document Signer to a country signing certificate (CSCA), including link certificates.
    • Active Authentication, Chip Authentication or PACE-CAM, where the document supports them, check that the chip is the original and not a copy.
  4. Explains the result: a plain-language summary ("Data Verified", "Original Chip") and a technical view of every data group, certificate and session detail, with a hex view of the raw data.
  5. Keeps a history of scans on the device. Scans can be exported as .gmrtd files and imported again, here or on another device, and are re-verified on import.

How it fits together

┌──────────────────────────────┐
│  Inspekt.ID (this repo)      │  UIKit app: scan flow, MRZ OCR (Vision), results,
│                              │  history, export/import, settings
├──────────────────────────────┤
│  GmrtdKit  (gmrtd-ios)       │  Swift package: CoreNFC session, MRTDReader,
│                              │  DocumentSummary, re-verification
├──────────────────────────────┤
│  gmrtd  (Gmrtd.xcframework)  │  Go library: ICAO 9303 protocols, LDS parsing,
│                              │  cryptographic verification, CSCA trust stores
└──────────────────────────────┘

The app does no cryptography of its own: reading and verification happen in gmrtd, driven through GmrtdKit. The app decides what to read (from Settings), and how to present and store the result.

Source layout

Path What's there
InspektID/AppCoordinator.swift Navigation and the scan flow: welcome, MRZ or CAN, NFC read, result. Also import and the sample document.
InspektID/MRZScanViewController.swift, VisionMRZOCRService.swift, MRZOverlayView.swift Camera MRZ scanning with Vision OCR, checked with GmrtdKit's MRZ validation
InspektID/CANEntryViewController.swift CAN entry
InspektID/NFCReadViewController.swift The chip read: MRTDReader, read options, NFC sheet text, error handling and retry guidance
InspektID/DocumentViewer/ The result screens: section builders that turn a DocumentSummary into rows (Icao9303Sections.swift), plain-language security explanations (SecurityExplanations.swift), and the views
InspektID/ScanHistoryStore.swift, ScanHistoryItem.swift, HistoryViewController.swift Scan history on the device
InspektID/TemporaryFiles.swift Export files and imported copies, and their clean-up
InspektID/SettingsViewController.swift, AboutViewController.swift Settings, reading options and About
InspektID/AppAnalytics.swift Optional Firebase Analytics and Crashlytics (see Analytics)
InspektIDTests/ Unit tests
Config/ Signing configuration and the Firebase template

Where GmrtdKit is used

GmrtdKit API Where
MRTDReader.read(credential:options:completion:), onStatus, onChipConnected, cancel() NFCReadViewController.swift
MRTDReadOptions (Require Authentic Document, Extended Length, Skip PACE, BAC fallback, PACE polling, Skip Images) NFCReadViewController.swift, set in SettingsViewController.swift
MRTDReadError: user-facing error text and retry guidance NFCReadViewController.swift
alertMessageProvider: the text in the iOS NFC sheet NFCReadViewController.nfcSheetText(for:)
MRTDCredential (.mrz, .can) AppCoordinator.swift, NFCReadViewController.swift
CscaCertPool.preload(): loading the CSCA trust store at launch, off the main thread AppDelegate.swift
DocumentSummary: personal data, the Passive Authentication trust chain, chipAuthenticity DocumentViewer/Icao9303Sections.swift, DocumentViewer/SecurityExplanations.swift
DocumentJsonRegenerator.regenerate(fromCbor:aaChallenge:trustedSource:): re-verifying saved and imported scans DocumentViewer/DocumentViewerViewController.swift, AppCoordinator.swift
aaChallenge: binding a scan to its Active Authentication challenge for later re-verification ChipData.swift, ScanHistoryItem.swift
SampleDocument: gmrtd's sample document, for trying the viewer without a chip AppCoordinator.swift, SampleDocumentTrigger.swift

Getting started

Requirements

  • A Mac with Xcode 26 or later (Firebase 13 needs Swift 6.2).
  • iOS 18.2 or later.
  • To read real documents:
    • an iPhone with NFC (any iPhone that runs iOS 18), and
    • a paid Apple Developer Program membership. A free Personal Team can't use the NFC Tag Reading capability.

You don't need an Apple Developer account to build the app or run it in the Simulator. The Simulator has no NFC or camera, but everything else runs there: the sample document, history, import, the result screens and the unit tests.

1. Run it in the Simulator

git clone https://github.com/gmrtd/InspektID-iOS.git
cd InspektID-iOS
open InspektID.xcodeproj

Swift Package Manager fetches the dependencies (GmrtdKit and Firebase) when the project opens; the first time takes a few minutes. Select the InspektID scheme and an iPhone Simulator, and run (⌘R). No accounts, keys or configuration files are needed.

Trying it without a document

Debug builds accept a launch argument that opens gmrtd's built-in sample document, so you can see the full result screens in the Simulator:

  1. Product → Scheme → Edit Scheme… → Run → Arguments
  2. Under Arguments Passed On Launch, add -ShowSampleDocument.

On an iPhone, you can also scan the sample MRZ in InspektID/SampleDocumentTrigger.swift (issuing state UTO, ICAO's fictitious test country) from your screen.

The sample combines ICAO's published worked examples, which come from different documents, so its data doesn't match its security object: it shows Verification Failed by design. It's marked as a sample everywhere it appears and is never treated as a real identity.

2. Set your team and bundle ID

The project doesn't include a development team, so signing for a device needs a small local file.

  1. Find your team ID: a 10-character code such as ABCDE12345. It's under Membership details in your Apple Developer account, or in Xcode under Settings → Accounts, by selecting your team. See Apple's Team ID entry.

  2. Create Config/Local.xcconfig from the template. It's git-ignored, so it stays on your Mac:

    cp Config/Local.example.xcconfig Config/Local.xcconfig
  3. Edit it to set your team, and a bundle ID you own:

    DEVELOPMENT_TEAM = ABCDE12345
    APP_BUNDLE_ID = com.yourname.inspektid
    

    The default bundle ID, id.inspekt.ios, belongs to the official app, so you can't sign with it. The .gmrtd document type is derived from the bundle ID (<bundle ID>.gmrtd-document), so your build won't claim the official app's file type.

Don't set the team in Xcode's Signing & Capabilities tab: that would change the shared project file. If Xcode still shows no team there after you create the file, close and reopen the project.

3. Set up the App ID and provisioning profile

The app needs one capability: NFC Tag Reading. It doesn't use iCloud, push notifications, App Groups, Associated Domains or any other capability. Camera access is a permission the user grants at runtime, not a capability.

The project already declares everything CoreNFC needs:

Where Setting
InspektID/InspektID.entitlements com.apple.developer.nfc.readersession.formats = PACE, TAG (the NFC Tag Reading entitlement)
InspektID/Info.plist com.apple.developer.nfc.readersession.iso7816.select-identifiers: the eMRTD application identifiers A0000002471001, A0000002472001 and 00000000000000
Build settings NFCReaderUsageDescription and NSCameraUsageDescription (the permission prompts)

Your App ID and provisioning profile just need to allow that entitlement. Choose one way:

Automatic signing (recommended). The project uses automatic signing. Connect your iPhone, select it as the run destination, and build. With your paid team set in step 2, Xcode registers the device, creates the App ID for your bundle ID with NFC Tag Reading turned on, and creates a development provisioning profile that includes it. You can check the result under Signing & Capabilities: Near Field Communication Tag Reading should be listed, with no errors.

Manual setup. If your organisation manages App IDs and profiles itself, in your Apple Developer account:

  1. Register your iPhone (Devices).
  2. Register an App ID (Identifiers) with your bundle ID, and under Capabilities turn on NFC Tag Reading.
  3. Create a development provisioning profile (Profiles) for that App ID, including your device and development certificate.
  4. Download the profile, and in Config/Local.xcconfig add CODE_SIGN_STYLE = Manual and PROVISIONING_PROFILE_SPECIFIER = <your profile's name>.

4. Run on your iPhone

  1. On the iPhone, turn on Developer Mode (Settings → Privacy & Security → Developer Mode) if you haven't already.
  2. In Xcode, select the iPhone as the destination and run (⌘R).
  3. In the app, scan the MRZ of a passport or ID card (or enter the CAN), then hold the top of the iPhone against the document's chip when asked.

If you plan to distribute your build, read TRADEMARKS.md first: you'll need your own name and icon.

Troubleshooting

Problem What to do
Signing for "InspektID" requires a development team Config/Local.xcconfig is missing or has no DEVELOPMENT_TEAM (step 2).
Failed to register bundle identifier / The app identifier cannot be registered to your development team The bundle ID is taken, for example the default id.inspekt.ios. Set your own APP_BUNDLE_ID (step 2).
Provisioning profile doesn't include the com.apple.developer.nfc.readersession.formats entitlement Your App ID doesn't have NFC Tag Reading. Turn it on for the App ID, then regenerate the profile (step 3). With automatic signing, Xcode does this when you rebuild.
Personal development teams do not support the NFC Tag Reading capability NFC needs a paid Apple Developer Program membership. You can still use the Simulator.
The app says chip scanning is unavailable You're running in the Simulator, or on a device without NFC.

Running the tests

xcodebuild test -project InspektID.xcodeproj -scheme InspektID \
  -destination 'platform=iOS Simulator,name=iPhone 17 Pro' \
  -only-testing:InspektIDTests CODE_SIGNING_ALLOWED=NO

Use any iPhone Simulator you have installed. The tests need no team or signing. CI runs the same tests on every pull request (.github/workflows/ci.yml).

Privacy

  • Reading and verification happen on the device. No document data, MRZ, CAN or chip contents are sent to any server. The app makes no network requests of its own; the only network traffic is Firebase, in official builds (see below).
  • The MRZ and CAN are never stored. Camera frames are processed in memory and never saved.
  • Scan history is stored on the device, in the app's container, with NSFileProtectionComplete. Like other app data, it's included in the device's iCloud or computer backups. It can be deleted one scan at a time, or all at once in Settings (Reset All History), which also deletes any leftover export and import files.
  • Exports are not encrypted. A .gmrtd export contains everything read from the chip, including the face image. The app says so, and the temporary copy is deleted once the share sheet closes.
  • The app switcher shows a cover instead of the screen while the app is in the background.

The official app's privacy policy is at inspekt.id/privacy.

Analytics and crash reporting

Official builds use Firebase Analytics to see where scans fail and Firebase Crashlytics for crash reports. Users can turn both off in Settings → Share Usage Data.

Analytics events record the step reached, timings, attempt counts, the method used (MRZ or CAN), the document type and issuing country, the verification outcome, and an error category with the error message (hex data and long numbers are removed from it). They never include names, dates of birth, document numbers, the MRZ, the CAN, photos or chip data. Firebase links events to a random installation identifier. The app has no ads, doesn't request tracking permission, and doesn't collect the advertising identifier.

Firebase is optional. It's only used when a GoogleService-Info.plist is in the app bundle, and that file isn't in this repository. A build from this repository has no analytics or crash reporting, and the Usage Data setting is hidden. To use your own Firebase project, download its GoogleService-Info.plist to InspektID/ (it's git-ignored); Config/GoogleService-Info.example.plist shows the expected format.

Limitations

Reading the chip

  • Chip reading needs the chip and the iPhone's NFC antenna (near the top of the phone) to line up and stay still for several seconds. Some documents, covers and phone cases make this difficult.
  • PACE Integrated Mapping (PACE-IM) isn't supported; documents that offer it alongside Generic Mapping are read with Generic Mapping.
  • Terminal Authentication isn't implemented, so fingerprint and iris images (DG3, DG4), which are protected by it, can't be read.

What verification proves, and what it doesn't

  • Passive Authentication proves that the data on the chip was signed by a Document Signer chaining to a CSCA in the trust store, and hasn't been altered. It's only as complete as the trust store: gmrtd's built-in CSCA lists cover 121 countries. A genuine document from an issuer that isn't covered can't be verified, and shows as Data Unverified, with the reason in its details.
  • Certificate revocation isn't checked. A Document Signer or CSCA that has since been revoked still verifies.
  • Passive Authentication alone doesn't detect a cloned chip, because the signed data can be copied byte for byte. Only Active Authentication, Chip Authentication or PACE-CAM prove that the chip is the original, and not every document supports them. The app reports a failed chip check as a failure, and a document without any as "Clone Protection Not Available".
  • An imported .gmrtd file can't prove which chip it came from. Its data is re-verified, but chip authentication recorded in the file isn't counted, so an import can show "Limited Verification" at best.
  • The chip proves the document, not the person. Verification says nothing about whether the person presenting the document is its holder; compare them with the face image.
  • Inspekt.ID is a reference implementation and a tool for inspecting documents. It is not a certified identity-verification product, and it shouldn't be the only check where the outcome matters.

Contributing and security

Contributions are welcome: see CONTRIBUTING.md. Please report vulnerabilities privately, as described in SECURITY.md. Never include real document data in issues, pull requests or test files.

Licence and trademarks

The source code is licensed under the MIT License. The Inspekt.ID name, logo and app icon are not covered by it and are reserved: see TRADEMARKS.md. Third-party components are listed in THIRD_PARTY_NOTICES.md.

Related

About

Open-source iOS app for reading and cryptographically verifying electronic passports (eMRTDs) using NFC, powered by gmrtd and GmrtdKit.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages