1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-29 21:58:04 +02: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>
This commit is contained in:
Werner Koch 2019-04-01 19:24:33 +02:00
parent 0fad61de15
commit e47524c34a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 30 additions and 16 deletions

View File

@ -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))

View File

@ -419,36 +419,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;
@ -463,6 +470,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)
@ -695,6 +704,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)
{ {
@ -722,6 +732,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)
{ {