diff options
| author | NIIBE Yutaka <[email protected]> | 2020-10-23 07:31:03 +0000 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2020-10-23 07:31:03 +0000 |
| commit | 2d4de4b6f06c87cd0f72b2a0d09950e1b50841b2 (patch) | |
| tree | 9faa40f8ed13ff74dea166d30f05fcfff67b31bb /scd/app-openpgp.c | |
| parent | scd: Use app_get_serialno for app_getattr. (diff) | |
| download | gnupg-2d4de4b6f06c87cd0f72b2a0d09950e1b50841b2.tar.gz gnupg-2d4de4b6f06c87cd0f72b2a0d09950e1b50841b2.zip | |
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 <[email protected]>
Diffstat (limited to 'scd/app-openpgp.c')
| -rw-r--r-- | scd/app-openpgp.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 8085fa812..b75ee6457 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -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 * |
