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

agent: Fix YK s/n and prettify the request card prompt for Yubikeys

* agent/divert-scd.c (ask_for_card): Detect and re-format the Yubikey
prompt.
* scd/app.c (app_munge_serialno): Fix Yubikey s/n munging.
(card_get_dispserialno): Ditto.
* scd/app-openpgp.c (get_disp_serialno): Remove.
(get_prompt_info): Use app_get_dispserialno.--
--
This commit is contained in:
Werner Koch 2020-11-26 12:36:44 +01:00
parent d784e76349
commit 7113263a00
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
3 changed files with 39 additions and 38 deletions

View file

@ -1208,10 +1208,22 @@ app_munge_serialno (card_t card)
buf[7] = 0; /* thus we use 0.0 and don't use this directly. */
buf[8] = 0; /* Manufacturer: Yubico (0x0006). */
buf[9] = 6;
buf[10] = (sn >> 24);
buf[11] = (sn >> 16);
buf[12] = (sn >> 8);
buf[13] = sn;
buf[13] = (sn % 10);
sn /= 10;
buf[13] |= (sn % 10) << 4;
sn /= 10;
buf[12] = (sn % 10);
sn /= 10;
buf[12] |= (sn % 10) << 4;
sn /= 10;
buf[11] = (sn % 10);
sn /= 10;
buf[11] |= (sn % 10) << 4;
sn /= 10;
buf[10] = (sn % 10);
sn /= 10;
buf[10] |= (sn % 10) << 4;
sn /= 10;
buf[14] = 0; /* Last two bytes are RFU. */
buf[15] = 0;
xfree (card->serialno);
@ -1311,15 +1323,13 @@ card_get_dispserialno (card_t card, int nofallback)
else if (card && card->cardtype == CARDTYPE_YUBIKEY)
{
/* Get back the printed Yubikey number from the OpenPGP AID
* Example: D2760001240100000006008A77C10000
* Example: D2760001240100000006120808620000
*/
result = card_get_serialno (card);
if (result && strlen (result) >= 28 && !strncmp (result+16, "0006", 4))
{
sn = xtoi_2 (result+20) * 16777216;
sn += xtoi_2 (result+22) * 65536;
sn += xtoi_2 (result+24) * 256;
sn += xtoi_2 (result+26);
sn = atoi_4 (result+20) * 10000;
sn += atoi_4 (result+24);
if ((card->cardversion >> 16) >= 5)
p = xtryasprintf ("%lu %03lu %03lu",
(sn/1000000ul),