@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,430 @@
1
+ //
2
+ // Utils.swift
3
+ // NFCTest
4
+ //
5
+ // Created by Andy Qua on 09/06/2019.
6
+ // Copyright © 2019 Andy Qua. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+ import OSLog
11
+
12
+ import CommonCrypto
13
+ import CryptoTokenKit
14
+
15
+ #if canImport(CryptoKit)
16
+ import CryptoKit
17
+ #endif
18
+
19
+ private extension UInt8 {
20
+ var hexString: String {
21
+ let string = String(self, radix: 16)
22
+ return (self < 16 ? "0" + string : string)
23
+ }
24
+ }
25
+
26
+ extension Int {
27
+ var hexString: String {
28
+ String(format:"%02X", self)
29
+ }
30
+ }
31
+
32
+ extension FileManager {
33
+ static var documentDir : URL {
34
+ return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
35
+ }
36
+ }
37
+
38
+ extension StringProtocol {
39
+ subscript(bounds: CountableClosedRange<Int>) -> SubSequence {
40
+ let start = index(startIndex, offsetBy: bounds.lowerBound)
41
+ let end = index(start, offsetBy: bounds.count)
42
+ return self[start..<end]
43
+ }
44
+
45
+ subscript(bounds: CountableRange<Int>) -> SubSequence {
46
+ let start = index(startIndex, offsetBy: bounds.lowerBound)
47
+ let end = index(start, offsetBy: bounds.count)
48
+ return self[start..<end]
49
+ }
50
+
51
+ func index(of string: Self, options: String.CompareOptions = []) -> Index? {
52
+ return range(of: string, options: options)?.lowerBound
53
+ }
54
+
55
+ }
56
+
57
+
58
+ public func binToHexRep( _ val : [UInt8], asArray : Bool = false ) -> String {
59
+ var string = asArray ? "[" : ""
60
+ for x in val {
61
+ if asArray {
62
+ string += String(format:"0x%02x, ", x )
63
+
64
+ } else {
65
+ string += String(format:"%02x", x )
66
+ }
67
+ }
68
+ string += asArray ? "]" : ""
69
+ return asArray ? string : string.uppercased()
70
+ }
71
+
72
+ public func binToHexRep( _ val : UInt8 ) -> String {
73
+ let string = String(format:"%02x", val ).uppercased()
74
+ return string
75
+ }
76
+
77
+ public func binToHex( _ val: UInt8 ) -> Int {
78
+ let hexRep = String(format:"%02X", val)
79
+ return Int(hexRep, radix:16)!
80
+ }
81
+
82
+ public func binToHex( _ val: [UInt8] ) -> UInt64 {
83
+ let hexVal = UInt64(binToHexRep(val), radix:16)!
84
+ return hexVal
85
+ }
86
+
87
+ public func binToHex( _ val: ArraySlice<UInt8> ) -> UInt64 {
88
+ return binToHex( [UInt8](val) )
89
+ }
90
+
91
+
92
+ public func hexToBin( _ val : UInt64 ) -> [UInt8] {
93
+ let hexRep = String(format:"%lx", val)
94
+ return hexRepToBin( hexRep)
95
+ }
96
+
97
+ public func binToInt( _ val: ArraySlice<UInt8> ) -> Int {
98
+ let hexVal = binToInt( [UInt8](val) )
99
+ return hexVal
100
+ }
101
+
102
+ public func binToInt( _ val: [UInt8] ) -> Int {
103
+ let hexVal = Int(binToHexRep(val), radix:16)!
104
+ return hexVal
105
+ }
106
+
107
+ public func intToBin(_ data : Int, pad : Int = 2) -> [UInt8] {
108
+ if pad == 2 {
109
+ let hex = String(format:"%02x", data)
110
+ return hexRepToBin(hex)
111
+ } else {
112
+ let hex = String(format:"%04x", data)
113
+ return hexRepToBin(hex)
114
+
115
+ }
116
+ }
117
+
118
+ /// 'AABB' --> \xaa\xbb'"""
119
+ public func hexRepToBin(_ val : String) -> [UInt8] {
120
+ var output : [UInt8] = []
121
+ var x = 0
122
+ while x < val.count {
123
+ if x+2 <= val.count {
124
+ output.append( UInt8(val[x ..< x + 2], radix:16)! )
125
+ } else {
126
+ output.append( UInt8(val[x ..< x+1], radix:16)! )
127
+
128
+ }
129
+ x += 2
130
+ }
131
+ return output
132
+ }
133
+
134
+ public func xor(_ kifd : [UInt8], _ response_kicc : [UInt8] ) -> [UInt8] {
135
+ var kseed = [UInt8]()
136
+ for i in 0 ..< kifd.count {
137
+ kseed.append( kifd[i] ^ response_kicc[i] )
138
+ }
139
+ return kseed
140
+ }
141
+
142
+ public func generateRandomUInt8Array( _ size: Int ) -> [UInt8] {
143
+
144
+ var ret : [UInt8] = []
145
+ for _ in 0 ..< size {
146
+ ret.append( UInt8(arc4random_uniform(UInt32(UInt8.max) + 1)) )
147
+ }
148
+ return ret
149
+ }
150
+
151
+ public func pad(_ toPad : [UInt8], blockSize : Int) -> [UInt8] {
152
+
153
+ var ret = toPad + [0x80]
154
+ while ret.count % blockSize != 0 {
155
+ ret.append(0x00)
156
+ }
157
+ return ret
158
+ }
159
+
160
+ public func unpad( _ tounpad : [UInt8]) -> [UInt8] {
161
+ var i = tounpad.count-1
162
+ while tounpad[i] == 0x00 {
163
+ i -= 1
164
+ }
165
+
166
+ if tounpad[i] == 0x80 {
167
+ return [UInt8](tounpad[0..<i])
168
+ } else {
169
+ // no padding
170
+ return tounpad
171
+ }
172
+ }
173
+
174
+ @available(iOS 13, macOS 10.15, *)
175
+ public func mac(algoName: SecureMessagingSupportedAlgorithms, key : [UInt8], msg : [UInt8]) -> [UInt8] {
176
+ if algoName == .DES {
177
+ return desMAC(key: key, msg: msg)
178
+ } else {
179
+ return aesMAC(key: key, msg: msg)
180
+ }
181
+ }
182
+
183
+ @available(iOS 13, macOS 10.15, *)
184
+ public func desMAC(key : [UInt8], msg : [UInt8]) -> [UInt8]{
185
+
186
+ let size = msg.count / 8
187
+ var y : [UInt8] = [0,0,0,0,0,0,0,0]
188
+
189
+ Logger.passportReader.debug("Calc mac" )
190
+ for i in 0 ..< size {
191
+ let tmp = [UInt8](msg[i*8 ..< i*8+8])
192
+ Logger.passportReader.debug("x\(i): \(binToHexRep(tmp))" )
193
+ y = DESEncrypt(key: [UInt8](key[0..<8]), message: tmp, iv: y)
194
+ Logger.passportReader.debug("y\(i): \(binToHexRep(y))" )
195
+ }
196
+
197
+ Logger.passportReader.debug("y: \(binToHexRep(y))" )
198
+ Logger.passportReader.debug("bkey: \(binToHexRep([UInt8](key[8..<16])))" )
199
+ Logger.passportReader.debug("akey: \(binToHexRep([UInt8](key[0..<8])))" )
200
+ let iv : [UInt8] = [0,0,0,0,0,0,0,0]
201
+ let b = DESDecrypt(key: [UInt8](key[8..<16]), message: y, iv: iv, options:UInt32(kCCOptionECBMode))
202
+ Logger.passportReader.debug( "b: \(binToHexRep(b))" )
203
+ let a = DESEncrypt(key: [UInt8](key[0..<8]), message: b, iv: iv, options:UInt32(kCCOptionECBMode))
204
+ Logger.passportReader.debug( "a: \(binToHexRep(a))" )
205
+
206
+ return a
207
+ }
208
+
209
+ @available(iOS 13, macOS 10.15, *)
210
+ public func aesMAC( key: [UInt8], msg : [UInt8] ) -> [UInt8] {
211
+ let mac = OpenSSLUtils.generateAESCMAC( key: key, message:msg )
212
+ return mac
213
+ }
214
+
215
+ @available(iOS 13, macOS 10.15, *)
216
+ public func wrapDO( b : UInt8, arr : [UInt8] ) -> [UInt8] {
217
+ let tag = TKBERTLVRecord(tag: TKTLVTag(b), value: Data(arr))
218
+ let result = [UInt8](tag.data)
219
+ return result;
220
+ }
221
+
222
+ @available(iOS 13, macOS 10.15, *)
223
+ public func unwrapDO( tag : UInt8, wrappedData : [UInt8]) throws -> [UInt8] {
224
+ guard let rec = TKBERTLVRecord(from: Data(wrappedData)),
225
+ rec.tag == tag else {
226
+ throw NFCPassportReaderError.InvalidASN1Value
227
+ }
228
+ return [UInt8](rec.value);
229
+ }
230
+
231
+
232
+ public func intToBytes( val: Int, removePadding:Bool) -> [UInt8] {
233
+ if val == 0 {
234
+ return [0]
235
+ }
236
+ var data = withUnsafeBytes(of: val.bigEndian, Array.init)
237
+
238
+ if removePadding {
239
+ // Remove initial 0 bytes
240
+ for i in 0 ..< data.count {
241
+ if data[i] != 0 {
242
+ data = [UInt8](data[i...])
243
+ break
244
+ }
245
+ }
246
+ }
247
+ return data
248
+ }
249
+
250
+ @available(iOS 13, macOS 10.15, *)
251
+ public func oidToBytes(oid : String, replaceTag : Bool) -> [UInt8] {
252
+ var encOID = OpenSSLUtils.asn1EncodeOID(oid: oid)
253
+
254
+ if replaceTag {
255
+ // Replace tag (0x06) with 0x80
256
+ encOID[0] = 0x80
257
+ }
258
+ return encOID
259
+ }
260
+
261
+
262
+
263
+ /// Take an asn.1 length, and return a couple with the decoded length in hexa and the total length of the encoding (1,2 or 3 bytes)
264
+ ///
265
+ /// Using Basic Encoding Rules (BER):
266
+ /// If the first byte is <= 0x7F (0-127), then this is the total length of the data
267
+ /// If the first byte is 0x81 then the length is the value of the next byte
268
+ /// If the first byte is 0x82 then the length is the value of the next two bytes
269
+ /// If the first byte is 0x80 then the length is indefinite (never seen this and not sure exactle what it means)
270
+ /// e.g.
271
+ /// if the data was 0x02, 0x11, 0x12, then the amount of data we have to read is two bytes, and the actual data is [0x11, 0x12]
272
+ /// If the length was 0x81,0x80,....... then we know that the data length is contained in the next byte - 0x80 (128), so the amount of data to read is 128 bytes
273
+ /// If the length was 0x82,0x01,0x01,....... then we know that the data length is contained in the next 2 bytes - 0x01, 0x01 (257) so the amount of data to read is 257 bytes
274
+ ///
275
+ /// @param data: A length value encoded in the asn.1 format.
276
+ /// @type data: A binary string.
277
+ /// @return: A tuple with the decoded hexa length and the length of the asn.1 encoded value.
278
+ /// @raise asn1Exception: If the parameter does not follow the asn.1 notation.
279
+
280
+ @available(iOS 13, macOS 10.15, *)
281
+ public func asn1Length( _ data: ArraySlice<UInt8> ) throws -> (Int, Int) {
282
+ return try asn1Length( Array(data) )
283
+ }
284
+
285
+ @available(iOS 13, macOS 10.15, *)
286
+ public func asn1Length(_ data : [UInt8]) throws -> (Int, Int) {
287
+ if data[0] < 0x80 {
288
+ return (Int(binToHex(data[0])), 1)
289
+ }
290
+ if data[0] == 0x81 {
291
+ return (Int(binToHex(data[1])), 2)
292
+ }
293
+ if data[0] == 0x82 {
294
+ let val = binToHex([UInt8](data[1..<3]))
295
+ return (Int(val), 3)
296
+ }
297
+
298
+ throw NFCPassportReaderError.CannotDecodeASN1Length
299
+
300
+ }
301
+
302
+ /// Convert a length to asn.1 format
303
+ /// @param data: The value to encode in asn.1
304
+ /// @type data: An integer (hexa)
305
+ /// @return: The asn.1 encoded value
306
+ /// @rtype: A binary string
307
+ /// @raise asn1Exception: If the parameter is too big, must be >= 0 and <= FFFF
308
+ @available(iOS 13, macOS 10.15, *)
309
+ public func toAsn1Length(_ data : Int) throws -> [UInt8] {
310
+ if data < 0x80 {
311
+ return hexRepToBin(String(format:"%02x", data))
312
+ }
313
+ if data >= 0x80 && data <= 0xFF {
314
+ return [0x81] + hexRepToBin( String(format:"%02x",data))
315
+ }
316
+ if data >= 0x0100 && data <= 0xFFFF {
317
+ return [0x82] + hexRepToBin( String(format:"%04x",data))
318
+ }
319
+
320
+ throw NFCPassportReaderError.InvalidASN1Value
321
+ }
322
+
323
+
324
+
325
+ /// This function calculates a Hash of the input data based on the input algorithm
326
+ /// @param data: a byte array of data
327
+ /// @param hashAlgorithm: the hash algorithm to be used - supported ones are SHA1, SHA224, SHA256, SHA384 and SHA512
328
+ /// Currently specifying any others return empty array
329
+ /// @return: A hash of the data
330
+ @available(iOS 13, macOS 10.15, *)
331
+ public func calcHash( data: [UInt8], hashAlgorithm: String ) throws -> [UInt8] {
332
+ var ret : [UInt8] = []
333
+
334
+ let hashAlgorithm = hashAlgorithm.lowercased()
335
+ if hashAlgorithm == "sha1" {
336
+ ret = calcSHA1Hash(data)
337
+ } else if hashAlgorithm == "sha224" {
338
+ ret = calcSHA224Hash(data)
339
+ } else if hashAlgorithm == "sha256" {
340
+ ret = calcSHA256Hash(data)
341
+ } else if hashAlgorithm == "sha384" {
342
+ ret = calcSHA384Hash(data)
343
+ } else if hashAlgorithm == "sha512" {
344
+ ret = calcSHA512Hash(data)
345
+ } else {
346
+ throw NFCPassportReaderError.InvalidHashAlgorithmSpecified
347
+ }
348
+
349
+ return ret
350
+ }
351
+
352
+
353
+ /// This function calculates a SHA1 Hash of the input data
354
+ /// @param data: a byte array of data
355
+ /// @return: A SHA1 hash of the data
356
+ @available(iOS 13, macOS 10.15, *)
357
+ public func calcSHA1Hash( _ data: [UInt8] ) -> [UInt8] {
358
+ #if canImport(CryptoKit)
359
+ var sha1 = Insecure.SHA1()
360
+ sha1.update(data: data)
361
+ let hash = sha1.finalize()
362
+
363
+ return Array(hash)
364
+ #else
365
+ fatalError("Couldn't import CryptoKit")
366
+ #endif
367
+ }
368
+
369
+ /// This function calculates a SHA224 Hash of the input data
370
+ /// @param data: a byte array of data
371
+ /// @return: A SHA224 hash of the data
372
+ @available(iOS 13, macOS 10.15, *)
373
+ public func calcSHA224Hash( _ data: [UInt8] ) -> [UInt8] {
374
+
375
+ var digest = [UInt8](repeating: 0, count:Int(CC_SHA224_DIGEST_LENGTH))
376
+
377
+ data.withUnsafeBytes {
378
+ _ = CC_SHA224($0.baseAddress, CC_LONG(data.count), &digest)
379
+ }
380
+ return digest
381
+ }
382
+
383
+ /// This function calculates a SHA256 Hash of the input data
384
+ /// @param data: a byte array of data
385
+ /// @return: A SHA256 hash of the data
386
+ @available(iOS 13, macOS 10.15, *)
387
+ public func calcSHA256Hash( _ data: [UInt8] ) -> [UInt8] {
388
+ #if canImport(CryptoKit)
389
+ var sha256 = SHA256()
390
+ sha256.update(data: data)
391
+ let hash = sha256.finalize()
392
+
393
+ return Array(hash)
394
+ #else
395
+ fatalError("Couldn't import CryptoKit")
396
+ #endif
397
+ }
398
+
399
+ /// This function calculates a SHA512 Hash of the input data
400
+ /// @param data: a byte array of data
401
+ /// @return: A SHA512 hash of the data
402
+ @available(iOS 13, macOS 10.15, *)
403
+ public func calcSHA512Hash( _ data: [UInt8] ) -> [UInt8] {
404
+ #if canImport(CryptoKit)
405
+ var sha512 = SHA512()
406
+ sha512.update(data: data)
407
+ let hash = sha512.finalize()
408
+
409
+ return Array(hash)
410
+ #else
411
+ fatalError("Couldn't import CryptoKit")
412
+ #endif
413
+ }
414
+
415
+ /// This function calculates a SHA384 Hash of the input data
416
+ /// @param data: a byte array of data
417
+ /// @return: A SHA384 hash of the data
418
+ @available(iOS 13, macOS 10.15, *)
419
+ public func calcSHA384Hash( _ data: [UInt8] ) -> [UInt8] {
420
+ #if canImport(CryptoKit)
421
+ var sha384 = SHA384()
422
+ sha384.update(data: data)
423
+ let hash = sha384.finalize()
424
+
425
+ return Array(hash)
426
+ #else
427
+ fatalError("Couldn't import CryptoKit")
428
+ #endif
429
+ }
430
+
@@ -0,0 +1,168 @@
1
+ //
2
+ // X509Wrapper.swift
3
+ // NFCPassportReader
4
+ //
5
+ // Created by Andy Qua on 29/10/2019.
6
+ //
7
+
8
+ import OpenSSL
9
+
10
+ @available(iOS 13, macOS 10.15, *)
11
+ public enum CertificateType {
12
+ case documentSigningCertificate
13
+ case issuerSigningCertificate
14
+ }
15
+
16
+ @available(iOS 13, macOS 10.15, *)
17
+ public enum CertificateItem : String {
18
+ case fingerprint = "Certificate fingerprint"
19
+ case issuerName = "Issuer"
20
+ case subjectName = "Subject"
21
+ case serialNumber = "Serial number"
22
+ case signatureAlgorithm = "Signature algorithm"
23
+ case publicKeyAlgorithm = "Public key algorithm"
24
+ case notBefore = "Valid from"
25
+ case notAfter = "Valid to"
26
+ }
27
+
28
+ @available(iOS 13, macOS 10.15, *)
29
+ public class X509Wrapper {
30
+ public let cert : OpaquePointer
31
+
32
+ public init?( with cert: OpaquePointer? ) {
33
+ guard let cert = cert else { return nil }
34
+
35
+ self.cert = X509_dup(cert)
36
+ }
37
+
38
+ public func getItemsAsDict() -> [CertificateItem:String] {
39
+ var item = [CertificateItem:String]()
40
+ if let fingerprint = self.getFingerprint() {
41
+ item[.fingerprint] = fingerprint
42
+ }
43
+ if let issuerName = self.getIssuerName() {
44
+ item[.issuerName] = issuerName
45
+
46
+ }
47
+ if let subjectName = self.getSubjectName() {
48
+ item[.subjectName] = subjectName
49
+ }
50
+ if let serialNr = self.getSerialNumber() {
51
+ item[.serialNumber] = serialNr
52
+ }
53
+ if let signatureAlgorithm = self.getSignatureAlgorithm() {
54
+ item[.signatureAlgorithm] = signatureAlgorithm
55
+ }
56
+ if let publicKeyAlgorithm = self.getPublicKeyAlgorithm() {
57
+ item[.publicKeyAlgorithm] = publicKeyAlgorithm
58
+ }
59
+ if let notBefore = self.getNotBeforeDate() {
60
+ item[.notBefore] = notBefore
61
+ }
62
+ if let notAfter = self.getNotAfterDate() {
63
+ item[.notAfter] = notAfter
64
+ }
65
+
66
+ return item
67
+ }
68
+ public func certToPEM() -> String {
69
+ return OpenSSLUtils.X509ToPEM( x509:cert )
70
+ }
71
+
72
+ public func getFingerprint( ) -> String? {
73
+ let fdig = EVP_sha1();
74
+
75
+ var n : UInt32 = 0
76
+ let md = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(EVP_MAX_MD_SIZE))
77
+ defer { md.deinitialize(count: Int(EVP_MAX_MD_SIZE)); md.deallocate() }
78
+
79
+ X509_digest(cert, fdig, md, &n)
80
+ let arr = UnsafeMutableBufferPointer(start: md, count: Int(n)).map({ binToHexRep($0) }).joined(separator: ":")
81
+ return arr
82
+ }
83
+
84
+ public func getNotBeforeDate() -> String? {
85
+ var notBefore : String?
86
+ if let val = X509_get0_notBefore(cert) {
87
+ notBefore = ASN1TimeToString( val )
88
+ }
89
+ return notBefore
90
+
91
+ }
92
+
93
+ public func getNotAfterDate() -> String? {
94
+ var notAfter : String?
95
+ if let val = X509_get0_notAfter(cert) {
96
+ notAfter = ASN1TimeToString( val )
97
+ }
98
+ return notAfter
99
+ }
100
+
101
+ public func getSerialNumber() -> String? {
102
+ let serialNr = String( ASN1_INTEGER_get(X509_get_serialNumber(cert)), radix:16, uppercase: true )
103
+ return serialNr
104
+ }
105
+
106
+ public func getSignatureAlgorithm() -> String? {
107
+ let algor = X509_get0_tbs_sigalg(cert);
108
+ let algo = getAlgorithm( algor?.pointee.algorithm )
109
+ return algo
110
+ }
111
+
112
+ public func getPublicKeyAlgorithm() -> String? {
113
+ let pubKey = X509_get_X509_PUBKEY(cert)
114
+ var ptr : OpaquePointer?
115
+ X509_PUBKEY_get0_param(&ptr, nil, nil, nil, pubKey)
116
+ let algo = getAlgorithm(ptr)
117
+ return algo
118
+ }
119
+
120
+ public func getIssuerName() -> String? {
121
+ return getName(for: X509_get_issuer_name(cert))
122
+ }
123
+
124
+ public func getSubjectName() -> String? {
125
+ return getName(for: X509_get_subject_name(cert))
126
+ }
127
+
128
+ private func getName( for name: OpaquePointer? ) -> String? {
129
+ guard let name = name else { return nil }
130
+
131
+ var issuer: String = ""
132
+
133
+ guard let out = BIO_new( BIO_s_mem()) else { return nil }
134
+ defer { BIO_free(out) }
135
+
136
+ X509_NAME_print_ex(out, name, 0, UInt(ASN1_STRFLGS_ESC_2253 |
137
+ ASN1_STRFLGS_ESC_CTRL |
138
+ ASN1_STRFLGS_ESC_MSB |
139
+ ASN1_STRFLGS_UTF8_CONVERT |
140
+ ASN1_STRFLGS_DUMP_UNKNOWN |
141
+ ASN1_STRFLGS_DUMP_DER | XN_FLAG_SEP_COMMA_PLUS |
142
+ XN_FLAG_DN_REV |
143
+ XN_FLAG_FN_SN |
144
+ XN_FLAG_DUMP_UNKNOWN_FIELDS))
145
+ issuer = OpenSSLUtils.bioToString(bio: out)
146
+
147
+ return issuer
148
+ }
149
+
150
+ private func getAlgorithm( _ algo: OpaquePointer? ) -> String? {
151
+ guard let algo = algo else { return nil }
152
+ let len = OBJ_obj2nid(algo)
153
+ var algoString : String? = nil
154
+ if let sa = OBJ_nid2ln(len) {
155
+ algoString = String(cString: sa )
156
+ }
157
+ return algoString
158
+ }
159
+
160
+ private func ASN1TimeToString( _ date: UnsafePointer<ASN1_TIME> ) -> String? {
161
+ guard let b = BIO_new(BIO_s_mem()) else { return nil }
162
+ defer { BIO_free(b) }
163
+
164
+ ASN1_TIME_print(b, date)
165
+ return OpenSSLUtils.bioToString(bio: b)
166
+ }
167
+
168
+ }
@@ -0,0 +1,45 @@
1
+ # Master list generator
2
+
3
+ ## What is it?
4
+ This script will create a file containing a set of unique CSCA (Country Signing Certificate Authority) certificates in PEM format from a country master List or the ICAO PKD repository.
5
+
6
+ These are used to verify both Document Signing certificates and Security Object DS Signatures (SOD) contained in e-passports and other electronic identity cards.
7
+
8
+ It can accept either the ICOA PDK master list file in LDIF format (which is a collection of master lists from validated countries), or a single Country masterlist file in Cryptographic Message Syntax (CMS) format.
9
+
10
+ # Where can I get a master list from?
11
+ ICAO makes their master lists available "freely available online to any person or State who wishes to download it. However, the process of downloading is manual and cannot be automated" (https://www.icao.int/Security/FAL/PKD/BVRT/Pages/Access.aspx)
12
+
13
+ The master lists can be downloaded from: https://download.pkd.icao.int (previously was https://pkddownloadsg.icao.int but this seems to be unavailable now)
14
+
15
+ These are in LDIF (LDAP Data Interchange Format) format
16
+
17
+ Additionally, some countries make their master lists available (e.g. Germany, France and Italy are ones I've found). Do a search for <country> masterlist or the JMRTD project has a list (some links no longer work though) - https://jmrtd.org/certificates.shtml Yobi Wifi
18
+
19
+ These files will usually be zipped, so extract these files and you should end up with a <file>.ml.
20
+
21
+ Obviously you should only use masterlists from a source you trust!
22
+
23
+ ## Requirements
24
+
25
+ The script uses Python 3.7 (other versions of Python 3 may work - not tried).
26
+
27
+
28
+ It also requires a version of OpenSSL that supports the CMS flag.
29
+
30
+ The version that comes with macOS (including Catalina) doesn't support this so you will need to get that from somewhere else (e.g. Homebrew).
31
+
32
+ ## Usage
33
+ To run the script, simply run:
34
+ python extract.py [Country master list.ml|ICAO LDIF file]
35
+
36
+ e.g.
37
+ python extract.py icaopkd-002-ml-000119.ldif
38
+
39
+
40
+ It will run through the masterlist(s) contained within the file and you should end up with a new masterList.pem file which is a concatenation of all the unique certificates.
41
+
42
+ This can then be imported into the NFCPassportReader app and used to verify an e-passport using Passive Authentication.
43
+
44
+ ## Credits
45
+ This script is pretty much based on the details from http://wiki.yobi.be/wiki/EPassport with some additional bits for de-duplicating certificates.