Fix #32: Decryption of message encrypted with multiple keys (#55)

When the message is encrypted with multiple keys and the decryption
key(s) added is not the first encrypted key, then it was failing due to
invalid early failure when uid was not found in decrypted keys. This
changes such behavior and just returns empty key instead in such case.
This commit is contained in:
Jakub Zelenka 2025-05-20 17:23:58 +01:00 committed by GitHub
parent 91e92a2690
commit 74993ff4a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 137 additions and 4 deletions

View file

@ -742,8 +742,10 @@ gpgme_error_t passphrase_decrypt_cb (
uid[idx] = '\0';
if (!PHPC_HASH_CSTR_FIND_PTR_IN_COND(
PHPC_THIS->decryptkeys, (char *)uid, passphrase)) {
GNUPG_ERR("no passphrase set");
return 1;
/* If the requested key is not in decryptkeys, ignore it and return success. It then tries
* to call callback for the next key if the message was encrypted with more than one key. */
write(fd, "\n", 1);
return 0;
}
if (!passphrase) {
GNUPG_ERR("no passphrase set");