PGPAgent can encrypt with multiple keys

This commit is contained in:
Lysann Tranvouez 2026-03-11 00:48:21 +01:00
parent b7873e6d72
commit 09b0b150ce
3 changed files with 41 additions and 5 deletions

View file

@ -138,8 +138,11 @@ struct GopenPGPInterface: PGPInterface {
}
func encrypt(plainData: Data, keyIDs: [String]) throws -> Data {
let keys: [CryptoKey] = keyIDs.compactMap { keyID in
publicKeys.first(where: { key, _ in key.hasSuffix(keyID.lowercased()) })?.value
let keys: [CryptoKey] = try keyIDs.map { keyID in
guard let key = publicKeys.first(where: { key, _ in key.hasSuffix(keyID.lowercased()) })?.value else {
throw AppError.pgpPublicKeyNotFound(keyID: keyID)
}
return key
}
guard let firstKey = keys.first else {
throw AppError.encryption