diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2020-10-27 06:35:20 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2020-10-27 06:35:20 +0100 |
commit | e59d2b3632d8c778bd2c4375a1c3ba9c786c4360 (patch) | |
tree | b44212957ea9cad33df660801ff119837898df33 /scd/app.c | |
parent | g10: Make call to agent_scd_serialno more robust. (diff) | |
download | gnupg2-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.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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. */ |