PGPInterface can encrypt with multiple keys, PGPAgent can encrypt with all keys
This commit is contained in:
parent
39dab8c6c0
commit
a56193dc86
5 changed files with 87 additions and 11 deletions
|
|
@ -97,7 +97,7 @@ public class PGPAgent {
|
|||
throw AppError.pgpPublicKeyNotFound(keyID: keyID)
|
||||
}
|
||||
}
|
||||
return try pgpInterface.encrypt(plainData: plainData, keyID: keyID)
|
||||
return try pgpInterface.encrypt(plainData: plainData, keyIDs: [keyID])
|
||||
}
|
||||
|
||||
public func decrypt(encryptedData: Data, requestPGPKeyPassphrase: @escaping (String) -> String) throws -> Data? {
|
||||
|
|
@ -122,6 +122,7 @@ public class PGPAgent {
|
|||
return result
|
||||
}
|
||||
|
||||
@available(*, deprecated, message: "Use encrypt(plainData:keyID:) or encryptWithAllKeys(plainData:) instead.")
|
||||
public func encrypt(plainData: Data) throws -> Data {
|
||||
try checkAndInit()
|
||||
guard let pgpInterface else {
|
||||
|
|
@ -130,6 +131,14 @@ public class PGPAgent {
|
|||
return try pgpInterface.encrypt(plainData: plainData, keyID: nil)
|
||||
}
|
||||
|
||||
public func encryptWithAllKeys(plainData: Data) throws -> Data {
|
||||
try checkAndInit()
|
||||
guard let pgpInterface else {
|
||||
throw AppError.encryption
|
||||
}
|
||||
return try pgpInterface.encryptWithAllKeys(plainData: plainData)
|
||||
}
|
||||
|
||||
public var isPrepared: Bool {
|
||||
keyStore.contains(key: PGPKey.PUBLIC.getKeychainKey())
|
||||
&& keyStore.contains(key: PGPKey.PRIVATE.getKeychainKey())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue