No need to select key for encryption if there only one imported key
This commit is contained in:
parent
fcc8961e46
commit
072f824158
1 changed files with 6 additions and 1 deletions
|
|
@ -86,8 +86,13 @@ public class PGPAgent {
|
|||
guard let pgpInterface = pgpInterface else {
|
||||
throw AppError.Encryption
|
||||
}
|
||||
var keyID = keyID
|
||||
if !pgpInterface.containsPublicKey(with: keyID) {
|
||||
throw AppError.PgpPublicKeyNotFound(keyID: keyID)
|
||||
if pgpInterface.keyID.count == 1 {
|
||||
keyID = pgpInterface.keyID.first!
|
||||
} else {
|
||||
throw AppError.PgpPublicKeyNotFound(keyID: keyID)
|
||||
}
|
||||
}
|
||||
return try pgpInterface.encrypt(plainData: plainData, keyID: keyID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue