replace calls to deprecated function
changes PasswordStore.encrypt behavior when .gpg-id support is off
(default):
old:
* ignores passed in keyID
* encrypt with first public key in keychain (gopenPGP), or entire
keychain (ObjectivePGP)
new:
* honor passed in keyID
* encrypt with all keys in keychain
This commit is contained in:
parent
09b0b150ce
commit
e69e590e36
7 changed files with 11 additions and 110 deletions
|
|
@ -123,15 +123,6 @@ struct GopenPGPInterface: PGPInterface {
|
|||
}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "Use encrypt(plainData:keyIDs:) instead.")
|
||||
func encrypt(plainData: Data, keyID: String?) throws -> Data {
|
||||
guard let keyID = keyID ?? publicKeys.keys.first else {
|
||||
// this is invalid, but we want the new function to throw the error for us
|
||||
return try encrypt(plainData: plainData, keyIDs: [])
|
||||
}
|
||||
return try encrypt(plainData: plainData, keyIDs: [keyID])
|
||||
}
|
||||
|
||||
func encryptWithAllKeys(plainData: Data) throws -> Data {
|
||||
let keyIDs = publicKeys.keys.filter { key in privateKeys.keys.contains(key) }
|
||||
return try encrypt(plainData: plainData, keyIDs: keyIDs)
|
||||
|
|
|
|||
|
|
@ -33,12 +33,6 @@ struct ObjectivePGPInterface: PGPInterface {
|
|||
}
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "Use encrypt(plainData:keyIDs:) instead.")
|
||||
func encrypt(plainData: Data, keyID _: String?) throws -> Data {
|
||||
// Backwards compatibility: ignore keyID parameter and encrypted with all keys in the keyring
|
||||
try encryptWithAllKeys(plainData: plainData)
|
||||
}
|
||||
|
||||
func encryptWithAllKeys(plainData: Data) throws -> Data {
|
||||
try encrypt(plainData: plainData, keyIDs: keyID)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,23 +89,6 @@ public class PGPAgent {
|
|||
return result
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "Use encrypt(plainData:keyIDs:) instead.")
|
||||
public func encrypt(plainData: Data, keyID: String) throws -> Data {
|
||||
try checkAndInit()
|
||||
guard let pgpInterface else {
|
||||
throw AppError.encryption
|
||||
}
|
||||
var keyID = keyID
|
||||
if !pgpInterface.containsPublicKey(with: keyID) {
|
||||
if pgpInterface.keyID.count == 1 {
|
||||
keyID = pgpInterface.keyID.first!
|
||||
} else {
|
||||
throw AppError.pgpPublicKeyNotFound(keyID: keyID)
|
||||
}
|
||||
}
|
||||
return try pgpInterface.encrypt(plainData: plainData, keyIDs: [keyID])
|
||||
}
|
||||
|
||||
public func encrypt(plainData: Data, keyIDs: [String]) throws -> Data {
|
||||
try checkAndInit()
|
||||
guard let pgpInterface else {
|
||||
|
|
@ -114,15 +97,6 @@ public class PGPAgent {
|
|||
return try pgpInterface.encrypt(plainData: plainData, keyIDs: keyIDs)
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "Use encrypt(plainData:keyIDs:) or encryptWithAllKeys(plainData:) instead.")
|
||||
public func encrypt(plainData: Data) throws -> Data {
|
||||
try checkAndInit()
|
||||
guard let pgpInterface else {
|
||||
throw AppError.encryption
|
||||
}
|
||||
return try pgpInterface.encrypt(plainData: plainData, keyID: nil)
|
||||
}
|
||||
|
||||
public func encryptWithAllKeys(plainData: Data) throws -> Data {
|
||||
try checkAndInit()
|
||||
guard let pgpInterface else {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
protocol PGPInterface {
|
||||
func decrypt(encryptedData: Data, keyIDHint: String?, passPhraseForKey: @escaping (String) -> String) throws -> Data?
|
||||
|
||||
@available(*, deprecated, message: "Use encrypt(plainData:keyIDs:) instead.")
|
||||
func encrypt(plainData: Data, keyID: String?) throws -> Data
|
||||
// encrypt with all public keys for which we also have a private key
|
||||
func encryptWithAllKeys(plainData: Data) throws -> Data
|
||||
func encrypt(plainData: Data, keyIDs: [String]) throws -> Data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue