1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

scd: Handle Yubikey's multiple apps and serialno.

* scd/app-common.h (yubikey_get_serialno): New.
* scd/app-openpgp.c (yubikey_get_serialno): New.
* scd/app.c (card_get_serialno): Use OpenPGP app's serialno,
when it's enabled for Yubikey.
(send_serialno_and_app_status): Use card_get_serialno, not
directly accessing ->serialno.

--

GnuPG-bug-id: 5100
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-10-23 16:31:03 +09:00
parent c8cc35dd2c
commit 2d4de4b6f0
3 changed files with 72 additions and 7 deletions

View file

@ -1383,6 +1383,39 @@ get_disp_name (app_t app)
}
/*
* Yubikey has its own serial number at app->serialno. When Yubikey
* is used for OpenPGP card app, we get the serial number for OpenPGP
* card from its AID data object.
*/
char *
yubikey_get_serialno (app_t app)
{
void *relptr;
unsigned char *buffer;
size_t buflen;
char *serial;
relptr = get_one_do (app, 0x004F, &buffer, &buflen, NULL);
if (!relptr)
return NULL;
if (buflen != 16)
{
xfree (relptr);
return NULL;
}
serial = xtrymalloc (32 + 1);
if (!serial)
return NULL;
serial[32] = 0;
bin2hex (buffer, buflen, serial);
xfree (relptr);
return serial;
}
/* Return the pretty formatted serialnumber. On error NULL is
* returned. */
static char *