diff options
author | Werner Koch <wk@gnupg.org> | 2022-01-18 08:03:27 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2022-01-18 08:03:27 +0100 |
commit | 38e100acb7201010d46a50e6a371603373b2a30e (patch) | |
tree | 7a137791679ff86665abffd89780b410fd7f5d10 /g10/card-util.c | |
parent | gpgconf: Add command aliases -L -K -R. (diff) | |
download | gnupg2-38e100acb7201010d46a50e6a371603373b2a30e.tar.xz gnupg2-38e100acb7201010d46a50e6a371603373b2a30e.zip |
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
Diffstat (limited to 'g10/card-util.c')
-rw-r--r-- | g10/card-util.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/g10/card-util.c b/g10/card-util.c index f3ede6d46..a5f1f7bb7 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -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,7 +468,12 @@ current_card_status (ctrl_t ctrl, estream_t fp, if (opt.with_colons) { - es_fprintf (fp, "version:%.4s:\n", info.serialno+12); + 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 ? percent_escape (info.manufacturer_name, NULL) : NULL); @@ -548,7 +573,10 @@ current_card_status (ctrl_t ctrl, estream_t fp, } else { - tty_fprintf (fp, "Version ..........: %.1s%c.%.1s%c\n", + 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], info.serialno[14] == '0'?"":info.serialno+14, |