@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.
Files changed (223) hide show
  1. package/LICENSE +20 -0
  2. package/NFCSDK.podspec +40 -0
  3. package/android/build.gradle +85 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +31 -0
  6. package/android/src/main/AndroidManifestNew.xml +30 -0
  7. package/android/src/main/java/com/nfcsdk/ChipReader.kt +237 -0
  8. package/android/src/main/java/com/nfcsdk/NFCSDKModule.kt +78 -0
  9. package/android/src/main/java/com/nfcsdk/NFCSDKPackage.kt +17 -0
  10. package/android/src/main/java/com/nfcsdk/NFCScanActivity.kt +299 -0
  11. package/android/src/main/java/com/nfcsdk/utils/Dg13Parser.kt +278 -0
  12. package/android/src/main/java/com/nfcsdk/utils/FaceExtractor.kt +40 -0
  13. package/android/src/main/java/com/nfcsdk/utils/MrzUtils.kt +75 -0
  14. package/android/src/main/res/drawable/bg_nfc_bottom_sheet.xml +13 -0
  15. package/android/src/main/res/drawable/bg_nfc_sheet_handle.xml +9 -0
  16. package/android/src/main/res/layout/activity_nfc.xml +110 -0
  17. package/android/src/main/res/values/styles.xml +10 -0
  18. package/android/src/main/res/xml/nfc_tech_filter.xml +8 -0
  19. package/ios/ChipReader.swift +258 -0
  20. package/ios/NFCSDK-Bridging-Header.h +2 -0
  21. package/ios/NFCSDK.mm +9 -0
  22. package/ios/NFCSDK.swift +112 -0
  23. package/ios/NFCSDKSession.swift +5 -0
  24. package/ios/utils/DG13Parser.swift +302 -0
  25. package/ios/utils/MrzUtils.swift +49 -0
  26. package/lib/module/errors.js +9 -0
  27. package/lib/module/errors.js.map +1 -0
  28. package/lib/module/index.js +118 -0
  29. package/lib/module/index.js.map +1 -0
  30. package/lib/module/package.json +1 -0
  31. package/lib/module/types.js +2 -0
  32. package/lib/module/types.js.map +1 -0
  33. package/lib/typescript/package.json +1 -0
  34. package/lib/typescript/src/errors.d.ts +4 -0
  35. package/lib/typescript/src/errors.d.ts.map +1 -0
  36. package/lib/typescript/src/index.d.ts +80 -0
  37. package/lib/typescript/src/index.d.ts.map +1 -0
  38. package/lib/typescript/src/types.d.ts +45 -0
  39. package/lib/typescript/src/types.d.ts.map +1 -0
  40. package/package.json +155 -0
  41. package/src/errors.ts +6 -0
  42. package/src/index.tsx +141 -0
  43. package/src/types.ts +45 -0
  44. package/vendor/ios-passport-reader/CHANGELOG +362 -0
  45. package/vendor/ios-passport-reader/CODE_OF_CONDUCT.md +77 -0
  46. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/AppDelegate.swift +39 -0
  47. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
  48. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
  49. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
  50. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
  51. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
  52. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
  53. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
  54. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
  55. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
  56. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
  57. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
  58. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
  59. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
  60. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
  61. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
  62. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
  63. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
  64. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
  65. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
  66. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
  67. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
  68. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
  69. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
  70. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
  71. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
  72. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
  73. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
  74. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
  75. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
  76. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
  77. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
  78. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
  79. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Info.plist +77 -0
  80. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/PassportUtils.swift +76 -0
  81. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/SettingsStore.swift +107 -0
  82. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
  83. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/SceneDelegate.swift +57 -0
  84. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/DetailsView.swift +197 -0
  85. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
  86. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
  87. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
  88. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
  89. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
  90. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
  91. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MainView.swift +214 -0
  92. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
  93. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportView.swift +73 -0
  94. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/SettingsView.swift +63 -0
  95. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/StoredPassportView.swift +152 -0
  96. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/masterList.pem +32 -0
  97. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/readme.md +10 -0
  98. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/project.pbxproj +695 -0
  99. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
  100. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/contents.xcworkspacedata +10 -0
  101. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  102. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  103. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/DataGroupParsingTests.swift +189 -0
  104. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/Info.plist +22 -0
  105. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
  106. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/PACETests.swift +112 -0
  107. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile +22 -0
  108. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile.lock +35 -0
  109. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/README.md +2 -0
  110. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/AppDelegate.swift +39 -0
  111. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
  112. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
  113. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
  114. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
  115. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
  116. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
  117. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
  118. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
  119. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
  120. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
  121. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
  122. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
  123. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
  124. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
  125. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
  126. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
  127. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
  128. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
  129. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
  130. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
  131. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
  132. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
  133. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
  134. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
  135. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
  136. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
  137. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
  138. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
  139. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
  140. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
  141. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
  142. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
  143. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Info.plist +79 -0
  144. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/PassportUtils.swift +99 -0
  145. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStore.swift +98 -0
  146. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStoreCAN.swift +75 -0
  147. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/LICENSE +21 -0
  148. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/PreviewView.swift +34 -0
  149. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/StringUtils.swift +160 -0
  150. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/ViewController.swift +320 -0
  151. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/VisionViewController.swift +163 -0
  152. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
  153. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/SceneDelegate.swift +58 -0
  154. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/CanKeyView.swift +251 -0
  155. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/MRZEntryViewCanKey.swift +65 -0
  156. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/PassportViewCAN.swift +73 -0
  157. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/DetailsView.swift +193 -0
  158. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
  159. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
  160. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
  161. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
  162. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
  163. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
  164. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MainView.swift +264 -0
  165. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
  166. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportView.swift +73 -0
  167. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/SettingsView.swift +47 -0
  168. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/StoredPassportView.swift +149 -0
  169. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/masterList.pem +32 -0
  170. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/readme.md +10 -0
  171. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.pbxproj +683 -0
  172. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  173. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +25 -0
  174. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
  175. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/DataGroupParsingTests.swift +190 -0
  176. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/Info.plist +22 -0
  177. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
  178. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/PACETests.swift +112 -0
  179. package/vendor/ios-passport-reader/LICENSE +21 -0
  180. package/vendor/ios-passport-reader/NFCPassportReader.podspec +27 -0
  181. package/vendor/ios-passport-reader/Package.swift +29 -0
  182. package/vendor/ios-passport-reader/README.md +141 -0
  183. package/vendor/ios-passport-reader/Sources/NFCPassportReader/AES_3DES_DESEncryption.swift +377 -0
  184. package/vendor/ios-passport-reader/Sources/NFCPassportReader/BACHandler.swift +194 -0
  185. package/vendor/ios-passport-reader/Sources/NFCPassportReader/ChipAuthenticationHandler.swift +224 -0
  186. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupHash.swift +16 -0
  187. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupParser.swift +36 -0
  188. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ActiveAuthenticationInfo.swift +69 -0
  189. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/COM.swift +61 -0
  190. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/CardAccess.swift +38 -0
  191. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationInfo.swift +135 -0
  192. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationPublicKeyInfo.swift +53 -0
  193. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup.swift +103 -0
  194. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup1.swift +111 -0
  195. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup11.swift +66 -0
  196. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup12.swift +75 -0
  197. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup14.swift +37 -0
  198. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup15.swift +46 -0
  199. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup2.swift +163 -0
  200. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup7.swift +46 -0
  201. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroupId.swift +105 -0
  202. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/NotImplementedDG.swift +16 -0
  203. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/PACEInfo.swift +415 -0
  204. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SOD.swift +240 -0
  205. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SecurityInfo.swift +136 -0
  206. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Errors.swift +148 -0
  207. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Logging.swift +32 -0
  208. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Models/FaceImageInfo.swift +161 -0
  209. package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCPassportModel.swift +540 -0
  210. package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCViewDisplayMessage.swift +60 -0
  211. package/vendor/ios-passport-reader/Sources/NFCPassportReader/OpenSSLUtils.swift +705 -0
  212. package/vendor/ios-passport-reader/Sources/NFCPassportReader/PACEHandler.swift +627 -0
  213. package/vendor/ios-passport-reader/Sources/NFCPassportReader/PassportReader.swift +387 -0
  214. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Resources/PrivacyInfo.xcprivacy +14 -0
  215. package/vendor/ios-passport-reader/Sources/NFCPassportReader/ResponseAPDU.swift +25 -0
  216. package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessaging.swift +301 -0
  217. package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessagingSessionKeyGenerator.swift +156 -0
  218. package/vendor/ios-passport-reader/Sources/NFCPassportReader/SimpleASN1DumpParser.swift +173 -0
  219. package/vendor/ios-passport-reader/Sources/NFCPassportReader/TagReader.swift +374 -0
  220. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Utils.swift +430 -0
  221. package/vendor/ios-passport-reader/Sources/NFCPassportReader/X509Wrapper.swift +168 -0
  222. package/vendor/ios-passport-reader/scripts/README.md +45 -0
  223. 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
+