diff --git a/pass/Base.lproj/Main.storyboard b/pass/Base.lproj/Main.storyboard index f1a72b5..3ade99c 100644 --- a/pass/Base.lproj/Main.storyboard +++ b/pass/Base.lproj/Main.storyboard @@ -84,11 +84,11 @@ - + - + @@ -104,11 +104,11 @@ - + - + @@ -124,18 +124,18 @@ - + - + - + @@ -152,18 +152,18 @@ - + - + - + @@ -180,7 +180,7 @@ - + @@ -197,11 +197,11 @@ - + - + @@ -221,11 +221,11 @@ - + - + @@ -367,18 +367,18 @@ - + - + - + @@ -443,7 +443,7 @@ - + @@ -463,7 +463,7 @@ - + @@ -564,36 +564,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -610,14 +580,14 @@ - + - + @@ -1006,7 +976,7 @@ - + @@ -1137,17 +1107,75 @@ - + - - + + - + - - + + + + + + GnuPG supports a command-line option --armor that that causes output to be generated in an ASCII-armored format similar to uuencoded documents rather than binary format. + + + + + + + + + + $ gpg --export -a KEY_ID + $ gpg --export-secret-keys -a KEY_ID + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -----BEGIN PGP PUBLIC KEY BLOCK----- @@ -1184,10 +1212,10 @@ pfZ36xQbOAQYKKf6ZTT5R/Y= - - - - + + + + @@ -1196,10 +1224,10 @@ pfZ36xQbOAQYKKf6ZTT5R/Y= - + - + @@ -1249,32 +1277,6 @@ pfZ36xQbOAQYKKf6ZTT5R/Y= - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1289,14 +1291,14 @@ pfZ36xQbOAQYKKf6ZTT5R/Y= - + - - + + diff --git a/pass/Controllers/PGPKeyArmorSettingTableViewController.swift b/pass/Controllers/PGPKeyArmorSettingTableViewController.swift index b10cb21..d0637de 100644 --- a/pass/Controllers/PGPKeyArmorSettingTableViewController.swift +++ b/pass/Controllers/PGPKeyArmorSettingTableViewController.swift @@ -11,14 +11,27 @@ import SwiftyUserDefaults class PGPKeyArmorSettingTableViewController: UITableViewController { @IBOutlet weak var armorPublicKeyTextView: UITextView! - @IBOutlet weak var passphraseTextField: UITextField! @IBOutlet weak var armorPrivateKeyTextView: UITextView! + var pgpPassphrase: String? override func viewDidLoad() { super.viewDidLoad() armorPublicKeyTextView.text = Defaults[.pgpPublicKeyArmor] armorPrivateKeyTextView.text = Defaults[.pgpPrivateKeyArmor] - passphraseTextField.text = Defaults[.pgpKeyPassphrase] + pgpPassphrase = Defaults[.pgpKeyPassphrase] + } + + @IBAction func save(_ sender: Any) { + let alert = UIAlertController(title: "Phassphrase", message: "Please fill in the passphrase of your PGP secret key.", preferredStyle: UIAlertControllerStyle.alert) + alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {_ in + self.pgpPassphrase = alert.textFields?.first?.text + self.performSegue(withIdentifier: "savePGPKeySegue", sender: self) + })) + alert.addTextField(configurationHandler: {(textField: UITextField!) in + textField.text = self.pgpPassphrase + textField.isSecureTextEntry = true + }) + self.present(alert, animated: true, completion: nil) } } diff --git a/pass/Controllers/PGPKeySettingTableViewController.swift b/pass/Controllers/PGPKeySettingTableViewController.swift index af8e76c..b8b7c72 100644 --- a/pass/Controllers/PGPKeySettingTableViewController.swift +++ b/pass/Controllers/PGPKeySettingTableViewController.swift @@ -13,13 +13,13 @@ class PGPKeySettingTableViewController: UITableViewController { @IBOutlet weak var pgpPublicKeyURLTextField: UITextField! @IBOutlet weak var pgpPrivateKeyURLTextField: UITextField! - @IBOutlet weak var pgpKeyPassphraseTextField: UITextField! + var pgpPassphrase: String? override func viewDidLoad() { super.viewDidLoad() pgpPublicKeyURLTextField.text = Defaults[.pgpPublicKeyURL]?.absoluteString pgpPrivateKeyURLTextField.text = Defaults[.pgpPrivateKeyURL]?.absoluteString - pgpKeyPassphraseTextField.text = Defaults[.pgpKeyPassphrase] + pgpPassphrase = Defaults[.pgpKeyPassphrase] } override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { @@ -48,4 +48,17 @@ class PGPKeySettingTableViewController: UITableViewController { } return true } + + @IBAction func save(_ sender: Any) { + let alert = UIAlertController(title: "Phassphrase", message: "Please fill in the passphrase of your PGP secret key.", preferredStyle: UIAlertControllerStyle.alert) + alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {_ in + self.pgpPassphrase = alert.textFields?.first?.text + self.performSegue(withIdentifier: "savePGPKeySegue", sender: self) + })) + alert.addTextField(configurationHandler: {(textField: UITextField!) in + textField.text = self.pgpPassphrase + textField.isSecureTextEntry = true + }) + self.present(alert, animated: true, completion: nil) + } } diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index cd5837f..3efc0f7 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -25,46 +25,39 @@ class SettingsTableViewController: UITableViewController { @IBAction func savePGPKey(segue: UIStoryboardSegue) { if let controller = segue.source as? PGPKeySettingTableViewController { - -// if Defaults[.pgpKeyID] == nil || -// Defaults[.pgpPrivateKeyURL] != URL(string: controller.pgpPrivateKeyURLTextField.text!) || -// Defaults[.pgpPublicKeyURL] != URL(string: controller.pgpPublicKeyURLTextField.text!) || -// Defaults[.pgpKeyPassphrase] != controller.pgpKeyPassphraseTextField.text! { + Defaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!) + Defaults[.pgpPublicKeyURL] = URL(string: controller.pgpPublicKeyURLTextField.text!) + Defaults[.pgpKeyPassphrase] = controller.pgpPassphrase + Defaults[.pgpKeySource] = "url" - Defaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!) - Defaults[.pgpPublicKeyURL] = URL(string: controller.pgpPublicKeyURLTextField.text!) - Defaults[.pgpKeyPassphrase] = controller.pgpKeyPassphraseTextField.text! - Defaults[.pgpKeySource] = "url" - - SVProgressHUD.setDefaultMaskType(.black) - SVProgressHUD.setDefaultStyle(.light) - SVProgressHUD.show(withStatus: "Fetching PGP Key") - DispatchQueue.global(qos: .userInitiated).async { [unowned self] in - do { - try PasswordStore.shared.initPGP(pgpPublicKeyURL: Defaults[.pgpPublicKeyURL]!, - pgpPublicKeyLocalPath: Globals.pgpPublicKeyPath, - pgpPrivateKeyURL: Defaults[.pgpPrivateKeyURL]!, - pgpPrivateKeyLocalPath: Globals.pgpPrivateKeyPath) - DispatchQueue.main.async { - self.pgpKeyTableViewCell.detailTextLabel?.text = Defaults[.pgpKeyID] - SVProgressHUD.showSuccess(withStatus: "Success.") - SVProgressHUD.dismiss(withDelay: 1) - Utils.alert(title: "Remove the Key", message: "Remember to remove the key from the server.", controller: self, completion: nil) - } - } catch { - DispatchQueue.main.async { - self.pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" - Defaults[.pgpKeyID] = nil - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) - } + SVProgressHUD.setDefaultMaskType(.black) + SVProgressHUD.setDefaultStyle(.light) + SVProgressHUD.show(withStatus: "Fetching PGP Key") + DispatchQueue.global(qos: .userInitiated).async { [unowned self] in + do { + try PasswordStore.shared.initPGP(pgpPublicKeyURL: Defaults[.pgpPublicKeyURL]!, + pgpPublicKeyLocalPath: Globals.pgpPublicKeyPath, + pgpPrivateKeyURL: Defaults[.pgpPrivateKeyURL]!, + pgpPrivateKeyLocalPath: Globals.pgpPrivateKeyPath) + DispatchQueue.main.async { + self.pgpKeyTableViewCell.detailTextLabel?.text = Defaults[.pgpKeyID] + SVProgressHUD.showSuccess(withStatus: "Success.") + SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Rememver to Remove the Key", message: "Remember to remove the key from the server.", controller: self, completion: nil) + } + } catch { + DispatchQueue.main.async { + self.pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" + Defaults[.pgpKeyID] = nil + SVProgressHUD.showError(withStatus: error.localizedDescription) + SVProgressHUD.dismiss(withDelay: 1) } } -// } + } } else if let controller = segue.source as? PGPKeyArmorSettingTableViewController { Defaults[.pgpKeySource] = "armor" - Defaults[.pgpKeyPassphrase] = controller.passphraseTextField.text! + Defaults[.pgpKeyPassphrase] = controller.pgpPassphrase Defaults[.pgpPublicKeyArmor] = controller.armorPublicKeyTextView.text! Defaults[.pgpPrivateKeyArmor] = controller.armorPrivateKeyTextView.text!