summaryrefslogtreecommitdiffstats
path: root/scd/app.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-10-27 06:35:20 +0100
committerNIIBE Yutaka <gniibe@fsij.org>2020-10-27 06:35:20 +0100
commite59d2b3632d8c778bd2c4375a1c3ba9c786c4360 (patch)
treeb44212957ea9cad33df660801ff119837898df33 /scd/app.c
parentg10: Make call to agent_scd_serialno more robust. (diff)
downloadgnupg2-e59d2b3632d8c778bd2c4375a1c3ba9c786c4360.tar.xz
gnupg2-e59d2b3632d8c778bd2c4375a1c3ba9c786c4360.zip
scd: Handle canonical serialno and app specific serialno differently.
* scd/app-common.h (card_get_serialno): Add IS_CANONICAL arg. * scd/app.c (app_send_devinfo): Use app specific serialno. (card_get_serialno): Support two different cases. (app_get_serialno): Return app specific serialno. (send_serialno_and_app_status): Return canonical serialno. * scd/command.c (cmd_serialno): Return app specific serialno. (cmd_learn): Return canonical serialno. -- GnuPG-bug-id: 5100 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd/app.c')
-rw-r--r--scd/app.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/scd/app.c b/scd/app.c
index 8f054a81f..872eb0ab2 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -302,7 +302,7 @@ app_send_devinfo (ctrl_t ctrl)
char *serialno;
char card_info[80];
- serialno = card_get_serialno (c);
+ serialno = card_get_serialno (c, 0);
snprintf (card_info, sizeof card_info, "DEVICE %s %s",
strcardtype (c->cardtype), serialno);
xfree (serialno);
@@ -1182,7 +1182,7 @@ app_munge_serialno (card_t card)
returned as a malloced string (hex encoded) in SERIAL. Caller must
free SERIAL unless the function returns an error. */
char *
-card_get_serialno (card_t card)
+card_get_serialno (card_t card, int is_canonical)
{
char *serial;
@@ -1191,7 +1191,8 @@ card_get_serialno (card_t card)
if (!card->serialnolen)
serial = xtrystrdup ("FF7F00");
- else if (card->cardtype == CARDTYPE_YUBIKEY)
+ else if (card->cardtype == CARDTYPE_YUBIKEY && !is_canonical
+ && card->app && card->app->apptype == APPTYPE_OPENPGP)
{
app_t a;
@@ -1226,7 +1227,7 @@ app_get_serialno (app_t app)
{
if (!app || !app->card)
return NULL;
- return card_get_serialno (app->card);
+ return card_get_serialno (app->card, 0);
}
@@ -2135,7 +2136,7 @@ send_serialno_and_app_status (card_t card, int with_apps, ctrl_t ctrl)
membuf_t mb;
int any = 0;
- serial = card_get_serialno (card);
+ serial = card_get_serialno (card, 1);
if (!serial)
return 0; /* Oops. */