Skip to content

Conversation

@xlokk73
Copy link

@xlokk73 xlokk73 commented Apr 24, 2025

Add PACE-CAN Authentication Support

Overview

This PR adds support for PACE authentication using Card Access Number (CAN) as an alternative to MRZ. The implementation is non-breaking, maintaining backward compatibility with existing code while adding new functionality.

Key Changes

  • Added support for CAN-based PACE authentication as an alternative to MRZ
  • Created a PACEPasswordType enum to distinguish between authentication methods
  • Added password validation for different authentication types
  • Updated UI in sample app to allow users to choose between MRZ and CAN authentication
  • Enhanced error handling to provide specific error messages for CAN-related issues
  • Updated NFCViewDisplayMessage to support CAN-specific display messages

Implementation Details

  • Updated PassportReader.swift to accept either MRZ or CAN through the readPassport method
  • Modified PACEHandler.swift to handle different password types
  • Added PACEPasswordValidator.swift to validate input based on password type
  • Updated error handling in NFCPassportReaderError with a dedicated InvalidCAN case
  • Enhanced the sample app UI with a segmented control for authentication method selection

Backward Compatibility

  • Carefully maintained the original API signature for MRZ-based authentication
  • Sample app demonstrates both the original API call pattern for MRZ and the new pattern for CAN
  • Existing code using MRZ authentication will continue to work without changes

Benefits

  • Supports e-passports and ID cards that require CAN authentication
  • Maintains backward compatibility with existing integrations
  • Provides clear user feedback for authentication failures
  • Improves accessibility of the library by supporting more authentication methods

Testing

The changes have been tested with both MRZ and CAN authentication methods on supported documents. The sample app has been updated to demonstrate both authentication methods working correctly.

Screenshots

IMG_1660
IMG_1659

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

Successfully merging this pull request may close these issues.

1 participant