mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
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>
This commit is contained in:
parent
0f780b1aeb
commit
e59d2b3632
@ -235,7 +235,7 @@ const char *strapptype (apptype_t t);
|
||||
void app_update_priority_list (const char *arg);
|
||||
gpg_error_t app_send_card_list (ctrl_t ctrl);
|
||||
gpg_error_t app_send_active_apps (card_t card, ctrl_t ctrl);
|
||||
char *card_get_serialno (card_t card);
|
||||
char *card_get_serialno (card_t card, int is_canonical);
|
||||
char *app_get_serialno (app_t app);
|
||||
char *yubikey_get_serialno (app_t app);
|
||||
|
||||
|
11
scd/app.c
11
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. */
|
||||
|
||||
|
@ -346,7 +346,7 @@ cmd_serialno (assuan_context_t ctx, char *line)
|
||||
return rc;
|
||||
}
|
||||
|
||||
serial = card_get_serialno (ctrl->card_ctx);
|
||||
serial = card_get_serialno (ctrl->card_ctx, 0);
|
||||
if (!serial)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
@ -522,7 +522,7 @@ cmd_learn (assuan_context_t ctx, char *line)
|
||||
send_status_direct (ctrl, "READER", reader);
|
||||
/* No need to free the string of READER. */
|
||||
|
||||
serial = card_get_serialno (ctrl->card_ctx);
|
||||
serial = card_get_serialno (ctrl->card_ctx, 1);
|
||||
if (!serial)
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user