1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Fix readkey --info in case a readkey command is available.

* scd/command.c (do_readkey): Make --info also work if a readkey
command is available.

* scd/app-p15.c (cdf_object_from_certid): Fix a but introduced with
the previous commit.
This commit is contained in:
Werner Koch 2021-02-22 18:28:45 +01:00
parent 488eaedc9a
commit 2490f4e8e1
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 39 additions and 45 deletions

View File

@ -768,8 +768,8 @@ cdf_object_from_certid (app_t app, const char *certid, cdf_object_t *r_cdf)
err = cdf_object_from_objid (app, objidlen, objid, &cdf);
xfree (objid);
if (!cdf)
return gpg_error (GPG_ERR_NOT_FOUND);
if (err)
return err;
*r_cdf = cdf;
return 0;
}

View File

@ -620,33 +620,30 @@ do_readkey (card_t card, ctrl_t ctrl, const char *line,
opt_info? APP_READKEY_FLAG_INFO : 0,
opt_nokey? NULL : pk_p, pklen_p);
if (!rc)
/* Okay, got that key. */
return 0;
if (gpg_err_code (rc) == GPG_ERR_UNSUPPORTED_OPERATION
; /* Got the key. */
else if (gpg_err_code (rc) == GPG_ERR_UNSUPPORTED_OPERATION
|| gpg_err_code (rc) == GPG_ERR_NOT_FOUND)
{
/* Fall back to certificate reading. */
unsigned char *cert = NULL;
size_t ncert;
/* Fall back to certificate reading. */
rc = app_readcert (card, ctrl, line, &cert, &ncert);
if (rc)
{
log_error ("app_readcert failed: %s\n", gpg_strerror (rc));
return rc;
}
else
{
rc = app_help_pubkey_from_cert (cert, ncert, pk_p, pklen_p);
xfree (cert);
if (rc)
{
log_error ("failed to parse the certificate: %s\n",
gpg_strerror (rc));
return rc;
}
}
else
log_error ("app_readkey failed: %s\n", gpg_strerror (rc));
if (opt_info)
if (!rc && opt_info)
{
char keygripstr[KEYGRIP_LEN*2+1];
char *algostr;
@ -672,9 +669,6 @@ do_readkey (card_t card, ctrl_t ctrl, const char *line,
NULL, (size_t)0);
xfree (algostr);
}
}
else
log_error ("app_readkey failed: %s\n", gpg_strerror (rc));
return rc;
}