@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,240 @@
|
|
|
1
|
+
//
|
|
2
|
+
// SOD.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by Andy Qua on 01/02/2021.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import OpenSSL
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// Format of SOD: ASN1 - Signed Data (taken from rfc5652 - https://tools.ietf.org/html/rfc5652):
|
|
12
|
+
// The SOD is a CMS container of type Signed-data
|
|
13
|
+
//
|
|
14
|
+
// Note - ideally I'd be using a proper ASN1 parser, however currently there isn't a reliable one for Swift
|
|
15
|
+
// and I haven't written on (yet?). So for the moment, I'm relying on the output from ASN1Dump and a
|
|
16
|
+
// simple parser for that
|
|
17
|
+
//
|
|
18
|
+
// Sequence
|
|
19
|
+
// Object ID: signedData
|
|
20
|
+
// Content: SignedData
|
|
21
|
+
// SignedData ::= SEQUENCE {
|
|
22
|
+
// INTEGER version CMSVersion,
|
|
23
|
+
// SET digestAlgorithms DigestAlgorithmIdentifiers,
|
|
24
|
+
// SEQUENCE encapContentInfo EncapsulatedContentInfo,
|
|
25
|
+
// certificates [0] IMPLICIT CertificateSet OPTIONAL,
|
|
26
|
+
// crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
|
|
27
|
+
// SET signerInfos SignerInfos }
|
|
28
|
+
//
|
|
29
|
+
// AlgorithmIdentifier ::= SEQUENCE {
|
|
30
|
+
// algorithm OBJECT IDENTIFIER,
|
|
31
|
+
// parameters ANY OPTIONAL
|
|
32
|
+
// }
|
|
33
|
+
//
|
|
34
|
+
// EncapsulatedContentInfo ::= SEQUENCE {
|
|
35
|
+
// eContentType ContentType,
|
|
36
|
+
// eContent [0] EXPLICIT OCTET STRING OPTIONAL }
|
|
37
|
+
//
|
|
38
|
+
// ContentType ::= OBJECT IDENTIFIER
|
|
39
|
+
//
|
|
40
|
+
// SignerInfos ::= SET OF SignerInfo
|
|
41
|
+
//
|
|
42
|
+
// SignerInfo ::= SEQUENCE {
|
|
43
|
+
// version CMSVersion,
|
|
44
|
+
// sid SignerIdentifier,
|
|
45
|
+
// digestAlgorithm DigestAlgorithmIdentifier,
|
|
46
|
+
// signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL,
|
|
47
|
+
// signatureAlgorithm SignatureAlgorithmIdentifier,
|
|
48
|
+
// signature SignatureValue,
|
|
49
|
+
// unsignedAttrs [1] IMPLICIT UnsignedAttributes OPTIONAL }
|
|
50
|
+
//
|
|
51
|
+
// SignerIdentifier ::= CHOICE {
|
|
52
|
+
// issuerAndSerialNumber IssuerAndSerialNumber,
|
|
53
|
+
// subjectKeyIdentifier [0] SubjectKeyIdentifier }
|
|
54
|
+
//
|
|
55
|
+
// SignedAttributes ::= SET SIZE (1..MAX) OF Attribute
|
|
56
|
+
// UnsignedAttributes ::= SET SIZE (1..MAX) OF Attribute
|
|
57
|
+
// Attribute ::= SEQUENCE {
|
|
58
|
+
// attrType OBJECT IDENTIFIER,
|
|
59
|
+
// attrValues SET OF AttributeValue }
|
|
60
|
+
// AttributeValue ::= ANY
|
|
61
|
+
// SignatureValue ::= OCTET STRING
|
|
62
|
+
@available(iOS 13, macOS 10.15, *)
|
|
63
|
+
class SOD : DataGroup {
|
|
64
|
+
|
|
65
|
+
public private(set) var pkcs7CertificateData : [UInt8] = []
|
|
66
|
+
private var asn1 : ASN1Item!
|
|
67
|
+
private var pubKey : OpaquePointer?
|
|
68
|
+
|
|
69
|
+
override var datagroupType: DataGroupId { .SOD }
|
|
70
|
+
|
|
71
|
+
required init( _ data : [UInt8] ) throws {
|
|
72
|
+
try super.init(data)
|
|
73
|
+
self.pkcs7CertificateData = body
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
deinit {
|
|
77
|
+
if ( pubKey != nil ) {
|
|
78
|
+
EVP_PKEY_free(pubKey);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
override func parse(_ data: [UInt8]) throws {
|
|
83
|
+
let p = SimpleASN1DumpParser()
|
|
84
|
+
asn1 = try p.parse(data: Data(body))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Returns the public key from the embedded X509 certificate
|
|
88
|
+
/// - Returns pointer to the public key
|
|
89
|
+
func getPublicKey( ) throws -> OpaquePointer {
|
|
90
|
+
|
|
91
|
+
if let key = pubKey {
|
|
92
|
+
return key
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let certs = try OpenSSLUtils.getX509CertificatesFromPKCS7(pkcs7Der:Data(pkcs7CertificateData))
|
|
96
|
+
if let key = X509_get_pubkey (certs[0].cert) {
|
|
97
|
+
pubKey = key
|
|
98
|
+
return key
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Unable to get public key")
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/// Extracts the encapsulated content section from a SignedData PKCS7 container (if present)
|
|
106
|
+
/// - Returns: The encapsulated content from a PKCS7 container if we could read it
|
|
107
|
+
/// - Throws: Error if we can't find or read the encapsulated content
|
|
108
|
+
func getEncapsulatedContent() throws -> Data {
|
|
109
|
+
guard let signedData = asn1.getChild(1)?.getChild(0),
|
|
110
|
+
let encContent = signedData.getChild(2)?.getChild(1),
|
|
111
|
+
let content = encContent.getChild(0) else {
|
|
112
|
+
|
|
113
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Data in invalid format")
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var sigData : Data?
|
|
117
|
+
if content.type.hasPrefix("OCTET STRING" ) {
|
|
118
|
+
sigData = Data(hexRepToBin( content.value ))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
guard let ret = sigData else { throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("noDataReturned") }
|
|
122
|
+
return ret
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/// Gets the digest algorithm used to hash the encapsulated content in the signed data section (if present)
|
|
126
|
+
/// - Returns: The digest algorithm used to hash the encapsulated content in the signed data section
|
|
127
|
+
/// - Throws: Error if we can't find or read the digest algorithm
|
|
128
|
+
func getEncapsulatedContentDigestAlgorithm() throws -> String {
|
|
129
|
+
guard let signedData = asn1.getChild(1)?.getChild(0),
|
|
130
|
+
let digestAlgo = signedData.getChild(1)?.getChild(0)?.getChild(0) else {
|
|
131
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Data in invalid format")
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return String(digestAlgo.value)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// Gets the signed attributes section (if present)
|
|
138
|
+
/// - Returns: the signed attributes section
|
|
139
|
+
/// - Throws: Error if we can't find or read the signed attributes
|
|
140
|
+
func getSignedAttributes( ) throws -> Data {
|
|
141
|
+
|
|
142
|
+
// Get the SignedAttributes section.
|
|
143
|
+
guard let signedData = asn1.getChild(1)?.getChild(0),
|
|
144
|
+
let signerInfo = signedData.getChild(4),
|
|
145
|
+
let signedAttrs = signerInfo.getChild(0)?.getChild(3) else {
|
|
146
|
+
|
|
147
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Data in invalid format")
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var bytes = [UInt8](self.pkcs7CertificateData[signedAttrs.pos ..< signedAttrs.pos + signedAttrs.headerLen + signedAttrs.length])
|
|
151
|
+
|
|
152
|
+
// The first byte will be 0xA0 -> as its a explicit tag for a contextual item which we need to convert
|
|
153
|
+
// for the hash to calculate correctly
|
|
154
|
+
// We know that the actual tag is a SET (0x31) - See section 5.4 of https://tools.ietf.org/html/rfc5652
|
|
155
|
+
// So we need to change this from 0xA0 to 0x31
|
|
156
|
+
if bytes[0] == 0xA0 {
|
|
157
|
+
bytes[0] = 0x31
|
|
158
|
+
}
|
|
159
|
+
let signedAttribs = Data(bytes)
|
|
160
|
+
|
|
161
|
+
return signedAttribs
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// Gets the message digest from the signed attributes section (if present)
|
|
165
|
+
/// - Returns: the message digest
|
|
166
|
+
/// - Throws: Error if we can't find or read the message digest
|
|
167
|
+
func getMessageDigestFromSignedAttributes( ) throws -> Data {
|
|
168
|
+
|
|
169
|
+
// For the SOD, the SignedAttributes consists of:
|
|
170
|
+
// A Content type Object (which has the value of the attributes content type)
|
|
171
|
+
// A messageDigest Object which has the message digest as it value
|
|
172
|
+
// We want the messageDigest value
|
|
173
|
+
|
|
174
|
+
guard let signedData = asn1.getChild(1)?.getChild(0),
|
|
175
|
+
let signerInfo = signedData.getChild(4),
|
|
176
|
+
let signedAttrs = signerInfo.getChild(0)?.getChild(3) else {
|
|
177
|
+
|
|
178
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Data in invalid format")
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Find the messageDigest in the signedAttributes section
|
|
182
|
+
var sigData : Data?
|
|
183
|
+
for i in 0 ..< signedAttrs.getNumberOfChildren() {
|
|
184
|
+
let attrObj = signedAttrs.getChild(i)
|
|
185
|
+
if attrObj?.getChild(0)?.value == "messageDigest" {
|
|
186
|
+
if let set = attrObj?.getChild(1),
|
|
187
|
+
let digestVal = set.getChild(0) {
|
|
188
|
+
|
|
189
|
+
if digestVal.type.hasPrefix("OCTET STRING" ) {
|
|
190
|
+
sigData = Data(hexRepToBin( digestVal.value ) )
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
guard let messageDigest = sigData else { throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("No messageDigest Returned") }
|
|
197
|
+
|
|
198
|
+
return messageDigest
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/// Gets the signature data (if present)
|
|
202
|
+
/// - Returns: the signature
|
|
203
|
+
/// - Throws: Error if we can't find or read the signature
|
|
204
|
+
func getSignature( ) throws -> Data {
|
|
205
|
+
|
|
206
|
+
guard let signedData = asn1.getChild(1)?.getChild(0),
|
|
207
|
+
let signerInfo = signedData.getChild(4),
|
|
208
|
+
let signature = signerInfo.getChild(0)?.getChild(5) else {
|
|
209
|
+
|
|
210
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Data in invalid format")
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var sigData : Data?
|
|
214
|
+
if signature.type.hasPrefix("OCTET STRING" ) {
|
|
215
|
+
sigData = Data(hexRepToBin( signature.value ))
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
guard let ret = sigData else { throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("noDataReturned") }
|
|
219
|
+
return ret
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/// Gets the signature algorithm used (if present)
|
|
223
|
+
/// - Returns: the signature algorithm used
|
|
224
|
+
/// - Throws: Error if we can't find or read the signature algorithm
|
|
225
|
+
func getSignatureAlgorithm( ) throws -> String {
|
|
226
|
+
|
|
227
|
+
guard let signedData = asn1.getChild(1)?.getChild(0),
|
|
228
|
+
let signerInfo = signedData.getChild(4),
|
|
229
|
+
let signatureAlgo = signerInfo.getChild(0)?.getChild(4)?.getChild(0) else {
|
|
230
|
+
|
|
231
|
+
throw OpenSSLError.UnableToExtractSignedDataFromPKCS7("Data in invalid format")
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Vals I've seen are:
|
|
235
|
+
// sha1WithRSAEncryption => default pkcs1
|
|
236
|
+
// sha256WithRSAEncryption => default pkcs1
|
|
237
|
+
// rsassaPss => pss
|
|
238
|
+
return signatureAlgo.value
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//
|
|
2
|
+
// SecurityInfo.swift
|
|
3
|
+
// NFCPassportReader
|
|
4
|
+
//
|
|
5
|
+
// Created by Andy Qua on 25/02/2021.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import OpenSSL
|
|
10
|
+
|
|
11
|
+
@available(iOS 13, macOS 10.15,*)
|
|
12
|
+
public class SecurityInfo {
|
|
13
|
+
// Active Authentication OID
|
|
14
|
+
static let ID_AA_OID = "2.23.136.1.1.5"
|
|
15
|
+
|
|
16
|
+
// Active Authentication Signature Algorithm OIDS
|
|
17
|
+
// Specified in BSI TR 03111 Section 5.2.1.
|
|
18
|
+
static let ECDSA_PLAIN_SIGNATURES = "0.4.0.127.0.7.1.1.4.1";
|
|
19
|
+
static let ECDSA_PLAIN_SHA1_OID = ECDSA_PLAIN_SIGNATURES + ".1"; // 0.4.0.127.0.7.1.1.4.1.1, ecdsa-plain-SHA1
|
|
20
|
+
static let ECDSA_PLAIN_SHA224_OID = ECDSA_PLAIN_SIGNATURES + ".2"; // 0.4.0.127.0.7.1.1.4.1.2, ecdsa-plain-SHA224
|
|
21
|
+
static let ECDSA_PLAIN_SHA256_OID = ECDSA_PLAIN_SIGNATURES + ".3"; // 0.4.0.127.0.7.1.1.4.1.3, ecdsa-plain-SHA256
|
|
22
|
+
static let ECDSA_PLAIN_SHA384_OID = ECDSA_PLAIN_SIGNATURES + ".4"; // 0.4.0.127.0.7.1.1.4.1.4, ecdsa-plain-SHA384
|
|
23
|
+
static let ECDSA_PLAIN_SHA512_OID = ECDSA_PLAIN_SIGNATURES + ".5"; // 0.4.0.127.0.7.1.1.4.1.5, ecdsa-plain-SHA512
|
|
24
|
+
static let ECDSA_PLAIN_RIPEMD160_OID = ECDSA_PLAIN_SIGNATURES + ".6"; // 0.4.0.127.0.7.1.1.4.1.6, ecdsa-plain-RIPEMD160
|
|
25
|
+
|
|
26
|
+
// Chip Authentication Public Key OIDS
|
|
27
|
+
static let ID_PK_DH_OID = "0.4.0.127.0.7.2.2.1.1"
|
|
28
|
+
static let ID_PK_ECDH_OID = "0.4.0.127.0.7.2.2.1.2"
|
|
29
|
+
|
|
30
|
+
// Chip Authentication OIDS
|
|
31
|
+
static let ID_CA_DH_3DES_CBC_CBC_OID = "0.4.0.127.0.7.2.2.3.1.1"
|
|
32
|
+
static let ID_CA_ECDH_3DES_CBC_CBC_OID = "0.4.0.127.0.7.2.2.3.2.1"
|
|
33
|
+
static let ID_CA_DH_AES_CBC_CMAC_128_OID = "0.4.0.127.0.7.2.2.3.1.2"
|
|
34
|
+
static let ID_CA_DH_AES_CBC_CMAC_192_OID = "0.4.0.127.0.7.2.2.3.1.3"
|
|
35
|
+
static let ID_CA_DH_AES_CBC_CMAC_256_OID = "0.4.0.127.0.7.2.2.3.1.4"
|
|
36
|
+
static let ID_CA_ECDH_AES_CBC_CMAC_128_OID = "0.4.0.127.0.7.2.2.3.2.2"
|
|
37
|
+
static let ID_CA_ECDH_AES_CBC_CMAC_192_OID = "0.4.0.127.0.7.2.2.3.2.3"
|
|
38
|
+
static let ID_CA_ECDH_AES_CBC_CMAC_256_OID = "0.4.0.127.0.7.2.2.3.2.4"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// PACE OIDS
|
|
42
|
+
static let ID_BSI = "0.4.0.127.0.7"
|
|
43
|
+
static let ID_PACE = ID_BSI + ".2.2.4"
|
|
44
|
+
static let ID_PACE_DH_GM = ID_PACE + ".1"
|
|
45
|
+
static let ID_PACE_DH_GM_3DES_CBC_CBC = ID_PACE_DH_GM + ".1"; // 0.4.0.127.0.7.2.2.4.1.1, id-PACE-DH-GM-3DES-CBC-CBC
|
|
46
|
+
static let ID_PACE_DH_GM_AES_CBC_CMAC_128 = ID_PACE_DH_GM + ".2"; // 0.4.0.127.0.7.2.2.4.1.2, id-PACE-DH-GM-AES-CBC-CMAC-128
|
|
47
|
+
static let ID_PACE_DH_GM_AES_CBC_CMAC_192 = ID_PACE_DH_GM + ".3"; // 0.4.0.127.0.7.2.2.4.1.3, id-PACE-DH-GM-AES-CBC-CMAC-192
|
|
48
|
+
static let ID_PACE_DH_GM_AES_CBC_CMAC_256 = ID_PACE_DH_GM + ".4"; // 0.4.0.127.0.7.2.2.4.1.4, id-PACE-DH-GM-AES-CBC-CMAC-256
|
|
49
|
+
|
|
50
|
+
static let ID_PACE_ECDH_GM = ID_PACE + ".2"
|
|
51
|
+
static let ID_PACE_ECDH_GM_3DES_CBC_CBC = ID_PACE_ECDH_GM + ".1"; // 0.4.0.127.0.7.2.2.4.2.1, id-PACE-ECDH-GM-3DES-CBC-CBC
|
|
52
|
+
static let ID_PACE_ECDH_GM_AES_CBC_CMAC_128 = ID_PACE_ECDH_GM + ".2"; // 0.4.0.127.0.7.2.2.4.2.2, id-PACE-ECDH-GM-AES-CBC-CMAC-128
|
|
53
|
+
static let ID_PACE_ECDH_GM_AES_CBC_CMAC_192 = ID_PACE_ECDH_GM + ".3"; // 0.4.0.127.0.7.2.2.4.2.3, id-PACE-ECDH-GM-AES-CBC-CMAC-192
|
|
54
|
+
static let ID_PACE_ECDH_GM_AES_CBC_CMAC_256 = ID_PACE_ECDH_GM + ".4"; // 0.4.0.127.0.7.2.2.4.2.4, id-PACE-ECDH-GM-AES-CBC-CMAC-256
|
|
55
|
+
|
|
56
|
+
static let ID_PACE_DH_IM = ID_PACE + ".3"
|
|
57
|
+
static let ID_PACE_DH_IM_3DES_CBC_CBC = ID_PACE_DH_IM + ".1"; // 0.4.0.127.0.7.2.2.4.3.1, id-PACE-DH-IM-3DES-CBC-CBC
|
|
58
|
+
static let ID_PACE_DH_IM_AES_CBC_CMAC_128 = ID_PACE_DH_IM + ".2"; // 0.4.0.127.0.7.2.2.4.3.2, id-PACE-DH-IM-AES-CBC-CMAC-128
|
|
59
|
+
static let ID_PACE_DH_IM_AES_CBC_CMAC_192 = ID_PACE_DH_IM + ".3"; // 0.4.0.127.0.7.2.2.4.3.3, id-PACE-DH-IM-AES-CBC-CMAC-192
|
|
60
|
+
static let ID_PACE_DH_IM_AES_CBC_CMAC_256 = ID_PACE_DH_IM + ".4"; // 0.4.0.127.0.7.2.2.4.3.4, id-PACE-DH-IM-AES-CBC-CMAC-256
|
|
61
|
+
|
|
62
|
+
static let ID_PACE_ECDH_IM = ID_PACE + ".4"
|
|
63
|
+
static let ID_PACE_ECDH_IM_3DES_CBC_CBC = ID_PACE_ECDH_IM + ".1"; // 0.4.0.127.0.7.2.2.4.4.1, id-PACE-ECDH-IM-3DES-CBC-CBC
|
|
64
|
+
static let ID_PACE_ECDH_IM_AES_CBC_CMAC_128 = ID_PACE_ECDH_IM + ".2"; // 0.4.0.127.0.7.2.2.4.4.2, id-PACE-ECDH-IM-AES-CBC-CMAC-128
|
|
65
|
+
static let ID_PACE_ECDH_IM_AES_CBC_CMAC_192 = ID_PACE_ECDH_IM + ".3"; // 0.4.0.127.0.7.2.2.4.4.3, id-PACE-ECDH-IM-AES-CBC-CMAC-192
|
|
66
|
+
static let ID_PACE_ECDH_IM_AES_CBC_CMAC_256 = ID_PACE_ECDH_IM + ".4"; // 0.4.0.127.0.7.2.2.4.4.4, id-PACE-ECDH-IM-AES-CBC-CMAC-256
|
|
67
|
+
|
|
68
|
+
static let ID_PACE_ECDH_CAM = ID_PACE + ".6"
|
|
69
|
+
static let ID_PACE_ECDH_CAM_AES_CBC_CMAC_128 = ID_PACE_ECDH_CAM + ".2"; // 0.4.0.127.0.7.2.2.4.6.2, id-PACE-ECDH-CAM-AES-CBC-CMAC-128
|
|
70
|
+
static let ID_PACE_ECDH_CAM_AES_CBC_CMAC_192 = ID_PACE_ECDH_CAM + ".3"; // 0.4.0.127.0.7.2.2.4.6.3, id-PACE-ECDH-CAM-AES-CBC-CMAC-192
|
|
71
|
+
static let ID_PACE_ECDH_CAM_AES_CBC_CMAC_256 = ID_PACE_ECDH_CAM + ".4"; // 0.4.0.127.0.7.2.2.4.6.4, id-PACE-ECDH-CAM-AES-CBC-CMAC-256
|
|
72
|
+
|
|
73
|
+
public func getObjectIdentifier() -> String {
|
|
74
|
+
preconditionFailure("This method must be overridden")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public func getProtocolOIDString() -> String {
|
|
78
|
+
preconditionFailure("This method must be overridden")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static func getInstance( object : ASN1Item, body: [UInt8] ) -> SecurityInfo? {
|
|
82
|
+
let oid = object.getChild(0)?.value ?? ""
|
|
83
|
+
let requiredData = object.getChild(1)!
|
|
84
|
+
var optionalData : ASN1Item? = nil
|
|
85
|
+
if (object.getNumberOfChildren() == 3) {
|
|
86
|
+
optionalData = object.getChild(2)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ChipAuthenticationPublicKeyInfo.checkRequiredIdentifier(oid) {
|
|
90
|
+
|
|
91
|
+
let keyData : [UInt8] = [UInt8](body[requiredData.pos ..< requiredData.pos+requiredData.headerLen+requiredData.length])
|
|
92
|
+
|
|
93
|
+
var subjectPublicKeyInfo : OpaquePointer? = nil
|
|
94
|
+
let _ = keyData.withUnsafeBytes { (ptr) in
|
|
95
|
+
var newPtr = ptr.baseAddress?.assumingMemoryBound(to: UInt8.self)
|
|
96
|
+
|
|
97
|
+
subjectPublicKeyInfo = d2i_PUBKEY(nil, &newPtr, keyData.count)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if let subjectPublicKeyInfo = subjectPublicKeyInfo {
|
|
101
|
+
|
|
102
|
+
if optionalData == nil {
|
|
103
|
+
return ChipAuthenticationPublicKeyInfo(oid:oid, pubKey:subjectPublicKeyInfo);
|
|
104
|
+
} else {
|
|
105
|
+
let keyId = Int(optionalData!.value, radix: 16)
|
|
106
|
+
return ChipAuthenticationPublicKeyInfo(oid:oid, pubKey:subjectPublicKeyInfo, keyId: keyId);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
} else if ChipAuthenticationInfo.checkRequiredIdentifier(oid) {
|
|
111
|
+
let version = Int(requiredData.value) ?? -1
|
|
112
|
+
if let optionalData = optionalData {
|
|
113
|
+
let keyId = Int(optionalData.value, radix: 16)
|
|
114
|
+
return ChipAuthenticationInfo(oid: oid, version: version, keyId: keyId);
|
|
115
|
+
} else {
|
|
116
|
+
return ChipAuthenticationInfo(oid: oid, version: version);
|
|
117
|
+
}
|
|
118
|
+
} else if PACEInfo.checkRequiredIdentifier(oid) {
|
|
119
|
+
let version = Int(requiredData.value) ?? -1
|
|
120
|
+
var parameterId : Int? = nil
|
|
121
|
+
|
|
122
|
+
if let optionalData = optionalData {
|
|
123
|
+
parameterId = Int(optionalData.value, radix:16)
|
|
124
|
+
}
|
|
125
|
+
return PACEInfo(oid: oid, version: version, parameterId: parameterId);
|
|
126
|
+
} else if ActiveAuthenticationInfo.checkRequiredIdentifier(oid) {
|
|
127
|
+
let version = Int(requiredData.value) ?? -1
|
|
128
|
+
if let optionalData = optionalData {
|
|
129
|
+
return ActiveAuthenticationInfo(oid: oid, version: version, signatureAlgorithmOID: optionalData.value)
|
|
130
|
+
} else {
|
|
131
|
+
return ActiveAuthenticationInfo(oid: oid, version: version)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return nil
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Errors.swift
|
|
3
|
+
// NFCPassportReader
|
|
4
|
+
//
|
|
5
|
+
// Created by Andy Qua on 09/02/2021.
|
|
6
|
+
// Copyright © 2021 Andy Qua. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
// MARK: TagError
|
|
12
|
+
@available(iOS 13, macOS 10.15, *)
|
|
13
|
+
public enum NFCPassportReaderError: Error {
|
|
14
|
+
case ResponseError(String, UInt8, UInt8)
|
|
15
|
+
case InvalidResponse(dataGroupId: DataGroupId, expectedTag: Int, actualTag: Int)
|
|
16
|
+
case UnexpectedError
|
|
17
|
+
case NFCNotSupported
|
|
18
|
+
case NoConnectedTag
|
|
19
|
+
case D087Malformed
|
|
20
|
+
case InvalidResponseChecksum
|
|
21
|
+
case MissingMandatoryFields
|
|
22
|
+
case CannotDecodeASN1Length
|
|
23
|
+
case InvalidASN1Value
|
|
24
|
+
case UnableToProtectAPDU
|
|
25
|
+
case UnableToUnprotectAPDU
|
|
26
|
+
case UnsupportedDataGroup
|
|
27
|
+
case DataGroupNotRead
|
|
28
|
+
case UnknownTag
|
|
29
|
+
case UnknownImageFormat
|
|
30
|
+
case NotImplemented
|
|
31
|
+
case TagNotValid
|
|
32
|
+
case ConnectionError
|
|
33
|
+
case UserCanceled
|
|
34
|
+
case InvalidMRZKey
|
|
35
|
+
case MoreThanOneTagFound
|
|
36
|
+
case InvalidHashAlgorithmSpecified
|
|
37
|
+
case UnsupportedCipherAlgorithm
|
|
38
|
+
case UnsupportedMappingType
|
|
39
|
+
case PACEError(String,String)
|
|
40
|
+
case ChipAuthenticationFailed
|
|
41
|
+
case InvalidDataPassed(String)
|
|
42
|
+
case NotYetSupported(String)
|
|
43
|
+
case Unknown(Error)
|
|
44
|
+
|
|
45
|
+
var value: String {
|
|
46
|
+
switch self {
|
|
47
|
+
case .ResponseError(let errMsg, _, _): return errMsg
|
|
48
|
+
case .InvalidResponse(let dataGroupId, let expected, let actual):
|
|
49
|
+
return "InvalidResponse in \(dataGroupId.getName()). Expected: \(expected.hexString) Actual: \(actual.hexString)"
|
|
50
|
+
case .UnexpectedError: return "UnexpectedError"
|
|
51
|
+
case .NFCNotSupported: return "NFCNotSupported"
|
|
52
|
+
case .NoConnectedTag: return "NoConnectedTag"
|
|
53
|
+
case .D087Malformed: return "D087Malformed"
|
|
54
|
+
case .InvalidResponseChecksum: return "InvalidResponseChecksum"
|
|
55
|
+
case .MissingMandatoryFields: return "MissingMandatoryFields"
|
|
56
|
+
case .CannotDecodeASN1Length: return "CannotDecodeASN1Length"
|
|
57
|
+
case .InvalidASN1Value: return "InvalidASN1Value"
|
|
58
|
+
case .UnableToProtectAPDU: return "UnableToProtectAPDU"
|
|
59
|
+
case .UnableToUnprotectAPDU: return "UnableToUnprotectAPDU"
|
|
60
|
+
case .UnsupportedDataGroup: return "UnsupportedDataGroup"
|
|
61
|
+
case .DataGroupNotRead: return "DataGroupNotRead"
|
|
62
|
+
case .UnknownTag: return "UnknownTag"
|
|
63
|
+
case .UnknownImageFormat: return "UnknownImageFormat"
|
|
64
|
+
case .NotImplemented: return "NotImplemented"
|
|
65
|
+
case .TagNotValid: return "TagNotValid"
|
|
66
|
+
case .ConnectionError: return "ConnectionError"
|
|
67
|
+
case .UserCanceled: return "UserCanceled"
|
|
68
|
+
case .InvalidMRZKey: return "InvalidMRZKey"
|
|
69
|
+
case .MoreThanOneTagFound: return "MoreThanOneTagFound"
|
|
70
|
+
case .InvalidHashAlgorithmSpecified: return "InvalidHashAlgorithmSpecified"
|
|
71
|
+
case .UnsupportedCipherAlgorithm: return "UnsupportedCipherAlgorithm"
|
|
72
|
+
case .UnsupportedMappingType: return "UnsupportedMappingType"
|
|
73
|
+
case .PACEError(let step, let reason): return "PACEError (\(step)) - \(reason)"
|
|
74
|
+
case .ChipAuthenticationFailed: return "ChipAuthenticationFailed"
|
|
75
|
+
case .InvalidDataPassed(let reason) : return "Invalid data passed - \(reason)"
|
|
76
|
+
case .NotYetSupported(let reason) : return "Not yet supported - \(reason)"
|
|
77
|
+
case .Unknown(let error): return "Unknown error: \(error.localizedDescription)"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@available(iOS 13, macOS 10.15, *)
|
|
83
|
+
extension NFCPassportReaderError: LocalizedError {
|
|
84
|
+
public var errorDescription: String? {
|
|
85
|
+
return NSLocalizedString(value, comment: "My error")
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// MARK: OpenSSLError
|
|
91
|
+
@available(iOS 13, macOS 10.15, *)
|
|
92
|
+
public enum OpenSSLError: Error {
|
|
93
|
+
case UnableToGetX509CertificateFromPKCS7(String)
|
|
94
|
+
case UnableToVerifyX509CertificateForSOD(String)
|
|
95
|
+
case VerifyAndReturnSODEncapsulatedData(String)
|
|
96
|
+
case UnableToReadECPublicKey(String)
|
|
97
|
+
case UnableToExtractSignedDataFromPKCS7(String)
|
|
98
|
+
case VerifySignedAttributes(String)
|
|
99
|
+
case UnableToParseASN1(String)
|
|
100
|
+
case UnableToDecryptRSASignature(String)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@available(iOS 13, macOS 10.15, *)
|
|
104
|
+
extension OpenSSLError: LocalizedError {
|
|
105
|
+
public var errorDescription: String? {
|
|
106
|
+
switch self {
|
|
107
|
+
case .UnableToGetX509CertificateFromPKCS7(let reason):
|
|
108
|
+
return NSLocalizedString("Unable to read the SOD PKCS7 Certificate. \(reason)", comment: "UnableToGetPKCS7CertificateForSOD")
|
|
109
|
+
case .UnableToVerifyX509CertificateForSOD(let reason):
|
|
110
|
+
return NSLocalizedString("Unable to verify the SOD X509 certificate. \(reason)", comment: "UnableToVerifyX509CertificateForSOD")
|
|
111
|
+
case .VerifyAndReturnSODEncapsulatedData(let reason):
|
|
112
|
+
return NSLocalizedString("Unable to verify the SOD Datagroup hashes. \(reason)", comment: "UnableToGetSignedDataFromPKCS7")
|
|
113
|
+
case .UnableToReadECPublicKey(let reason):
|
|
114
|
+
return NSLocalizedString("Unable to read ECDSA Public key \(reason)!", comment: "UnableToReadECPublicKey")
|
|
115
|
+
case .UnableToExtractSignedDataFromPKCS7(let reason):
|
|
116
|
+
return NSLocalizedString("Unable to extract Signer data from PKCS7 \(reason)!", comment: "UnableToExtractSignedDataFromPKCS7")
|
|
117
|
+
case .VerifySignedAttributes(let reason):
|
|
118
|
+
return NSLocalizedString("Unable to Verify the SOD SignedAttributes \(reason)!", comment: "UnableToExtractSignedDataFromPKCS7")
|
|
119
|
+
case .UnableToParseASN1(let reason):
|
|
120
|
+
return NSLocalizedString("Unable to parse ASN1 \(reason)!", comment: "UnableToParseASN1")
|
|
121
|
+
case .UnableToDecryptRSASignature(let reason):
|
|
122
|
+
return NSLocalizedString("DatUnable to decrypt RSA Signature \(reason)!", comment: "UnableToDecryptRSSignature")
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// MARK: PassiveAuthenticationError
|
|
129
|
+
public enum PassiveAuthenticationError: Error {
|
|
130
|
+
case UnableToParseSODHashes(String)
|
|
131
|
+
case InvalidDataGroupHash(String)
|
|
132
|
+
case SODMissing(String)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
extension PassiveAuthenticationError: LocalizedError {
|
|
137
|
+
public var errorDescription: String? {
|
|
138
|
+
switch self {
|
|
139
|
+
case .UnableToParseSODHashes(let reason):
|
|
140
|
+
return NSLocalizedString("Unable to parse the SOD Datagroup hashes. \(reason)", comment: "UnableToParseSODHashes")
|
|
141
|
+
case .InvalidDataGroupHash(let reason):
|
|
142
|
+
return NSLocalizedString("DataGroup hash not present or didn't match \(reason)!", comment: "InvalidDataGroupHash")
|
|
143
|
+
case .SODMissing(let reason):
|
|
144
|
+
return NSLocalizedString("DataGroup SOD not present or not read \(reason)!", comment: "SODMissing")
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Logging.swift
|
|
3
|
+
// NFCTest
|
|
4
|
+
//
|
|
5
|
+
// Created by Andy Qua on 11/06/2019.
|
|
6
|
+
// Copyright © 2019 Andy Qua. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import OSLog
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
extension Logger {
|
|
14
|
+
/// Using your bundle identifier is a great way to ensure a unique identifier.
|
|
15
|
+
private static var subsystem = Bundle.main.bundleIdentifier!
|
|
16
|
+
|
|
17
|
+
/// Tag Reader logs
|
|
18
|
+
static let passportReader = Logger(subsystem: subsystem, category: "passportReader")
|
|
19
|
+
|
|
20
|
+
/// Tag Reader logs
|
|
21
|
+
static let tagReader = Logger(subsystem: subsystem, category: "tagReader")
|
|
22
|
+
|
|
23
|
+
/// SecureMessaging logs
|
|
24
|
+
static let secureMessaging = Logger(subsystem: subsystem, category: "secureMessaging")
|
|
25
|
+
|
|
26
|
+
static let openSSL = Logger(subsystem: subsystem, category: "openSSL")
|
|
27
|
+
|
|
28
|
+
static let bac = Logger(subsystem: subsystem, category: "BAC")
|
|
29
|
+
static let chipAuth = Logger(subsystem: subsystem, category: "chipAuthentication")
|
|
30
|
+
static let pace = Logger(subsystem: subsystem, category: "PACE")
|
|
31
|
+
}
|
|
32
|
+
|