Implement migration of existing PGP keys into Keychain

This commit is contained in:
Danny Moesch 2019-06-26 21:49:29 +02:00 committed by Mingshen Sun
parent a66a79abc6
commit e4e4c6daff

View file

@ -126,6 +126,7 @@ public class PasswordStore {
// File migration to group
migrateIfNeeded()
backwardCompatibility()
importExistingKeysIntoKeychain()
do {
if fm.fileExists(atPath: storeURL.path) {
@ -183,6 +184,15 @@ public class PasswordStore {
}
}
private func importExistingKeysIntoKeychain() {
if let publicKey = fm.contents(atPath: Globals.pgpPublicKeyPath) {
Utils.addDataToKeychain(key: PGPKeyType.PUBLIC.rawValue, data: publicKey)
}
if let privateKey = fm.contents(atPath: Globals.pgpPrivateKeyPath) {
Utils.addDataToKeychain(key: PGPKeyType.PRIVATE.rawValue, data: privateKey)
}
}
enum SSHKeyType {
case `public`, secret
}