Polish logics about PGP passphrase

- Ask passphrase only when users want to save them for later usage
- Provide a second change to enter passphrase during the decryption
This commit is contained in:
Yishi Lin 2017-06-07 21:11:01 +08:00
parent 0542733f86
commit 2388edccfb
5 changed files with 104 additions and 105 deletions

View file

@ -93,10 +93,10 @@ class PasswordStore {
if FileManager.default.fileExists(atPath: storeURL.path) {
try storeRepository = GTRepository.init(url: storeURL)
}
try initPGPKeys()
} catch {
print(error)
}
initPGPKeys()
}
enum SSHKeyType {
@ -111,13 +111,9 @@ class PasswordStore {
try armorKey.write(toFile: keyPath, atomically: true, encoding: .ascii)
}
public func initPGPKeys() {
do {
try initPGPKey(.public)
try initPGPKey(.secret)
} catch {
print(error)
}
public func initPGPKeys() throws {
try initPGPKey(.public)
try initPGPKey(.secret)
}
public func initPGPKey(_ keyType: PGPKeyType) throws {
@ -139,7 +135,7 @@ class PasswordStore {
}
}
public func initPGPKey(from url: URL, keyType: PGPKeyType) throws{
public func initPGPKey(from url: URL, keyType: PGPKeyType) throws {
var pgpKeyLocalPath = ""
if keyType == .public {
pgpKeyLocalPath = Globals.pgpPublicKeyPath