Mark field 'gpgAgent' as never-nil

This commit is contained in:
Danny Moesch 2019-07-20 22:59:22 +02:00
parent 2ece3ef07a
commit ea37b40e2f
10 changed files with 37 additions and 43 deletions

View file

@ -31,7 +31,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "saveAddPasswordSegue" { if identifier == "saveAddPasswordSegue" {
// check PGP key // check PGP key
guard passwordStore.pgpAgent?.isImported ?? false else { guard passwordStore.pgpAgent.isImported else {
let alertTitle = "CannotAddPassword".localize() let alertTitle = "CannotAddPassword".localize()
let alertMessage = "PgpKeyNotSet.".localize() let alertMessage = "PgpKeyNotSet.".localize()
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil) Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)

View file

@ -221,7 +221,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
@objc func rememberPGPPassphraseSwitchAction(_ sender: Any?) { @objc func rememberPGPPassphraseSwitchAction(_ sender: Any?) {
SharedDefaults[.isRememberPGPPassphraseOn] = rememberPGPPassphraseSwitch.isOn SharedDefaults[.isRememberPGPPassphraseOn] = rememberPGPPassphraseSwitch.isOn
if rememberPGPPassphraseSwitch.isOn == false { if rememberPGPPassphraseSwitch.isOn == false {
passwordStore.pgpAgent?.passphrase = nil passwordStore.pgpAgent.passphrase = nil
} }
} }

View file

@ -91,7 +91,7 @@ class PGPKeyArmorSettingTableViewController: AutoCellHeightUITableViewController
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
pgpPassphrase = passwordStore.pgpAgent?.passphrase pgpPassphrase = passwordStore.pgpAgent.passphrase
scanPublicKeyCell?.textLabel?.text = "ScanPublicKeyQrCodes".localize() scanPublicKeyCell?.textLabel?.text = "ScanPublicKeyQrCodes".localize()
scanPublicKeyCell?.textLabel?.textColor = Globals.blue scanPublicKeyCell?.textLabel?.textColor = Globals.blue

View file

@ -20,7 +20,7 @@ class PGPKeySettingTableViewController: AutoCellHeightUITableViewController {
super.viewDidLoad() super.viewDidLoad()
pgpPublicKeyURLTextField.text = SharedDefaults[.pgpPublicKeyURL]?.absoluteString pgpPublicKeyURLTextField.text = SharedDefaults[.pgpPublicKeyURL]?.absoluteString
pgpPrivateKeyURLTextField.text = SharedDefaults[.pgpPrivateKeyURL]?.absoluteString pgpPrivateKeyURLTextField.text = SharedDefaults[.pgpPrivateKeyURL]?.absoluteString
pgpPassphrase = passwordStore.pgpAgent?.passphrase pgpPassphrase = passwordStore.pgpAgent.passphrase
} }
private func validatePGPKeyURL(input: String?) -> Bool { private func validatePGPKeyURL(input: String?) -> Bool {

View file

@ -103,7 +103,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
} }
let _ = sem.wait(timeout: DispatchTime.distantFuture) let _ = sem.wait(timeout: DispatchTime.distantFuture)
if SharedDefaults[.isRememberPGPPassphraseOn] { if SharedDefaults[.isRememberPGPPassphraseOn] {
self.passwordStore.pgpAgent?.passphrase = passphrase self.passwordStore.pgpAgent.passphrase = passphrase
} }
return passphrase return passphrase
} }
@ -122,7 +122,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
} catch { } catch {
DispatchQueue.main.async { DispatchQueue.main.async {
// remove the wrong passphrase so that users could enter it next time // remove the wrong passphrase so that users could enter it next time
self.passwordStore.pgpAgent?.passphrase = nil self.passwordStore.pgpAgent.passphrase = nil
// alert: cancel or try again // alert: cancel or try again
let alert = UIAlertController(title: "CannotShowPassword".localize(), message: error.localizedDescription, preferredStyle: UIAlertController.Style.alert) let alert = UIAlertController(title: "CannotShowPassword".localize(), message: error.localizedDescription, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.default) { _ in alert.addAction(UIAlertAction(title: "Cancel".localize(), style: UIAlertAction.Style.default) { _ in

View file

@ -385,13 +385,13 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
SVProgressHUD.show(withStatus: "Decrypting".localize()) SVProgressHUD.show(withStatus: "Decrypting".localize())
} }
if SharedDefaults[.isRememberPGPPassphraseOn] { if SharedDefaults[.isRememberPGPPassphraseOn] {
self.passwordStore.pgpAgent?.passphrase = passphrase self.passwordStore.pgpAgent.passphrase = passphrase
} }
return passphrase return passphrase
} }
private func decryptThenCopyPassword(from indexPath: IndexPath) { private func decryptThenCopyPassword(from indexPath: IndexPath) {
guard self.passwordStore.pgpAgent?.isImported ?? false else { guard self.passwordStore.pgpAgent.isImported else {
Utils.alert(title: "CannotCopyPassword".localize(), message: "SetPgpKey.".localize(), controller: self, completion: nil) Utils.alert(title: "CannotCopyPassword".localize(), message: "SetPgpKey.".localize(), controller: self, completion: nil)
return return
} }
@ -412,7 +412,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
} catch { } catch {
DispatchQueue.main.async { DispatchQueue.main.async {
// remove the wrong passphrase so that users could enter it next time // remove the wrong passphrase so that users could enter it next time
self.passwordStore.pgpAgent?.passphrase = nil self.passwordStore.pgpAgent.passphrase = nil
Utils.alert(title: "CannotCopyPassword".localize(), message: error.localizedDescription, controller: self, completion: nil) Utils.alert(title: "CannotCopyPassword".localize(), message: error.localizedDescription, controller: self, completion: nil)
} }
} }
@ -453,7 +453,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "showPasswordDetail" { if identifier == "showPasswordDetail" {
guard self.passwordStore.pgpAgent?.isImported ?? false else { guard self.passwordStore.pgpAgent.isImported else {
Utils.alert(title: "CannotShowPassword".localize(), message: "SetPgpKey.".localize(), controller: self, completion: nil) Utils.alert(title: "CannotShowPassword".localize(), message: "SetPgpKey.".localize(), controller: self, completion: nil)
if let s = sender as? UITableViewCell { if let s = sender as? UITableViewCell {
let selectedIndexPath = tableView.indexPath(for: s)! let selectedIndexPath = tableView.indexPath(for: s)!
@ -462,7 +462,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
return false return false
} }
} else if identifier == "addPasswordSegue" { } else if identifier == "addPasswordSegue" {
guard self.passwordStore.pgpAgent?.isImported ?? false && self.passwordStore.storeRepository != nil else { guard self.passwordStore.pgpAgent.isImported && self.passwordStore.storeRepository != nil else {
Utils.alert(title: "CannotAddPassword".localize(), message: "MakeSurePgpAndGitProperlySet.".localize(), controller: self, completion: nil) Utils.alert(title: "CannotAddPassword".localize(), message: "MakeSurePgpAndGitProperlySet.".localize(), controller: self, completion: nil)
return false return false
} }

View file

@ -29,7 +29,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
SharedDefaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!.trimmed) SharedDefaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!.trimmed)
SharedDefaults[.pgpPublicKeyURL] = URL(string: controller.pgpPublicKeyURLTextField.text!.trimmed) SharedDefaults[.pgpPublicKeyURL] = URL(string: controller.pgpPublicKeyURLTextField.text!.trimmed)
if SharedDefaults[.isRememberPGPPassphraseOn] { if SharedDefaults[.isRememberPGPPassphraseOn] {
self.passwordStore.pgpAgent?.passphrase = controller.pgpPassphrase self.passwordStore.pgpAgent.passphrase = controller.pgpPassphrase
} }
SharedDefaults[.pgpKeySource] = "url" SharedDefaults[.pgpKeySource] = "url"
@ -38,10 +38,10 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize()) SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
do { do {
try self.passwordStore.pgpAgent?.initPGPKey(from: SharedDefaults[.pgpPublicKeyURL]!, keyType: .PUBLIC) try self.passwordStore.pgpAgent.initPGPKey(from: SharedDefaults[.pgpPublicKeyURL]!, keyType: .PUBLIC)
try self.passwordStore.pgpAgent?.initPGPKey(from: SharedDefaults[.pgpPrivateKeyURL]!, keyType: .PRIVATE) try self.passwordStore.pgpAgent.initPGPKey(from: SharedDefaults[.pgpPrivateKeyURL]!, keyType: .PRIVATE)
DispatchQueue.main.async { DispatchQueue.main.async {
self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpAgent?.pgpKeyID self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpAgent.pgpKeyID
SVProgressHUD.showSuccess(withStatus: "Success".localize()) SVProgressHUD.showSuccess(withStatus: "Success".localize())
SVProgressHUD.dismiss(withDelay: 1) SVProgressHUD.dismiss(withDelay: 1)
Utils.alert(title: "RememberToRemoveKey".localize(), message: "RememberToRemoveKeyFromServer.".localize(), controller: self, completion: nil) Utils.alert(title: "RememberToRemoveKey".localize(), message: "RememberToRemoveKeyFromServer.".localize(), controller: self, completion: nil)
@ -57,17 +57,17 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
} else if let controller = segue.source as? PGPKeyArmorSettingTableViewController { } else if let controller = segue.source as? PGPKeyArmorSettingTableViewController {
SharedDefaults[.pgpKeySource] = "armor" SharedDefaults[.pgpKeySource] = "armor"
if SharedDefaults[.isRememberPGPPassphraseOn] { if SharedDefaults[.isRememberPGPPassphraseOn] {
self.passwordStore.pgpAgent?.passphrase = controller.pgpPassphrase self.passwordStore.pgpAgent.passphrase = controller.pgpPassphrase
} }
SVProgressHUD.setDefaultMaskType(.black) SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light) SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize()) SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
do { do {
try self.passwordStore.pgpAgent?.initPGPKey(with: controller.armorPublicKeyTextView.text ?? "", keyType: .PUBLIC) try self.passwordStore.pgpAgent.initPGPKey(with: controller.armorPublicKeyTextView.text ?? "", keyType: .PUBLIC)
try self.passwordStore.pgpAgent?.initPGPKey(with: controller.armorPrivateKeyTextView.text ?? "", keyType: .PRIVATE) try self.passwordStore.pgpAgent.initPGPKey(with: controller.armorPrivateKeyTextView.text ?? "", keyType: .PRIVATE)
DispatchQueue.main.async { DispatchQueue.main.async {
self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpAgent?.pgpKeyID self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpAgent.pgpKeyID
SVProgressHUD.showSuccess(withStatus: "Success".localize()) SVProgressHUD.showSuccess(withStatus: "Success".localize())
SVProgressHUD.dismiss(withDelay: 1) SVProgressHUD.dismiss(withDelay: 1)
} }
@ -89,9 +89,9 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
SVProgressHUD.show(withStatus: "FetchingPgpKey".localize()) SVProgressHUD.show(withStatus: "FetchingPgpKey".localize())
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
do { do {
try self.passwordStore.pgpAgent?.initPGPKeyFromFileSharing() try self.passwordStore.pgpAgent.initPGPKeyFromFileSharing()
DispatchQueue.main.async { DispatchQueue.main.async {
self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpAgent?.pgpKeyID self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpAgent.pgpKeyID
SVProgressHUD.showSuccess(withStatus: "Imported".localize()) SVProgressHUD.showSuccess(withStatus: "Imported".localize())
SVProgressHUD.dismiss(withDelay: 1) SVProgressHUD.dismiss(withDelay: 1)
} }
@ -135,7 +135,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
} }
private func setPGPKeyTableViewCellDetailText() { private func setPGPKeyTableViewCellDetailText() {
if let pgpKeyID = self.passwordStore.pgpAgent?.pgpKeyID { if let pgpKeyID = self.passwordStore.pgpAgent.pgpKeyID {
pgpKeyTableViewCell.detailTextLabel?.text = pgpKeyID pgpKeyTableViewCell.detailTextLabel?.text = pgpKeyID
} else { } else {
pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize() pgpKeyTableViewCell.detailTextLabel?.text = "NotSet".localize()
@ -192,14 +192,14 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
optionMenu.addAction(urlAction) optionMenu.addAction(urlAction)
optionMenu.addAction(armorAction) optionMenu.addAction(armorAction)
if passwordStore.pgpAgent?.isFileSharingReady ?? false { if passwordStore.pgpAgent.isFileSharingReady {
fileActionTitle.append(" (\("Import".localize()))") fileActionTitle.append(" (\("Import".localize()))")
let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in let fileAction = UIAlertAction(title: fileActionTitle, style: .default) { _ in
// passphrase related // passphrase related
let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertController.Style.alert) let savePassphraseAlert = UIAlertController(title: "Passphrase".localize(), message: "WantToSavePassphrase?".localize(), preferredStyle: UIAlertController.Style.alert)
// no // no
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
self.passwordStore.pgpAgent?.passphrase = nil self.passwordStore.pgpAgent.passphrase = nil
SharedDefaults[.isRememberPGPPassphraseOn] = false SharedDefaults[.isRememberPGPPassphraseOn] = false
self.saveImportedPGPKey() self.saveImportedPGPKey()
}) })
@ -208,7 +208,7 @@ class SettingsTableViewController: UITableViewController, UITabBarControllerDele
// ask for the passphrase // ask for the passphrase
let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert) let alert = UIAlertController(title: "Passphrase".localize(), message: "FillInPgpPassphrase.".localize(), preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: {_ in
self.passwordStore.pgpAgent?.passphrase = alert.textFields?.first?.text self.passwordStore.pgpAgent.passphrase = alert.textFields?.first?.text
SharedDefaults[.isRememberPGPPassphraseOn] = true SharedDefaults[.isRememberPGPPassphraseOn] = true
self.saveImportedPGPKey() self.saveImportedPGPKey()
})) }))

View file

@ -145,7 +145,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController, UITa
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let entry = getPasswordEntry(by: indexPath) let entry = getPasswordEntry(by: indexPath)
guard self.passwordStore.pgpAgent?.isImported ?? false else { guard self.passwordStore.pgpAgent.isImported else {
Utils.alert(title: "CannotCopyPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self, completion: nil) Utils.alert(title: "CannotCopyPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self, completion: nil)
return return
} }
@ -165,7 +165,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController, UITa
} catch { } catch {
DispatchQueue.main.async { DispatchQueue.main.async {
// remove the wrong passphrase so that users could enter it next time // remove the wrong passphrase so that users could enter it next time
self.passwordStore.pgpAgent?.passphrase = nil self.passwordStore.pgpAgent.passphrase = nil
Utils.alert(title: "CannotCopyPassword".localize(), message: error.localizedDescription, controller: self, completion: nil) Utils.alert(title: "CannotCopyPassword".localize(), message: error.localizedDescription, controller: self, completion: nil)
} }
} }
@ -200,7 +200,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController, UITa
} }
let _ = sem.wait(timeout: DispatchTime.distantFuture) let _ = sem.wait(timeout: DispatchTime.distantFuture)
if SharedDefaults[.isRememberPGPPassphraseOn] { if SharedDefaults[.isRememberPGPPassphraseOn] {
self.passwordStore.pgpAgent?.passphrase = passphrase self.passwordStore.pgpAgent.passphrase = passphrase
} }
return passphrase return passphrase
} }

View file

@ -153,7 +153,7 @@ class ExtensionViewController: UIViewController, UITableViewDataSource, UITableV
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let entry = getPasswordEntry(by: indexPath) let entry = getPasswordEntry(by: indexPath)
guard self.passwordStore.pgpAgent?.isImported ?? false else { guard self.passwordStore.pgpAgent.isImported else {
Utils.alert(title: "CannotCopyPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self, completion: nil) Utils.alert(title: "CannotCopyPassword".localize(), message: "PgpKeyNotSet.".localize(), controller: self, completion: nil)
return return
} }
@ -191,7 +191,7 @@ class ExtensionViewController: UIViewController, UITableViewDataSource, UITableV
} catch { } catch {
DispatchQueue.main.async { DispatchQueue.main.async {
// remove the wrong passphrase so that users could enter it next time // remove the wrong passphrase so that users could enter it next time
self.passwordStore.pgpAgent?.passphrase = nil self.passwordStore.pgpAgent.passphrase = nil
Utils.alert(title: "CannotCopyPassword".localize(), message: error.localizedDescription, controller: self, completion: nil) Utils.alert(title: "CannotCopyPassword".localize(), message: error.localizedDescription, controller: self, completion: nil)
} }
} }
@ -227,7 +227,7 @@ class ExtensionViewController: UIViewController, UITableViewDataSource, UITableV
} }
let _ = sem.wait(timeout: DispatchTime.distantFuture) let _ = sem.wait(timeout: DispatchTime.distantFuture)
if SharedDefaults[.isRememberPGPPassphraseOn] { if SharedDefaults[.isRememberPGPPassphraseOn] {
self.passwordStore.pgpAgent?.passphrase = passphrase self.passwordStore.pgpAgent.passphrase = passphrase
} }
return passphrase return passphrase
} }

View file

@ -25,7 +25,7 @@ public class PasswordStore {
public let storeURL = URL(fileURLWithPath: "\(Globals.repositoryPath)") public let storeURL = URL(fileURLWithPath: "\(Globals.repositoryPath)")
public let tempStoreURL = URL(fileURLWithPath: "\(Globals.repositoryPath)-temp") public let tempStoreURL = URL(fileURLWithPath: "\(Globals.repositoryPath)-temp")
public let pgpAgent: PGPAgent? public let pgpAgent = PGPAgent()
public var storeRepository: GTRepository? public var storeRepository: GTRepository?
@ -104,8 +104,6 @@ public class PasswordStore {
} }
private init() { private init() {
self.pgpAgent = PGPAgent()
// Migration // Migration
importExistingKeysIntoKeychain() importExistingKeysIntoKeychain()
@ -113,7 +111,7 @@ public class PasswordStore {
if fm.fileExists(atPath: storeURL.path) { if fm.fileExists(atPath: storeURL.path) {
try storeRepository = GTRepository.init(url: storeURL) try storeRepository = GTRepository.init(url: storeURL)
} }
try self.pgpAgent?.initPGPKeys() try self.pgpAgent.initPGPKeys()
} catch { } catch {
print(error) print(error)
} }
@ -640,7 +638,7 @@ public class PasswordStore {
try? fm.removeItem(atPath: Globals.gitSSHPrivateKeyPath) try? fm.removeItem(atPath: Globals.gitSSHPrivateKeyPath)
self.pgpAgent?.removePGPKeys() self.pgpAgent.removePGPKeys()
AppKeychain.removeAllContent() AppKeychain.removeAllContent()
@ -701,7 +699,7 @@ public class PasswordStore {
public func decrypt(passwordEntity: PasswordEntity, requestPGPKeyPassphrase: () -> String) throws -> Password? { public func decrypt(passwordEntity: PasswordEntity, requestPGPKeyPassphrase: () -> String) throws -> Password? {
let encryptedDataPath = storeURL.appendingPathComponent(passwordEntity.getPath()) let encryptedDataPath = storeURL.appendingPathComponent(passwordEntity.getPath())
let encryptedData = try Data(contentsOf: encryptedDataPath) let encryptedData = try Data(contentsOf: encryptedDataPath)
guard let decryptedData = try self.pgpAgent?.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase) else { guard let decryptedData = try self.pgpAgent.decrypt(encryptedData: encryptedData, requestPGPKeyPassphrase: requestPGPKeyPassphrase) else {
throw AppError.Decryption throw AppError.Decryption
} }
let plainText = String(data: decryptedData, encoding: .utf8) ?? "" let plainText = String(data: decryptedData, encoding: .utf8) ?? ""
@ -710,15 +708,11 @@ public class PasswordStore {
} }
public func encrypt(password: Password) throws -> Data { public func encrypt(password: Password) throws -> Data {
let plainData = password.plainData return try self.pgpAgent.encrypt(plainData: password.plainData)
guard let encryptedData = try self.pgpAgent?.encrypt(plainData: plainData) else {
throw AppError.Encryption
}
return encryptedData
} }
public func removePGPKeys() { public func removePGPKeys() {
self.pgpAgent?.removePGPKeys() self.pgpAgent.removePGPKeys()
} }
public func removeGitSSHKeys() { public func removeGitSSHKeys() {