aboutsummaryrefslogtreecommitdiffstats
path: root/g10/pubkey-enc.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-07-10 01:00:00 +0000
committerNIIBE Yutaka <[email protected]>2020-07-10 01:00:00 +0000
commit31ae0718ba10c3b1b670ba6131b4995de24aa7a1 (patch)
treef0ad6b292000672126b5e5fdaa6574ecf0b69b44 /g10/pubkey-enc.c
parentdoc: Add news entries from the latest 2.2 releases. (diff)
downloadgnupg-31ae0718ba10c3b1b670ba6131b4995de24aa7a1.tar.gz
gnupg-31ae0718ba10c3b1b670ba6131b4995de24aa7a1.zip
gpg: For decryption, support use of a key with no 'encrypt' usage.
* g10/pubkey-enc.c (get_session_key): Don't skip at no PUBKEY_USAGE_ENC. Emit information the key has no 'encrypt' usage. -- GnuPG-bug-id: 4246 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/pubkey-enc.c')
-rw-r--r--g10/pubkey-enc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c
index 14cbdbb0f..070d71d6a 100644
--- a/g10/pubkey-enc.c
+++ b/g10/pubkey-enc.c
@@ -91,9 +91,6 @@ get_session_key (ctrl_t ctrl, struct pubkey_enc_list *list, DEK *dek)
if (err)
break;
- if (!(sk->pubkey_usage & PUBKEY_USAGE_ENC))
- continue;
-
/* Check compliance. */
if (! gnupg_pk_is_allowed (opt.compliance, PK_USE_DECRYPTION,
sk->pubkey_algo, 0,
@@ -144,7 +141,10 @@ get_session_key (ctrl_t ctrl, struct pubkey_enc_list *list, DEK *dek)
}
else if (opt.try_all_secrets
|| (k->keyid[0] == keyid[0] && k->keyid[1] == keyid[1]))
- ;
+ {
+ if (!opt.quiet && !(sk->pubkey_usage & PUBKEY_USAGE_ENC))
+ log_info (_("using the key with no 'encrypt' usage.\n"));
+ }
else
continue;
@@ -153,7 +153,11 @@ get_session_key (ctrl_t ctrl, struct pubkey_enc_list *list, DEK *dek)
if (!err)
{
if (!opt.quiet && !k->keyid[0] && !k->keyid[1])
- log_info (_("okay, we are the anonymous recipient.\n"));
+ {
+ log_info (_("okay, we are the anonymous recipient.\n"));
+ if (!(sk->pubkey_usage & PUBKEY_USAGE_ENC))
+ log_info (_("using the key with no 'encrypt' usage.\n"));
+ }
search_for_secret_keys = 0;
break;
}