mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
gpg: Prepare card code to allow other than OpenPGP cards.
* g10/call-agent.c (start_agent): Use card app auto selection. * g10/card-util.c (current_card_status): Print the Application type. (card_status): Put empty line between card listings. Signed-off-by: Werner Koch <wk@gnupg.org> (cherry picked from commit e47524c34a2a9f53c2507f67a0b41b460cee78b7)
This commit is contained in:
parent
768cb6402f
commit
fe5c8de862
@ -336,7 +336,7 @@ start_agent (ctrl_t ctrl, int flag_for_card)
|
|||||||
if (!(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
|
if (!(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
|
||||||
rc = warn_version_mismatch (agent_ctx, SCDAEMON_NAME, 2);
|
rc = warn_version_mismatch (agent_ctx, SCDAEMON_NAME, 2);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = assuan_transact (agent_ctx, "SCD SERIALNO openpgp",
|
rc = assuan_transact (agent_ctx, "SCD SERIALNO",
|
||||||
NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL,
|
||||||
learn_status_cb, &info);
|
learn_status_cb, &info);
|
||||||
if (rc && !(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
|
if (rc && !(flag_for_card & FLAG_FOR_CARD_SUPPRESS_ERRORS))
|
||||||
|
@ -416,36 +416,43 @@ current_card_status (ctrl_t ctrl, estream_t fp,
|
|||||||
if (!info.serialno || strncmp (info.serialno, "D27600012401", 12)
|
if (!info.serialno || strncmp (info.serialno, "D27600012401", 12)
|
||||||
|| strlen (info.serialno) != 32 )
|
|| strlen (info.serialno) != 32 )
|
||||||
{
|
{
|
||||||
|
const char *name1, *name2;
|
||||||
if (info.apptype && !strcmp (info.apptype, "NKS"))
|
if (info.apptype && !strcmp (info.apptype, "NKS"))
|
||||||
{
|
{
|
||||||
if (opt.with_colons)
|
name1 = "netkey";
|
||||||
es_fputs ("netkey-card:\n", fp);
|
name2 = "NetKey";
|
||||||
log_info ("this is a NetKey card\n");
|
|
||||||
}
|
}
|
||||||
else if (info.apptype && !strcmp (info.apptype, "DINSIG"))
|
else if (info.apptype && !strcmp (info.apptype, "DINSIG"))
|
||||||
{
|
{
|
||||||
if (opt.with_colons)
|
name1 = "dinsig";
|
||||||
es_fputs ("dinsig-card:\n", fp);
|
name2 = "DINSIG";
|
||||||
log_info ("this is a DINSIG compliant card\n");
|
|
||||||
}
|
}
|
||||||
else if (info.apptype && !strcmp (info.apptype, "P15"))
|
else if (info.apptype && !strcmp (info.apptype, "P15"))
|
||||||
{
|
{
|
||||||
if (opt.with_colons)
|
name1 = "pkcs15";
|
||||||
es_fputs ("pkcs15-card:\n", fp);
|
name2 = "PKCS#15";
|
||||||
log_info ("this is a PKCS#15 compliant card\n");
|
|
||||||
}
|
}
|
||||||
else if (info.apptype && !strcmp (info.apptype, "GELDKARTE"))
|
else if (info.apptype && !strcmp (info.apptype, "GELDKARTE"))
|
||||||
{
|
{
|
||||||
if (opt.with_colons)
|
name1 = "geldkarte";
|
||||||
es_fputs ("geldkarte-card:\n", fp);
|
name2 = "Geldkarte";
|
||||||
log_info ("this is a Geldkarte compliant card\n");
|
}
|
||||||
|
else if (info.apptype && !strcmp (info.apptype, "PIV"))
|
||||||
|
{
|
||||||
|
name1 = "piv";
|
||||||
|
name2 = "PIV";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (opt.with_colons)
|
name1 = "unknown";
|
||||||
es_fputs ("unknown:\n", fp);
|
name2 = "Unknown";
|
||||||
}
|
}
|
||||||
log_info ("not an OpenPGP card\n");
|
|
||||||
|
if (opt.with_colons)
|
||||||
|
es_fprintf (fp, "%s-card:\n", name1);
|
||||||
|
else
|
||||||
|
tty_fprintf (fp, "Application type .: %s\n", name2);
|
||||||
|
|
||||||
agent_release_card_info (&info);
|
agent_release_card_info (&info);
|
||||||
xfree (pk);
|
xfree (pk);
|
||||||
return;
|
return;
|
||||||
@ -460,6 +467,8 @@ current_card_status (ctrl_t ctrl, estream_t fp,
|
|||||||
|
|
||||||
if (opt.with_colons)
|
if (opt.with_colons)
|
||||||
es_fputs ("openpgp-card:\n", fp);
|
es_fputs ("openpgp-card:\n", fp);
|
||||||
|
else
|
||||||
|
tty_fprintf (fp, "Application type .: %s\n", "OpenPGP");
|
||||||
|
|
||||||
|
|
||||||
if (opt.with_colons)
|
if (opt.with_colons)
|
||||||
@ -693,6 +702,7 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
|||||||
strlist_t card_list, sl;
|
strlist_t card_list, sl;
|
||||||
char *serialno0, *serialno1;
|
char *serialno0, *serialno1;
|
||||||
int all_cards = 0;
|
int all_cards = 0;
|
||||||
|
int any_card = 0;
|
||||||
|
|
||||||
if (serialno == NULL)
|
if (serialno == NULL)
|
||||||
{
|
{
|
||||||
@ -720,6 +730,10 @@ card_status (ctrl_t ctrl, estream_t fp, const char *serialno)
|
|||||||
if (!all_cards && strcmp (serialno, sl->d))
|
if (!all_cards && strcmp (serialno, sl->d))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (any_card && !opt.with_colons)
|
||||||
|
tty_fprintf (fp, "\n");
|
||||||
|
any_card = 1;
|
||||||
|
|
||||||
err = agent_scd_serialno (&serialno1, sl->d);
|
err = agent_scd_serialno (&serialno1, sl->d);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user