From eda3c688fc2e85c7cd63029cb9caf06552d203b4 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 8 Dec 2020 15:15:45 +0900 Subject: [PATCH] agent: Allow decryption with card but no file. * agent/pkdecrypt.c (agent_pkdecrypt): Support decryption with card but without a stub key. -- GnuPG-bug-id: 5170 Signed-off-by: NIIBE Yutaka --- agent/pkdecrypt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/agent/pkdecrypt.c b/agent/pkdecrypt.c index 703e0b4f4..da370bb0a 100644 --- a/agent/pkdecrypt.c +++ b/agent/pkdecrypt.c @@ -41,6 +41,7 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text, gcry_sexp_t s_skey = NULL, s_cipher = NULL, s_plain = NULL; unsigned char *shadow_info = NULL; gpg_error_t err = 0; + int no_shadow_info = 0; char *buf = NULL; size_t len; @@ -69,14 +70,16 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text, err = agent_key_from_file (ctrl, NULL, desc_text, ctrl->keygrip, &shadow_info, CACHE_MODE_NORMAL, NULL, &s_skey, NULL); - if (err) + if (gpg_err_code (err) == GPG_ERR_NO_SECKEY) + no_shadow_info = 1; + else if (err) { if (gpg_err_code (err) != GPG_ERR_NO_SECKEY) log_error ("failed to read the secret key\n"); goto leave; } - if (shadow_info) + if (shadow_info || no_shadow_info) { /* divert operation to the smartcard */ if (!gcry_sexp_canon_len (ciphertext, ciphertextlen, NULL, NULL))