@vppos/react-native-nfc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/NFCSDK.podspec +40 -0
- package/android/build.gradle +85 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +31 -0
- package/android/src/main/AndroidManifestNew.xml +30 -0
- package/android/src/main/java/com/nfcsdk/ChipReader.kt +237 -0
- package/android/src/main/java/com/nfcsdk/NFCSDKModule.kt +78 -0
- package/android/src/main/java/com/nfcsdk/NFCSDKPackage.kt +17 -0
- package/android/src/main/java/com/nfcsdk/NFCScanActivity.kt +299 -0
- package/android/src/main/java/com/nfcsdk/utils/Dg13Parser.kt +278 -0
- package/android/src/main/java/com/nfcsdk/utils/FaceExtractor.kt +40 -0
- package/android/src/main/java/com/nfcsdk/utils/MrzUtils.kt +75 -0
- package/android/src/main/res/drawable/bg_nfc_bottom_sheet.xml +13 -0
- package/android/src/main/res/drawable/bg_nfc_sheet_handle.xml +9 -0
- package/android/src/main/res/layout/activity_nfc.xml +110 -0
- package/android/src/main/res/values/styles.xml +10 -0
- package/android/src/main/res/xml/nfc_tech_filter.xml +8 -0
- package/ios/ChipReader.swift +258 -0
- package/ios/NFCSDK-Bridging-Header.h +2 -0
- package/ios/NFCSDK.mm +9 -0
- package/ios/NFCSDK.swift +112 -0
- package/ios/NFCSDKSession.swift +5 -0
- package/ios/utils/DG13Parser.swift +302 -0
- package/ios/utils/MrzUtils.swift +49 -0
- package/lib/module/errors.js +9 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +118 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/errors.d.ts +4 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +80 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +45 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +155 -0
- package/src/errors.ts +6 -0
- package/src/index.tsx +141 -0
- package/src/types.ts +45 -0
- package/vendor/ios-passport-reader/CHANGELOG +362 -0
- package/vendor/ios-passport-reader/CODE_OF_CONDUCT.md +77 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/AppDelegate.swift +39 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Info.plist +77 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/PassportUtils.swift +76 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/SettingsStore.swift +107 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/SceneDelegate.swift +57 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/DetailsView.swift +197 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MainView.swift +214 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportView.swift +73 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/SettingsView.swift +63 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/StoredPassportView.swift +152 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/masterList.pem +32 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/readme.md +10 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/project.pbxproj +695 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/contents.xcworkspacedata +10 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/DataGroupParsingTests.swift +189 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/Info.plist +22 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/PACETests.swift +112 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile +22 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile.lock +35 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/README.md +2 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/AppDelegate.swift +39 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Info.plist +79 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/PassportUtils.swift +99 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStore.swift +98 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStoreCAN.swift +75 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/LICENSE +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/PreviewView.swift +34 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/StringUtils.swift +160 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/ViewController.swift +320 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/VisionViewController.swift +163 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/SceneDelegate.swift +58 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/CanKeyView.swift +251 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/MRZEntryViewCanKey.swift +65 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/PassportViewCAN.swift +73 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/DetailsView.swift +193 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MainView.swift +264 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportView.swift +73 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/SettingsView.swift +47 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/StoredPassportView.swift +149 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/masterList.pem +32 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/readme.md +10 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.pbxproj +683 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +25 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/DataGroupParsingTests.swift +190 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/Info.plist +22 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/PACETests.swift +112 -0
- package/vendor/ios-passport-reader/LICENSE +21 -0
- package/vendor/ios-passport-reader/NFCPassportReader.podspec +27 -0
- package/vendor/ios-passport-reader/Package.swift +29 -0
- package/vendor/ios-passport-reader/README.md +141 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/AES_3DES_DESEncryption.swift +377 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/BACHandler.swift +194 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/ChipAuthenticationHandler.swift +224 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupHash.swift +16 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupParser.swift +36 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ActiveAuthenticationInfo.swift +69 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/COM.swift +61 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/CardAccess.swift +38 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationInfo.swift +135 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationPublicKeyInfo.swift +53 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup.swift +103 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup1.swift +111 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup11.swift +66 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup12.swift +75 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup14.swift +37 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup15.swift +46 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup2.swift +163 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup7.swift +46 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroupId.swift +105 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/NotImplementedDG.swift +16 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/PACEInfo.swift +415 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SOD.swift +240 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SecurityInfo.swift +136 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Errors.swift +148 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Logging.swift +32 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Models/FaceImageInfo.swift +161 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCPassportModel.swift +540 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCViewDisplayMessage.swift +60 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/OpenSSLUtils.swift +705 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/PACEHandler.swift +627 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/PassportReader.swift +387 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Resources/PrivacyInfo.xcprivacy +14 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/ResponseAPDU.swift +25 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessaging.swift +301 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessagingSessionKeyGenerator.swift +156 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/SimpleASN1DumpParser.swift +173 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/TagReader.swift +374 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Utils.swift +430 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/X509Wrapper.swift +168 -0
- package/vendor/ios-passport-reader/scripts/README.md +45 -0
- package/vendor/ios-passport-reader/scripts/extract.py +197 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
@available(iOS 13, macOS 10.15, *)
|
|
10
|
+
public class DataGroup {
|
|
11
|
+
public var datagroupType : DataGroupId { .Unknown }
|
|
12
|
+
|
|
13
|
+
/// Body contains the actual data
|
|
14
|
+
public private(set) var body : [UInt8] = []
|
|
15
|
+
|
|
16
|
+
/// Data contains the whole DataGroup data (as that is what the hash is calculated from
|
|
17
|
+
public private(set) var data : [UInt8] = []
|
|
18
|
+
|
|
19
|
+
var pos = 0
|
|
20
|
+
|
|
21
|
+
required init( _ data : [UInt8] ) throws {
|
|
22
|
+
self.data = data
|
|
23
|
+
|
|
24
|
+
// Skip the first byte which is the header byte
|
|
25
|
+
pos = 1
|
|
26
|
+
let _ = try getNextLength()
|
|
27
|
+
self.body = [UInt8](data[pos...])
|
|
28
|
+
|
|
29
|
+
try parse(data)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func parse( _ data:[UInt8] ) throws {
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func getNextTag() throws -> Int {
|
|
36
|
+
var tag = 0
|
|
37
|
+
|
|
38
|
+
// Fix for some passports that may have invalid data - ensure that we do have data!
|
|
39
|
+
guard data.count > pos else {
|
|
40
|
+
throw NFCPassportReaderError.TagNotValid
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if binToHex(data[pos]) & 0x0F == 0x0F {
|
|
44
|
+
tag = Int(binToHex(data[pos..<pos+2]))
|
|
45
|
+
pos += 2
|
|
46
|
+
} else {
|
|
47
|
+
tag = Int(data[pos])
|
|
48
|
+
pos += 1
|
|
49
|
+
}
|
|
50
|
+
return tag
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func getNextLength() throws -> Int {
|
|
54
|
+
let end = pos+4 < data.count ? pos+4 : data.count
|
|
55
|
+
let (len, lenOffset) = try asn1Length([UInt8](data[pos..<end]))
|
|
56
|
+
pos += lenOffset
|
|
57
|
+
return len
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func getNextValue() throws -> [UInt8] {
|
|
61
|
+
let length = try getNextLength()
|
|
62
|
+
let value = [UInt8](data[pos ..< pos+length])
|
|
63
|
+
pos += length
|
|
64
|
+
return value
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public func hash( _ hashAlgorythm: String ) -> [UInt8] {
|
|
68
|
+
var ret : [UInt8] = []
|
|
69
|
+
if hashAlgorythm == "SHA1" {
|
|
70
|
+
ret = calcSHA1Hash(self.data)
|
|
71
|
+
} else if hashAlgorythm == "SHA224" {
|
|
72
|
+
ret = calcSHA224Hash(self.data)
|
|
73
|
+
} else if hashAlgorythm == "SHA256" {
|
|
74
|
+
ret = calcSHA256Hash(self.data)
|
|
75
|
+
} else if hashAlgorythm == "SHA384" {
|
|
76
|
+
ret = calcSHA384Hash(self.data)
|
|
77
|
+
} else if hashAlgorythm == "SHA512" {
|
|
78
|
+
ret = calcSHA512Hash(self.data)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return ret
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public func verifyTag(_ tag: Int, equals expectedTag: Int) throws {
|
|
85
|
+
if tag != expectedTag {
|
|
86
|
+
throw NFCPassportReaderError.InvalidResponse(
|
|
87
|
+
dataGroupId: datagroupType,
|
|
88
|
+
expectedTag: expectedTag,
|
|
89
|
+
actualTag: tag
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public func verifyTag(_ tag: Int, oneOf expectedTags: [Int]) throws {
|
|
95
|
+
if !expectedTags.contains(tag) {
|
|
96
|
+
throw NFCPassportReaderError.InvalidResponse(
|
|
97
|
+
dataGroupId: datagroupType,
|
|
98
|
+
expectedTag: expectedTags.first!,
|
|
99
|
+
actualTag: tag
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup1.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
@available(iOS 13, macOS 10.15, *)
|
|
10
|
+
public enum DocTypeEnum: String {
|
|
11
|
+
case TD1
|
|
12
|
+
case TD2
|
|
13
|
+
case OTHER
|
|
14
|
+
|
|
15
|
+
var desc: String {
|
|
16
|
+
get {
|
|
17
|
+
return self.rawValue
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@available(iOS 13, macOS 10.15, *)
|
|
23
|
+
public class DataGroup1 : DataGroup {
|
|
24
|
+
public private(set) var elements : [String:String] = [:]
|
|
25
|
+
|
|
26
|
+
public override var datagroupType: DataGroupId { .DG1 }
|
|
27
|
+
|
|
28
|
+
required init( _ data : [UInt8] ) throws {
|
|
29
|
+
try super.init(data)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override func parse(_ data: [UInt8]) throws {
|
|
33
|
+
let tag = try getNextTag()
|
|
34
|
+
try verifyTag(tag, equals: 0x5F1F)
|
|
35
|
+
let body = try getNextValue()
|
|
36
|
+
let docType = getMRZType(length:body.count)
|
|
37
|
+
|
|
38
|
+
switch docType {
|
|
39
|
+
case .TD1:
|
|
40
|
+
self.parseTd1(body)
|
|
41
|
+
case .TD2:
|
|
42
|
+
self.parseTd2(body)
|
|
43
|
+
default:
|
|
44
|
+
self.parseOther(body)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Store MRZ data
|
|
48
|
+
elements["5F1F"] = String(bytes: body, encoding:.utf8)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func parseTd1(_ data : [UInt8]) {
|
|
52
|
+
elements["5F03"] = String(bytes: data[0..<2], encoding:.utf8)
|
|
53
|
+
elements["5F28"] = String( bytes:data[2..<5], encoding:.utf8)
|
|
54
|
+
elements["5A"] = String( bytes:data[5..<14], encoding:.utf8)
|
|
55
|
+
elements["5F04"] = String( bytes:data[14..<15], encoding:.utf8)
|
|
56
|
+
elements["53"] = (String( bytes:data[15..<30], encoding:.utf8) ?? "") +
|
|
57
|
+
(String( bytes:data[48..<59], encoding:.utf8) ?? "")
|
|
58
|
+
elements["5F57"] = String( bytes:data[30..<36], encoding:.utf8)
|
|
59
|
+
elements["5F05"] = String( bytes:data[36..<37], encoding:.utf8)
|
|
60
|
+
elements["5F35"] = String( bytes:data[37..<38], encoding:.utf8)
|
|
61
|
+
elements["59"] = String( bytes:data[38..<44], encoding:.utf8)
|
|
62
|
+
elements["5F06"] = String( bytes:data[44..<45], encoding:.utf8)
|
|
63
|
+
elements["5F2C"] = String( bytes:data[45..<48], encoding:.utf8)
|
|
64
|
+
elements["5F07"] = String( bytes:data[59..<60], encoding:.utf8)
|
|
65
|
+
elements["5B"] = String( bytes:data[60...], encoding:.utf8)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
func parseTd2(_ data : [UInt8]) {
|
|
69
|
+
elements["5F03"] = String( bytes:data[0..<2], encoding:.utf8)
|
|
70
|
+
elements["5F28"] = String( bytes:data[2..<5], encoding:.utf8)
|
|
71
|
+
elements["5B"] = String( bytes:data[5..<36], encoding:.utf8)
|
|
72
|
+
elements["5A"] = String( bytes:data[36..<45], encoding:.utf8)
|
|
73
|
+
elements["5F04"] = String( bytes:data[45..<46], encoding:.utf8)
|
|
74
|
+
elements["5F2C"] = String( bytes:data[46..<49], encoding:.utf8)
|
|
75
|
+
elements["5F57"] = String( bytes:data[49..<55], encoding:.utf8)
|
|
76
|
+
elements["5F05"] = String( bytes:data[55..<56], encoding:.utf8)
|
|
77
|
+
elements["5F35"] = String( bytes:data[56..<57], encoding:.utf8)
|
|
78
|
+
elements["59"] = String( bytes:data[57..<63], encoding:.utf8)
|
|
79
|
+
elements["5F06"] = String( bytes:data[63..<64], encoding:.utf8)
|
|
80
|
+
elements["53"] = String( bytes:data[64..<71], encoding:.utf8)
|
|
81
|
+
elements["5F07"] = String( bytes:data[71..<72], encoding:.utf8)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func parseOther(_ data : [UInt8]) {
|
|
85
|
+
elements["5F03"] = String( bytes:data[0..<2], encoding:.utf8)
|
|
86
|
+
elements["5F28"] = String( bytes:data[2..<5], encoding:.utf8)
|
|
87
|
+
elements["5B"] = String( bytes:data[5..<44], encoding:.utf8)
|
|
88
|
+
elements["5A"] = String( bytes:data[44..<53], encoding:.utf8)
|
|
89
|
+
elements["5F04"] = String( bytes:[data[53]], encoding:.utf8)
|
|
90
|
+
elements["5F2C"] = String( bytes:data[54..<57], encoding:.utf8)
|
|
91
|
+
elements["5F57"] = String( bytes:data[57..<63], encoding:.utf8)
|
|
92
|
+
elements["5F05"] = String( bytes:[data[63]], encoding:.utf8)
|
|
93
|
+
elements["5F35"] = String( bytes:[data[64]], encoding:.utf8)
|
|
94
|
+
elements["59"] = String( bytes:data[65..<71], encoding:.utf8)
|
|
95
|
+
elements["5F06"] = String( bytes:[data[71]], encoding:.utf8)
|
|
96
|
+
elements["53"] = String( bytes:data[72..<86], encoding:.utf8)
|
|
97
|
+
elements["5F02"] = String( bytes:[data[86]], encoding:.utf8)
|
|
98
|
+
elements["5F07"] = String( bytes:[data[87]], encoding:.utf8)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private func getMRZType(length: Int) -> DocTypeEnum {
|
|
102
|
+
if length == 0x5A {
|
|
103
|
+
return .TD1
|
|
104
|
+
}
|
|
105
|
+
if length == 0x48 {
|
|
106
|
+
return .TD2
|
|
107
|
+
}
|
|
108
|
+
return .OTHER
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup11.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
@available(iOS 13, macOS 10.15, *)
|
|
10
|
+
public class DataGroup11 : DataGroup {
|
|
11
|
+
|
|
12
|
+
public private(set) var fullName : String?
|
|
13
|
+
public private(set) var personalNumber : String?
|
|
14
|
+
public private(set) var dateOfBirth : String?
|
|
15
|
+
public private(set) var placeOfBirth : String?
|
|
16
|
+
public private(set) var address : String?
|
|
17
|
+
public private(set) var telephone : String?
|
|
18
|
+
public private(set) var profession : String?
|
|
19
|
+
public private(set) var title : String?
|
|
20
|
+
public private(set) var personalSummary : String?
|
|
21
|
+
public private(set) var proofOfCitizenship : String?
|
|
22
|
+
public private(set) var tdNumbers : String?
|
|
23
|
+
public private(set) var custodyInfo : String?
|
|
24
|
+
|
|
25
|
+
public override var datagroupType: DataGroupId { .DG11 }
|
|
26
|
+
|
|
27
|
+
required init( _ data : [UInt8] ) throws {
|
|
28
|
+
try super.init(data)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override func parse(_ data: [UInt8]) throws {
|
|
32
|
+
var tag = try getNextTag()
|
|
33
|
+
try verifyTag(tag, equals: 0x5C)
|
|
34
|
+
_ = try getNextValue()
|
|
35
|
+
|
|
36
|
+
repeat {
|
|
37
|
+
tag = try getNextTag()
|
|
38
|
+
let val = try String( bytes:getNextValue(), encoding:.utf8)
|
|
39
|
+
if tag == 0x5F0E {
|
|
40
|
+
fullName = val
|
|
41
|
+
} else if tag == 0x5F10 {
|
|
42
|
+
personalNumber = val
|
|
43
|
+
} else if tag == 0x5F11 {
|
|
44
|
+
placeOfBirth = val
|
|
45
|
+
} else if tag == 0x5F2B {
|
|
46
|
+
dateOfBirth = val
|
|
47
|
+
} else if tag == 0x5F42 {
|
|
48
|
+
address = val
|
|
49
|
+
} else if tag == 0x5F12 {
|
|
50
|
+
telephone = val
|
|
51
|
+
} else if tag == 0x5F13 {
|
|
52
|
+
profession = val
|
|
53
|
+
} else if tag == 0x5F14 {
|
|
54
|
+
title = val
|
|
55
|
+
} else if tag == 0x5F15 {
|
|
56
|
+
personalSummary = val
|
|
57
|
+
} else if tag == 0x5F16 {
|
|
58
|
+
proofOfCitizenship = val
|
|
59
|
+
} else if tag == 0x5F17 {
|
|
60
|
+
tdNumbers = val
|
|
61
|
+
} else if tag == 0x5F18 {
|
|
62
|
+
custodyInfo = val
|
|
63
|
+
}
|
|
64
|
+
} while pos < data.count
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup12.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
@available(iOS 13, macOS 10.15, *)
|
|
10
|
+
public class DataGroup12 : DataGroup {
|
|
11
|
+
public private(set) var issuingAuthority : String?
|
|
12
|
+
public private(set) var dateOfIssue : String?
|
|
13
|
+
public private(set) var otherPersonsDetails : String?
|
|
14
|
+
public private(set) var endorsementsOrObservations : String?
|
|
15
|
+
public private(set) var taxOrExitRequirements : String?
|
|
16
|
+
public private(set) var frontImage : [UInt8]?
|
|
17
|
+
public private(set) var rearImage : [UInt8]?
|
|
18
|
+
public private(set) var personalizationTime : String?
|
|
19
|
+
public private(set) var personalizationDeviceSerialNr : String?
|
|
20
|
+
|
|
21
|
+
public override var datagroupType: DataGroupId { .DG12 }
|
|
22
|
+
|
|
23
|
+
required init( _ data : [UInt8] ) throws {
|
|
24
|
+
try super.init(data)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override func parse(_ data: [UInt8]) throws {
|
|
28
|
+
var tag = try getNextTag()
|
|
29
|
+
try verifyTag(tag, equals: 0x5C)
|
|
30
|
+
|
|
31
|
+
// Skip the taglist - ideally we would check this but...
|
|
32
|
+
let _ = try getNextValue()
|
|
33
|
+
|
|
34
|
+
repeat {
|
|
35
|
+
tag = try getNextTag()
|
|
36
|
+
let val = try getNextValue()
|
|
37
|
+
|
|
38
|
+
if tag == 0x5F19 {
|
|
39
|
+
issuingAuthority = String( bytes:val, encoding:.utf8)
|
|
40
|
+
} else if tag == 0x5F26 {
|
|
41
|
+
dateOfIssue = parseDateOfIssue(value: val)
|
|
42
|
+
} else if tag == 0xA0 {
|
|
43
|
+
// Not yet handled
|
|
44
|
+
} else if tag == 0x5F1B {
|
|
45
|
+
endorsementsOrObservations = String( bytes:val, encoding:.utf8)
|
|
46
|
+
} else if tag == 0x5F1C {
|
|
47
|
+
taxOrExitRequirements = String( bytes:val, encoding:.utf8)
|
|
48
|
+
} else if tag == 0x5F1D {
|
|
49
|
+
frontImage = val
|
|
50
|
+
} else if tag == 0x5F1E {
|
|
51
|
+
rearImage = val
|
|
52
|
+
} else if tag == 0x5F55 {
|
|
53
|
+
personalizationTime = String( bytes:val, encoding:.utf8)
|
|
54
|
+
} else if tag == 0x5F56 {
|
|
55
|
+
personalizationDeviceSerialNr = String( bytes:val, encoding:.utf8)
|
|
56
|
+
}
|
|
57
|
+
} while pos < data.count
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private func parseDateOfIssue(value: [UInt8]) -> String? {
|
|
61
|
+
if value.count == 4 {
|
|
62
|
+
return decodeBCD(value: value)
|
|
63
|
+
} else {
|
|
64
|
+
return decodeASCII(value: value)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private func decodeASCII(value: [UInt8]) -> String? {
|
|
69
|
+
return String(bytes:value, encoding:.utf8)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private func decodeBCD(value: [UInt8]) -> String? {
|
|
73
|
+
value.map({ String(format: "%02X", $0) }).joined()
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup14.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
// SecurityInfos ::= SET of SecurityInfo
|
|
10
|
+
// SecurityInfo ::= SEQUENCE {
|
|
11
|
+
// protocol OBJECT IDENTIFIER,
|
|
12
|
+
// requiredData ANY DEFINED BY protocol,
|
|
13
|
+
// optionalData ANY DEFINED BY protocol OPTIONAL
|
|
14
|
+
@available(iOS 13, macOS 10.15, *)
|
|
15
|
+
public class DataGroup14 : DataGroup {
|
|
16
|
+
private var asn1 : ASN1Item!
|
|
17
|
+
public private(set) var securityInfos : [SecurityInfo] = [SecurityInfo]()
|
|
18
|
+
|
|
19
|
+
public override var datagroupType: DataGroupId { .DG14 }
|
|
20
|
+
|
|
21
|
+
required init( _ data : [UInt8] ) throws {
|
|
22
|
+
try super.init(data)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override func parse(_ data: [UInt8]) throws {
|
|
26
|
+
let p = SimpleASN1DumpParser()
|
|
27
|
+
asn1 = try p.parse(data: Data(body))
|
|
28
|
+
|
|
29
|
+
// Bit of a hack at the moment - passing in the body - if we had a decent ASN1 parser then this would be better! ;)
|
|
30
|
+
for i in 0 ..< asn1.getNumberOfChildren() {
|
|
31
|
+
if let child = asn1.getChild(i),
|
|
32
|
+
let secInfo = SecurityInfo.getInstance( object:child, body : body ) {
|
|
33
|
+
securityInfos.append(secInfo)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup15.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import OpenSSL
|
|
9
|
+
|
|
10
|
+
@available(iOS 13, macOS 10.15, *)
|
|
11
|
+
public class DataGroup15 : DataGroup {
|
|
12
|
+
|
|
13
|
+
public private(set) var rsaPublicKey : OpaquePointer?
|
|
14
|
+
public private(set) var ecdsaPublicKey : OpaquePointer?
|
|
15
|
+
|
|
16
|
+
public override var datagroupType: DataGroupId { .DG15 }
|
|
17
|
+
|
|
18
|
+
deinit {
|
|
19
|
+
if ( ecdsaPublicKey != nil ) {
|
|
20
|
+
EVP_PKEY_free(ecdsaPublicKey);
|
|
21
|
+
}
|
|
22
|
+
if ( rsaPublicKey != nil ) {
|
|
23
|
+
EVP_PKEY_free(rsaPublicKey);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
required init( _ data : [UInt8] ) throws {
|
|
28
|
+
try super.init(data)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
override func parse(_ data: [UInt8]) throws {
|
|
33
|
+
|
|
34
|
+
// the public key can either be in EC (elliptic curve) or RSA format
|
|
35
|
+
// Try ec first and if this fails try RSA
|
|
36
|
+
// Note - this will be improved in a later version to read the ASN1 body to
|
|
37
|
+
// check the actual type
|
|
38
|
+
if let key = try? OpenSSLUtils.readECPublicKey( data:body ) {
|
|
39
|
+
// NOTE We are responsible for freeing the key!
|
|
40
|
+
ecdsaPublicKey = key
|
|
41
|
+
} else if let key = try? OpenSSLUtils.readRSAPublicKey( data:body ) {
|
|
42
|
+
|
|
43
|
+
rsaPublicKey = key
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup2.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
#if !os(macOS)
|
|
10
|
+
import UIKit
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
@available(iOS 13, macOS 10.15, *)
|
|
14
|
+
public class DataGroup2 : DataGroup {
|
|
15
|
+
public private(set) var nrImages : Int = 0
|
|
16
|
+
public private(set) var versionNumber : Int = 0
|
|
17
|
+
public private(set) var lengthOfRecord : Int = 0
|
|
18
|
+
public private(set) var numberOfFacialImages : Int = 0
|
|
19
|
+
public private(set) var facialRecordDataLength : Int = 0
|
|
20
|
+
public private(set) var nrFeaturePoints : Int = 0
|
|
21
|
+
public private(set) var gender : Int = 0
|
|
22
|
+
public private(set) var eyeColor : Int = 0
|
|
23
|
+
public private(set) var hairColor : Int = 0
|
|
24
|
+
public private(set) var featureMask : Int = 0
|
|
25
|
+
public private(set) var expression : Int = 0
|
|
26
|
+
public private(set) var poseAngle : Int = 0
|
|
27
|
+
public private(set) var poseAngleUncertainty : Int = 0
|
|
28
|
+
public private(set) var faceImageType : Int = 0
|
|
29
|
+
public private(set) var imageDataType : Int = 0
|
|
30
|
+
public private(set) var imageWidth : Int = 0
|
|
31
|
+
public private(set) var imageHeight : Int = 0
|
|
32
|
+
public private(set) var imageColorSpace : Int = 0
|
|
33
|
+
public private(set) var sourceType : Int = 0
|
|
34
|
+
public private(set) var deviceType : Int = 0
|
|
35
|
+
public private(set) var quality : Int = 0
|
|
36
|
+
public private(set) var imageData : [UInt8] = []
|
|
37
|
+
|
|
38
|
+
public override var datagroupType: DataGroupId { .DG2 }
|
|
39
|
+
|
|
40
|
+
#if !os(macOS)
|
|
41
|
+
func getImage() -> UIImage? {
|
|
42
|
+
if imageData.count == 0 {
|
|
43
|
+
return nil
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let image = UIImage(data:Data(imageData) )
|
|
47
|
+
return image
|
|
48
|
+
}
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
required init( _ data : [UInt8] ) throws {
|
|
52
|
+
try super.init(data)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override func parse(_ data: [UInt8]) throws {
|
|
56
|
+
var tag = try getNextTag()
|
|
57
|
+
try verifyTag(tag, equals: 0x7F61)
|
|
58
|
+
_ = try getNextLength()
|
|
59
|
+
|
|
60
|
+
// Tag should be 0x02
|
|
61
|
+
tag = try getNextTag()
|
|
62
|
+
try verifyTag(tag, equals: 0x02)
|
|
63
|
+
nrImages = try Int(getNextValue()[0])
|
|
64
|
+
|
|
65
|
+
// Next tag is 0x7F60
|
|
66
|
+
tag = try getNextTag()
|
|
67
|
+
try verifyTag(tag, equals: 0x7F60)
|
|
68
|
+
_ = try getNextLength()
|
|
69
|
+
|
|
70
|
+
// Next tag is 0xA1 (Biometric Header Template) - don't care about this
|
|
71
|
+
tag = try getNextTag()
|
|
72
|
+
try verifyTag(tag, equals: 0xA1)
|
|
73
|
+
_ = try getNextValue()
|
|
74
|
+
|
|
75
|
+
// Now we get to the good stuff - next tag is either 5F2E or 7F2E
|
|
76
|
+
tag = try getNextTag()
|
|
77
|
+
try verifyTag(tag, oneOf: [0x5F2E, 0x7F2E])
|
|
78
|
+
let value = try getNextValue()
|
|
79
|
+
|
|
80
|
+
try parseISO19794_5( data:value )
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
func parseISO19794_5( data : [UInt8] ) throws {
|
|
84
|
+
// Validate header - 'F', 'A' 'C' 0x00 - 0x46414300
|
|
85
|
+
if data[0] != 0x46 && data[1] != 0x41 && data[2] != 0x43 && data[3] != 0x00 {
|
|
86
|
+
throw NFCPassportReaderError.InvalidResponse(
|
|
87
|
+
dataGroupId: datagroupType,
|
|
88
|
+
expectedTag: 0x46,
|
|
89
|
+
actualTag: Int(data[0])
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var offset = 4
|
|
94
|
+
versionNumber = binToInt(data[offset..<offset+4])
|
|
95
|
+
offset += 4
|
|
96
|
+
lengthOfRecord = binToInt(data[offset..<offset+4])
|
|
97
|
+
offset += 4
|
|
98
|
+
numberOfFacialImages = binToInt(data[offset..<offset+2])
|
|
99
|
+
offset += 2
|
|
100
|
+
|
|
101
|
+
facialRecordDataLength = binToInt(data[offset..<offset+4])
|
|
102
|
+
offset += 4
|
|
103
|
+
nrFeaturePoints = binToInt(data[offset..<offset+2])
|
|
104
|
+
offset += 2
|
|
105
|
+
gender = binToInt(data[offset..<offset+1])
|
|
106
|
+
offset += 1
|
|
107
|
+
eyeColor = binToInt(data[offset..<offset+1])
|
|
108
|
+
offset += 1
|
|
109
|
+
hairColor = binToInt(data[offset..<offset+1])
|
|
110
|
+
offset += 1
|
|
111
|
+
featureMask = binToInt(data[offset..<offset+3])
|
|
112
|
+
offset += 3
|
|
113
|
+
expression = binToInt(data[offset..<offset+2])
|
|
114
|
+
offset += 2
|
|
115
|
+
poseAngle = binToInt(data[offset..<offset+3])
|
|
116
|
+
offset += 3
|
|
117
|
+
poseAngleUncertainty = binToInt(data[offset..<offset+3])
|
|
118
|
+
offset += 3
|
|
119
|
+
|
|
120
|
+
// Features (not handled). There shouldn't be any but if for some reason there were,
|
|
121
|
+
// then we are going to skip over them
|
|
122
|
+
// The Feature block is 8 bytes
|
|
123
|
+
offset += nrFeaturePoints * 8
|
|
124
|
+
|
|
125
|
+
faceImageType = binToInt(data[offset..<offset+1])
|
|
126
|
+
offset += 1
|
|
127
|
+
imageDataType = binToInt(data[offset..<offset+1])
|
|
128
|
+
offset += 1
|
|
129
|
+
imageWidth = binToInt(data[offset..<offset+2])
|
|
130
|
+
offset += 2
|
|
131
|
+
imageHeight = binToInt(data[offset..<offset+2])
|
|
132
|
+
offset += 2
|
|
133
|
+
imageColorSpace = binToInt(data[offset..<offset+1])
|
|
134
|
+
offset += 1
|
|
135
|
+
sourceType = binToInt(data[offset..<offset+1])
|
|
136
|
+
offset += 1
|
|
137
|
+
deviceType = binToInt(data[offset..<offset+2])
|
|
138
|
+
offset += 2
|
|
139
|
+
quality = binToInt(data[offset..<offset+2])
|
|
140
|
+
offset += 2
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
// Make sure that the image data at least has a valid header
|
|
144
|
+
// Either JPG or JPEG2000
|
|
145
|
+
|
|
146
|
+
let jpegHeader : [UInt8] = [0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46]
|
|
147
|
+
let jpeg2000BitmapHeader : [UInt8] = [0x00,0x00,0x00,0x0c,0x6a,0x50,0x20,0x20,0x0d,0x0a]
|
|
148
|
+
let jpeg2000CodestreamBitmapHeader : [UInt8] = [0xff,0x4f,0xff,0x51]
|
|
149
|
+
|
|
150
|
+
if data.count < offset+jpeg2000CodestreamBitmapHeader.count {
|
|
151
|
+
throw NFCPassportReaderError.UnknownImageFormat
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if [UInt8](data[offset..<offset+jpegHeader.count]) != jpegHeader &&
|
|
156
|
+
[UInt8](data[offset..<offset+jpeg2000BitmapHeader.count]) != jpeg2000BitmapHeader &&
|
|
157
|
+
[UInt8](data[offset..<offset+jpeg2000CodestreamBitmapHeader.count]) != jpeg2000CodestreamBitmapHeader {
|
|
158
|
+
throw NFCPassportReaderError.UnknownImageFormat
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
imageData = [UInt8](data[offset...])
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DataGroup7.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
|
|
9
|
+
#if !os(macOS)
|
|
10
|
+
import UIKit
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
@available(iOS 13, macOS 10.15, *)
|
|
14
|
+
public class DataGroup7 : DataGroup {
|
|
15
|
+
|
|
16
|
+
public private(set) var imageData : [UInt8] = []
|
|
17
|
+
|
|
18
|
+
public override var datagroupType: DataGroupId { .DG7 }
|
|
19
|
+
|
|
20
|
+
required init( _ data : [UInt8] ) throws {
|
|
21
|
+
try super.init(data)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#if !os(macOS)
|
|
25
|
+
func getImage() -> UIImage? {
|
|
26
|
+
if imageData.count == 0 {
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let image = UIImage(data:Data(imageData) )
|
|
31
|
+
return image
|
|
32
|
+
}
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
override func parse(_ data: [UInt8]) throws {
|
|
37
|
+
var tag = try getNextTag()
|
|
38
|
+
try verifyTag(tag, equals: 0x02)
|
|
39
|
+
_ = try getNextValue()
|
|
40
|
+
|
|
41
|
+
tag = try getNextTag()
|
|
42
|
+
try verifyTag(tag, equals: 0x5F43)
|
|
43
|
+
|
|
44
|
+
imageData = try getNextValue()
|
|
45
|
+
}
|
|
46
|
+
}
|