1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg: Print Yubikey version correctly.

* g10/call-agent.c (learn_status_cb): Parse APPVERSION.
* g10/call-agent.h (struct agent_card_info_s): Add field appversion.
* g10/card-util.c (print_a_version): New.
(current_card_status): Print version from appversion.
--

This is a regression due to the PIV support.  Note that the newer
gpg-card worked correctly.

GnuPG-bug-id: 5787
This commit is contained in:
Werner Koch 2022-01-18 08:03:27 +01:00
parent ec4a1cffb8
commit 38e100acb7
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 38 additions and 2 deletions

View File

@ -539,6 +539,13 @@ learn_status_cb (void *opaque, const char *line)
xfree (parm->apptype);
parm->apptype = unescape_status_string (line);
}
else if (keywordlen == 10 && !memcmp (keyword, "APPVERSION", keywordlen))
{
unsigned int val = 0;
sscanf (line, "%x", &val);
parm->appversion = val;
}
else if (keywordlen == 9 && !memcmp (keyword, "DISP-NAME", keywordlen))
{
xfree (parm->disp_name);

View File

@ -32,6 +32,7 @@ struct agent_card_info_s
int error; /* private. */
char *reader; /* Reader information. */
char *apptype; /* Malloced application type string. */
unsigned int appversion; /* Version of the application. */
unsigned int manufacturer_id;
char *manufacturer_name; /* malloced. */
char *serialno; /* malloced hex string. */

View File

@ -348,6 +348,26 @@ fpr_is_ff (const char *fpr, unsigned int fprlen)
}
static void
print_a_version (estream_t fp, const char *prefix, unsigned int value)
{
unsigned int a, b, c, d;
a = ((value >> 24) & 0xff);
b = ((value >> 16) & 0xff);
c = ((value >> 8) & 0xff);
d = ((value ) & 0xff);
if (a)
tty_fprintf (fp, "%s %u.%u.%u.%u\n", prefix, a, b, c, d);
else if (b)
tty_fprintf (fp, "%s %u.%u.%u\n", prefix, b, c, d);
else if (c)
tty_fprintf (fp, "%s %u.%u\n", prefix, c, d);
else
tty_fprintf (fp, "%s %u\n", prefix, d);
}
/* Print all available information about the current card. */
static void
current_card_status (ctrl_t ctrl, estream_t fp,
@ -448,6 +468,11 @@ current_card_status (ctrl_t ctrl, estream_t fp,
if (opt.with_colons)
{
if (info.appversion)
es_fprintf (fp, "version:%02u%02u:\n",
(info.appversion >> 8) & 0xff,
info.appversion & 0xff);
else
es_fprintf (fp, "version:%.4s:\n", info.serialno+12);
uval = xtoi_2(info.serialno+16)*256 + xtoi_2 (info.serialno+18);
pesc = (info.manufacturer_name
@ -548,6 +573,9 @@ current_card_status (ctrl_t ctrl, estream_t fp,
}
else
{
if (info.appversion)
print_a_version (fp, "Version ..........:", info.appversion);
else
tty_fprintf (fp, "Version ..........: %.1s%c.%.1s%c\n",
info.serialno[12] == '0'?"":info.serialno+12,
info.serialno[13],