diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index 3e7f91d..7dc901e 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -126,6 +126,7 @@ public class PasswordStore { // File migration to group migrateIfNeeded() backwardCompatibility() + importExistingKeysIntoKeychain() do { if fm.fileExists(atPath: storeURL.path) { @@ -182,6 +183,15 @@ public class PasswordStore { SharedDefaults[.isRememberPGPPassphraseOn] = true } } + + 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