diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2020-12-08 07:15:45 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2020-12-08 07:15:45 +0100 |
commit | eda3c688fc2e85c7cd63029cb9caf06552d203b4 (patch) | |
tree | 31b84f7634cf3de4d33d287f4cc7c58fd7f54901 /agent | |
parent | agent: Clean up the API of agent_pkdecrypt. (diff) | |
download | gnupg2-eda3c688fc2e85c7cd63029cb9caf06552d203b4.tar.xz gnupg2-eda3c688fc2e85c7cd63029cb9caf06552d203b4.zip |
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 <gniibe@fsij.org>
Diffstat (limited to 'agent')
-rw-r--r-- | agent/pkdecrypt.c | 7 |
1 files 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)) |