diff options
author | Werner Koch <[email protected]> | 2020-11-26 11:36:44 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-11-26 14:56:37 +0000 |
commit | 7113263a00d8c9b09f0dfdb9590bfe2bab1bc776 (patch) | |
tree | c0fca9544130109763875b1175da38feffcb1af0 /agent/divert-scd.c | |
parent | scd: Do not try to use a non-enabled app after card switching. (diff) | |
download | gnupg-7113263a00d8c9b09f0dfdb9590bfe2bab1bc776.tar.gz gnupg-7113263a00d8c9b09f0dfdb9590bfe2bab1bc776.zip |
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.--
--
Diffstat (limited to 'agent/divert-scd.c')
-rw-r--r-- | agent/divert-scd.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/agent/divert-scd.c b/agent/divert-scd.c index 7587d4478..273f3a869 100644 --- a/agent/divert-scd.c +++ b/agent/divert-scd.c @@ -59,10 +59,25 @@ ask_for_card (ctrl_t ctrl, const unsigned char *shadow_info, if (len == 32 && !strncmp (want_sn, "D27600012401", 12)) { /* This is an OpenPGP card - reformat */ - memmove (want_sn, want_sn+16, 4); - want_sn[4] = ' '; - memmove (want_sn+5, want_sn+20, 8); - want_sn[13] = 0; + if (!strncmp (want_sn+16, "0006", 4)) + { + /* This is a Yubikey. Print the s/n as it would be printed + * on Yubikey 5. Example: D2760001240100000006120808620000 + * mmmm^^^^^^^^ */ + unsigned long sn; + + sn = atoi_4 (want_sn+20) * 10000; + sn += atoi_4 (want_sn+24); + snprintf (want_sn, 32, "%lu %03lu %03lu", + (sn/1000000ul), (sn/1000ul % 1000ul), (sn % 1000ul)); + } + else /* Default is the Zeitcontrol card print format. */ + { + memmove (want_sn, want_sn+16, 4); + want_sn[4] = ' '; + memmove (want_sn+5, want_sn+20, 8); + want_sn[13] = 0; + } } else if (len == 20 && want_sn[19] == '0') { |