mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
agent: Simplify diverting operation to the smartcard.
* agent/pkdecrypt.c (agent_pkdecrypt): Remove no_shadow_info variable. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
ab703eacf7
commit
d1f8caafb4
@ -116,7 +116,6 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
|||||||
gcry_sexp_t s_skey = NULL, s_cipher = NULL, s_plain = NULL;
|
gcry_sexp_t s_skey = NULL, s_cipher = NULL, s_plain = NULL;
|
||||||
unsigned char *shadow_info = NULL;
|
unsigned char *shadow_info = NULL;
|
||||||
gpg_error_t err = 0;
|
gpg_error_t err = 0;
|
||||||
int no_shadow_info = 0;
|
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@ -145,17 +144,13 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
|||||||
err = agent_key_from_file (ctrl, NULL, desc_text,
|
err = agent_key_from_file (ctrl, NULL, desc_text,
|
||||||
NULL, &shadow_info,
|
NULL, &shadow_info,
|
||||||
CACHE_MODE_NORMAL, NULL, &s_skey, NULL, NULL);
|
CACHE_MODE_NORMAL, NULL, &s_skey, NULL, NULL);
|
||||||
if (gpg_err_code (err) == GPG_ERR_NO_SECKEY)
|
if (err && gpg_err_code (err) != GPG_ERR_NO_SECKEY)
|
||||||
no_shadow_info = 1;
|
|
||||||
else if (err)
|
|
||||||
{
|
{
|
||||||
log_error ("failed to read the secret key\n");
|
log_error ("failed to read the secret key\n");
|
||||||
goto leave;
|
|
||||||
}
|
}
|
||||||
|
else if (shadow_info
|
||||||
if (shadow_info || no_shadow_info)
|
|| err /* gpg_err_code (err) == GPG_ERR_NO_SECKEY */)
|
||||||
{ /* divert operation to the smartcard */
|
{ /* divert operation to the smartcard */
|
||||||
|
|
||||||
if (!gcry_sexp_canon_len (ciphertext, ciphertextlen, NULL, NULL))
|
if (!gcry_sexp_canon_len (ciphertext, ciphertextlen, NULL, NULL))
|
||||||
{
|
{
|
||||||
err = gpg_error (GPG_ERR_INV_SEXP);
|
err = gpg_error (GPG_ERR_INV_SEXP);
|
||||||
@ -170,12 +165,12 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
|||||||
&buf, &len, r_padding);
|
&buf, &len, r_padding);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
/* We restore the original error (ie. no seckey) is no card
|
/* We restore the original error (ie. no seckey) as no card
|
||||||
* has been found and we have no shadow key. This avoids a
|
* has been found and we have no shadow key. This avoids a
|
||||||
* surprising "card removed" error code. */
|
* surprising "card removed" error code. */
|
||||||
if ((gpg_err_code (err) == GPG_ERR_CARD_REMOVED
|
if ((gpg_err_code (err) == GPG_ERR_CARD_REMOVED
|
||||||
|| gpg_err_code (err) == GPG_ERR_CARD_NOT_PRESENT)
|
|| gpg_err_code (err) == GPG_ERR_CARD_NOT_PRESENT)
|
||||||
&& no_shadow_info)
|
&& !shadow_info)
|
||||||
err = gpg_error (GPG_ERR_NO_SECKEY);
|
err = gpg_error (GPG_ERR_NO_SECKEY);
|
||||||
else
|
else
|
||||||
log_error ("smartcard decryption failed: %s\n", gpg_strerror (err));
|
log_error ("smartcard decryption failed: %s\n", gpg_strerror (err));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user