From 0862c1388e1b42ecf6b3c4db91c3e824aac319ba Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Wed, 17 Jul 2019 00:19:23 +0800 Subject: [PATCH] Use ObjectivePGP if Gopenpgp fails --- .travis.yml | 3 + Podfile | 25 +++ pass.xcodeproj/project.pbxproj | 190 ++++++++++++++++++ .../Controllers/PasswordsViewController.swift | 4 +- passKit/Models/PasswordStore.swift | 77 ++++++- 5 files changed, 286 insertions(+), 13 deletions(-) create mode 100644 Podfile diff --git a/.travis.yml b/.travis.yml index cdd02b0..1045a8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ before_install: - echo -e "machine github.com\n login $GITHUB_ACCESS_TOKEN" >> ~/.netrc install: - gem update fastlane + - gem uninstall -aIx cocoapods + - gem install cocoapods -v 1.5.3 + - pod --version before_script: - | if [ ! $(git diff --name-only master..."$TRAVIS_COMMIT" | grep "Cartfile.resolved") ] && [ -d "Carthage/Build" ]; then diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..13ea5b9 --- /dev/null +++ b/Podfile @@ -0,0 +1,25 @@ +platform :ios, '10.2' +use_frameworks! + +target 'passKit' do + pod 'ObjectivePGP', :git => 'https://github.com/krzyzanowskim/ObjectivePGP.git', :tag => '0.14.0' + target 'pass' do + inherit! :search_paths + end + target 'passExtension' do + inherit! :search_paths + end + target 'passKitTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + cflags = config.build_settings['OTHER_CFLAGS'] || ['$(inherited)'] + cflags << '-fembed-bitcode' + config.build_settings['OTHER_CFLAGS'] = cflags + end + end +end diff --git a/pass.xcodeproj/project.pbxproj b/pass.xcodeproj/project.pbxproj index 2b86e8e..35e31b6 100644 --- a/pass.xcodeproj/project.pbxproj +++ b/pass.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ 30C25DD721F4834D00BB27BB /* UILocalizedLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30C25DD521F4834D00BB27BB /* UILocalizedLabel.swift */; }; 30C25DD821F4834D00BB27BB /* UICodeHighlightingLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30C25DD621F4834D00BB27BB /* UICodeHighlightingLabel.swift */; }; 30FD2F78214D9E0E005E0A92 /* ParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30FD2F77214D9E0E005E0A92 /* ParserTest.swift */; }; + 369256FF46E6E8947151C659 /* Pods_passKitTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B2B2F844061EFA534FE9506 /* Pods_passKitTests.framework */; }; 556EC3D322335C5F00934F9C /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30BF5ECA21EA8FB5000E4154 /* Localizable.strings */; }; 556EC3D422335C5F00934F9C /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 30BF5ED521ED2434000E4154 /* Localizable.stringsdict */; }; 556EC3D522335CD900934F9C /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30BF5ECA21EA8FB5000E4154 /* Localizable.strings */; }; @@ -66,6 +67,7 @@ 556EC3D922335D2800934F9C /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 30BF5ED521ED2434000E4154 /* Localizable.stringsdict */; }; 556EC3DA22335D3400934F9C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30C25DBF21F3599E00BB27BB /* InfoPlist.strings */; }; 556EC3DB22335D3D00934F9C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30C25DBF21F3599E00BB27BB /* InfoPlist.strings */; }; + 56CA683433A6F6237041D454 /* Pods_passExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14E955B67C88672AA3A40BA0 /* Pods_passExtension.framework */; }; 9A714BD022AC61170020C3BB /* Gopenpgpwrapper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1154BEDB229AC00F00454075 /* Gopenpgpwrapper.framework */; }; A20691F41F2A3D0E0096483D /* SecurePasteboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A20691F31F2A3D0E0096483D /* SecurePasteboard.swift */; }; A217ACE41E9BBBBD00A1A6CF /* GitConfigSettingTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A217ACE31E9BBBBD00A1A6CF /* GitConfigSettingTableViewController.swift */; }; @@ -94,6 +96,7 @@ A2A61C171EEF90CB00CFE063 /* OneTimePassword.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCA671DE1E7A73B100D3ABE1 /* OneTimePassword.framework */; }; A2A61C201EEFABAD00CFE063 /* UtilsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2A61C1F1EEFABAD00CFE063 /* UtilsExtension.swift */; }; A2A7813F1E97DBD9001311F5 /* QRScannerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A2A7813E1E97DBD9001311F5 /* QRScannerController.swift */; }; + DA2679F1424EA94B5B8997FB /* Pods_pass.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE627E8F3DACEDD8FA220081 /* Pods_pass.framework */; }; DC037CA61E4B883900609409 /* OpenSourceComponentsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CA51E4B883900609409 /* OpenSourceComponentsTableViewController.swift */; }; DC037CA81E4B898100609409 /* BasicStaticTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CA71E4B898100609409 /* BasicStaticTableViewController.swift */; }; DC037CAA1E4B8EAE00609409 /* SpecialThanksTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC037CA91E4B8EAE00609409 /* SpecialThanksTableViewController.swift */; }; @@ -132,6 +135,7 @@ DCFB77A71E502DF9008DE471 /* EditPasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77A61E502DF9008DE471 /* EditPasswordTableViewController.swift */; }; DCFB77A91E502FF6008DE471 /* PasswordEditorTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77A81E502FF6008DE471 /* PasswordEditorTableViewController.swift */; }; DCFB77AB1E503729008DE471 /* ContentProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFB77AA1E503729008DE471 /* ContentProvider.swift */; }; + E813E400BBF3E7E8975EBAEF /* Pods_passKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 134DA5B66070BA56678688CF /* Pods_passKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -206,7 +210,11 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 04ACE535BB8E82352E077507 /* Pods-passExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-passExtension.release.xcconfig"; path = "Pods/Target Support Files/Pods-passExtension/Pods-passExtension.release.xcconfig"; sourceTree = ""; }; 1154BEDB229AC00F00454075 /* Gopenpgpwrapper.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Gopenpgpwrapper.framework; path = go/dist/Gopenpgpwrapper.framework; sourceTree = ""; }; + 134DA5B66070BA56678688CF /* Pods_passKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_passKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 14E955B67C88672AA3A40BA0 /* Pods_passExtension.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_passExtension.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2B31E2F93F817EFCF5959FCA /* Pods-passKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-passKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-passKitTests/Pods-passKitTests.debug.xcconfig"; sourceTree = ""; }; 300713C42219D54100F553AC /* AutoCellHeightUITableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoCellHeightUITableViewController.swift; sourceTree = ""; }; 301F6462216162550071A4CE /* AdditionField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionField.swift; sourceTree = ""; }; 301F6467216165290071A4CE /* ConstantsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstantsTest.swift; sourceTree = ""; }; @@ -262,6 +270,11 @@ 30C25DD521F4834D00BB27BB /* UILocalizedLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UILocalizedLabel.swift; sourceTree = ""; }; 30C25DD621F4834D00BB27BB /* UICodeHighlightingLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICodeHighlightingLabel.swift; sourceTree = ""; }; 30FD2F77214D9E0E005E0A92 /* ParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParserTest.swift; sourceTree = ""; }; + 3B2B2F844061EFA534FE9506 /* Pods_passKitTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_passKitTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 612DA14EE59D23AD92518728 /* Pods-pass.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pass.release.xcconfig"; path = "Pods/Target Support Files/Pods-pass/Pods-pass.release.xcconfig"; sourceTree = ""; }; + 64AA8DF9E73F39CCC3317247 /* Pods-passKit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-passKit.release.xcconfig"; path = "Pods/Target Support Files/Pods-passKit/Pods-passKit.release.xcconfig"; sourceTree = ""; }; + 7CAD21E487234A0631B52E20 /* Pods-passKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-passKit.debug.xcconfig"; path = "Pods/Target Support Files/Pods-passKit/Pods-passKit.debug.xcconfig"; sourceTree = ""; }; + 8C40396E32FCBC2103F459BE /* Pods-pass.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pass.debug.xcconfig"; path = "Pods/Target Support Files/Pods-pass/Pods-pass.debug.xcconfig"; sourceTree = ""; }; A20691F31F2A3D0E0096483D /* SecurePasteboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SecurePasteboard.swift; sourceTree = ""; }; A217ACE31E9BBBBD00A1A6CF /* GitConfigSettingTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = GitConfigSettingTableViewController.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; A2367B9F1EF0387000C8FE8B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -336,6 +349,9 @@ DCFB77A61E502DF9008DE471 /* EditPasswordTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditPasswordTableViewController.swift; sourceTree = ""; }; DCFB77A81E502FF6008DE471 /* PasswordEditorTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordEditorTableViewController.swift; sourceTree = ""; }; DCFB77AA1E503729008DE471 /* ContentProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentProvider.swift; sourceTree = ""; }; + DEEA6FEB49C87207EE46BDCD /* Pods-passExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-passExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-passExtension/Pods-passExtension.debug.xcconfig"; sourceTree = ""; }; + FA4FFCEAFB22A17C442B15F7 /* Pods-passKitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-passKitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-passKitTests/Pods-passKitTests.release.xcconfig"; sourceTree = ""; }; + FE627E8F3DACEDD8FA220081 /* Pods_pass.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_pass.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -353,6 +369,7 @@ buildActionMask = 2147483647; files = ( 9A714BD022AC61170020C3BB /* Gopenpgpwrapper.framework in Frameworks */, + E813E400BBF3E7E8975EBAEF /* Pods_passKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -361,6 +378,7 @@ buildActionMask = 2147483647; files = ( A26075811EEC6F34005DB03E /* passKit.framework in Frameworks */, + 369256FF46E6E8947151C659 /* Pods_passKitTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -374,6 +392,7 @@ A2A61C161EEF90CB00CFE063 /* ObjectiveGit.framework in Frameworks */, A2A61C171EEF90CB00CFE063 /* OneTimePassword.framework in Frameworks */, A26075961EEC6F8C005DB03E /* passKit.framework in Frameworks */, + 56CA683433A6F6237041D454 /* Pods_passExtension.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -391,6 +410,7 @@ A239F5902158C07D00576CBF /* AuthenticationServices.framework in Frameworks */, A260758D1EEC6F34005DB03E /* passKit.framework in Frameworks */, DCC408C71E307DBB00F29B0E /* SVProgressHUD.framework in Frameworks */, + DA2679F1424EA94B5B8997FB /* Pods_pass.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -406,6 +426,21 @@ path = Helpers; sourceTree = ""; }; + 30468FC4444CE00A19257B78 /* Pods */ = { + isa = PBXGroup; + children = ( + 8C40396E32FCBC2103F459BE /* Pods-pass.debug.xcconfig */, + 612DA14EE59D23AD92518728 /* Pods-pass.release.xcconfig */, + DEEA6FEB49C87207EE46BDCD /* Pods-passExtension.debug.xcconfig */, + 04ACE535BB8E82352E077507 /* Pods-passExtension.release.xcconfig */, + 7CAD21E487234A0631B52E20 /* Pods-passKit.debug.xcconfig */, + 64AA8DF9E73F39CCC3317247 /* Pods-passKit.release.xcconfig */, + 2B31E2F93F817EFCF5959FCA /* Pods-passKitTests.debug.xcconfig */, + FA4FFCEAFB22A17C442B15F7 /* Pods-passKitTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 30697C5521F63F870064FCAC /* Extensions */ = { isa = PBXGroup; children = ( @@ -668,6 +703,7 @@ A26075861EEC6F34005DB03E /* passKitTests */, DC13B14F1E8640810097803F /* passTests */, DC917BD41E2E8231000FDF54 /* Products */, + 30468FC4444CE00A19257B78 /* Pods */, ); sourceTree = ""; }; @@ -716,6 +752,10 @@ DCA049951E3357E000522E8F /* SwiftyUserDefaults.framework */, DCC408C61E307DBB00F29B0E /* SVProgressHUD.framework */, 1154BEDB229AC00F00454075 /* Gopenpgpwrapper.framework */, + FE627E8F3DACEDD8FA220081 /* Pods_pass.framework */, + 14E955B67C88672AA3A40BA0 /* Pods_passExtension.framework */, + 134DA5B66070BA56678688CF /* Pods_passKit.framework */, + 3B2B2F844061EFA534FE9506 /* Pods_passKitTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -755,6 +795,7 @@ isa = PBXNativeTarget; buildConfigurationList = A260758F1EEC6F34005DB03E /* Build configuration list for PBXNativeTarget "passKit" */; buildPhases = ( + 1BB5DAFEBEB84E2A89D2CE62 /* [CP] Check Pods Manifest.lock */, A26075731EEC6F34005DB03E /* Sources */, A26075741EEC6F34005DB03E /* Frameworks */, A26075751EEC6F34005DB03E /* Headers */, @@ -773,9 +814,11 @@ isa = PBXNativeTarget; buildConfigurationList = A26075931EEC6F34005DB03E /* Build configuration list for PBXNativeTarget "passKitTests" */; buildPhases = ( + 58FD5CA233A49AFB4D4032B1 /* [CP] Check Pods Manifest.lock */, A260757C1EEC6F34005DB03E /* Sources */, A260757D1EEC6F34005DB03E /* Frameworks */, A260757E1EEC6F34005DB03E /* Resources */, + 78E02A398E49466B50118AAD /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -792,6 +835,7 @@ isa = PBXNativeTarget; buildConfigurationList = A267002F1EEC466A00176B8A /* Build configuration list for PBXNativeTarget "passExtension" */; buildPhases = ( + 68B241826F3CB0B2ECF8B97F /* [CP] Check Pods Manifest.lock */, A26700201EEC466A00176B8A /* Sources */, A26700211EEC466A00176B8A /* Frameworks */, A26700221EEC466A00176B8A /* Resources */, @@ -827,12 +871,14 @@ isa = PBXNativeTarget; buildConfigurationList = DC917BE51E2E8231000FDF54 /* Build configuration list for PBXNativeTarget "pass" */; buildPhases = ( + 300917CA733C345F8D0C9611 /* [CP] Check Pods Manifest.lock */, DC917BCF1E2E8231000FDF54 /* Sources */, DC917BD01E2E8231000FDF54 /* Frameworks */, DC917BD11E2E8231000FDF54 /* Resources */, DC917BEC1E2F3659000FDF54 /* Run Script */, A26700191EEC450100176B8A /* Embed App Extensions */, A26075921EEC6F34005DB03E /* Embed Frameworks */, + B667D66C22A8B5F3987638C6 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -1016,6 +1062,142 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 1BB5DAFEBEB84E2A89D2CE62 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-passKit-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 300917CA733C345F8D0C9611 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-pass-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 58FD5CA233A49AFB4D4032B1 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-passKitTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 68B241826F3CB0B2ECF8B97F /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-passExtension-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 78E02A398E49466B50118AAD /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-passKitTests/Pods-passKitTests-frameworks.sh", + "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework", + "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework.dSYM", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectivePGP.framework", + "${DWARF_DSYM_FOLDER_PATH}/ObjectivePGP.framework.dSYM", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-passKitTests/Pods-passKitTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + B667D66C22A8B5F3987638C6 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-pass/Pods-pass-frameworks.sh", + "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework", + "${PODS_ROOT}/ObjectivePGP/Frameworks/ios/ObjectivePGP.framework.dSYM", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectivePGP.framework", + "${DWARF_DSYM_FOLDER_PATH}/ObjectivePGP.framework.dSYM", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-pass/Pods-pass-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; DC917BEC1E2F3659000FDF54 /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 12; @@ -1322,6 +1504,7 @@ }; A26075901EEC6F34005DB03E /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7CAD21E487234A0631B52E20 /* Pods-passKit.debug.xcconfig */; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1364,6 +1547,7 @@ }; A26075911EEC6F34005DB03E /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 64AA8DF9E73F39CCC3317247 /* Pods-passKit.release.xcconfig */; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1405,6 +1589,7 @@ }; A26075941EEC6F34005DB03E /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 2B31E2F93F817EFCF5959FCA /* Pods-passKitTests.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1425,6 +1610,7 @@ }; A26075951EEC6F34005DB03E /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = FA4FFCEAFB22A17C442B15F7 /* Pods-passKitTests.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1445,6 +1631,7 @@ }; A26700301EEC466A00176B8A /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = DEEA6FEB49C87207EE46BDCD /* Pods-passExtension.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1472,6 +1659,7 @@ }; A26700311EEC466A00176B8A /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 04ACE535BB8E82352E077507 /* Pods-passExtension.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1662,6 +1850,7 @@ }; DC917BE61E2E8231000FDF54 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8C40396E32FCBC2103F459BE /* Pods-pass.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -1697,6 +1886,7 @@ }; DC917BE71E2E8231000FDF54 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 612DA14EE59D23AD92518728 /* Pods-pass.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index ec78fac..ea18752 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -453,7 +453,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { if identifier == "showPasswordDetail" { - guard self.passwordStore.privateKey != nil else { + guard self.passwordStore.hasPgpKey else { Utils.alert(title: "CannotShowPassword".localize(), message: "SetPgpKey.".localize(), controller: self, completion: nil) if let s = sender as? UITableViewCell { let selectedIndexPath = tableView.indexPath(for: s)! @@ -462,7 +462,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV return false } } else if identifier == "addPasswordSegue" { - guard self.passwordStore.publicKey != nil, self.passwordStore.storeRepository != nil else { + guard self.passwordStore.hasPgpKey, self.passwordStore.storeRepository != nil else { Utils.alert(title: "CannotAddPassword".localize(), message: "MakeSurePgpAndGitProperlySet.".localize(), controller: self, completion: nil) return false } diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index 046fd8a..f1d6a38 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -11,6 +11,7 @@ import CoreData import UIKit import SwiftyUserDefaults import ObjectiveGit +import ObjectivePGP import KeychainAccess import Gopenpgpwrapper @@ -28,12 +29,26 @@ public class PasswordStore { public var storeRepository: GTRepository? public var pgpKeyID: String? + public var hasPgpKey: Bool { + get { + return (publicKey != nil || publicKeyV2 != nil) && (privateKey != nil || privateKeyV2 != nil) + } + } + // Gopenpgpwrapper public var publicKey: GopenpgpwrapperKey? { didSet { pgpKeyID = publicKey?.getID() } } public var privateKey: GopenpgpwrapperKey? + // ObjectivePGP + public let keyring = ObjectivePGP.defaultKeyring + public var publicKeyV2: Key? { + didSet { + pgpKeyID = publicKeyV2?.keyID.shortIdentifier + } + } + public var privateKeyV2: Key? public var gitSignatureForNow: GTSignature? { get { @@ -199,7 +214,11 @@ public class PasswordStore { } private func initPGPKey(_ keyType: PgpKey) throws { - if let key = GopenpgpwrapperReadKey(AppKeychain.get(for: keyType.getKeychainKey())) { + // Read the key data from keychain. + let pgpKeyData: Data? = AppKeychain.get(for: keyType.getKeychainKey()) + + // Try GopenpgpwrapperReadKey first. + if let key = GopenpgpwrapperReadKey(pgpKeyData) { switch keyType { case .PUBLIC: self.publicKey = key @@ -208,6 +227,20 @@ public class PasswordStore { } return } + + // Try ObjectivePGP as a backup plan. + if let keys = try? ObjectivePGP.readKeys(from: pgpKeyData!), + let key = keys.first { + keyring.import(keys: keys) + switch keyType { + case .PUBLIC: + self.publicKeyV2 = key + case .PRIVATE: + self.privateKeyV2 = key + } + return + } + throw AppError.KeyImport } @@ -728,6 +761,10 @@ public class PasswordStore { public func erase() { publicKey = nil privateKey = nil + publicKeyV2 = nil + privateKeyV2 = nil + keyring.deleteAll() + try? fm.removeItem(at: storeURL) try? fm.removeItem(at: tempStoreURL) @@ -800,24 +837,39 @@ public class PasswordStore { if passphrase == nil { passphrase = requestPGPKeyPassphrase() } - guard let decryptedData = privateKey?.decrypt(encryptedData, passphrase: passphrase) else { - throw AppError.Decryption + // Try Gopenpgp. + if let decryptedData = privateKey?.decrypt(encryptedData, passphrase: passphrase) { + let plainText = String(data: decryptedData, encoding: .utf8) ?? "" + let url = try passwordEntity.getURL() + return Password(name: passwordEntity.getName(), url: url, plainText: plainText) } - let plainText = String(data: decryptedData, encoding: .utf8) ?? "" - let url = try passwordEntity.getURL() - return Password(name: passwordEntity.getName(), url: url, plainText: plainText) + // Try ObjectivePGP. + if let decryptedData = try? ObjectivePGP.decrypt(encryptedData, andVerifySignature: false, using: keyring.keys, passphraseForKey: {(_) in passphrase}) { + let plainText = String(data: decryptedData, encoding: .utf8) ?? "" + let url = try passwordEntity.getURL() + return Password(name: passwordEntity.getName(), url: url, plainText: plainText) + } + throw AppError.Decryption } public func encrypt(password: Password) throws -> Data { - guard publicKey != nil else { + guard publicKey != nil || keyring.keys.count > 0 else { throw AppError.PgpPublicKeyNotExist } let plainData = password.plainData - guard let encryptedData = publicKey?.encrypt(plainData, armor: SharedDefaults[.encryptInArmored]) else { - throw AppError.Encryption + // Try Gopenpgp. + if let encryptedData = publicKey?.encrypt(plainData, armor: SharedDefaults[.encryptInArmored]) { + return encryptedData } - - return encryptedData + // Try ObjectivePGP. + if let encryptedData = try? ObjectivePGP.encrypt(plainData, addSignature: false, using: keyring.keys, passphraseForKey: nil) { + if SharedDefaults[.encryptInArmored] { + return Armor.armored(encryptedData, as: .message).data(using: .utf8)! + } else { + return encryptedData + } + } + throw AppError.Encryption } public func removePGPKeys() { @@ -833,6 +885,9 @@ public class PasswordStore { pgpKeyPassphrase = nil publicKey = nil privateKey = nil + publicKeyV2 = nil + privateKeyV2 = nil + keyring.deleteAll() } public func removeGitSSHKeys() {