diff options
| author | Werner Koch <[email protected]> | 2020-02-12 11:50:38 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2020-02-12 11:50:38 +0000 |
| commit | 1abfce82bd525de2976c31b83bb0e67e33364e58 (patch) | |
| tree | 9632addec0e3a4a3e80f0a466f9e28484ec2f4a8 /tools/gpg-card.c | |
| parent | card: New option --no-key-lookup. (diff) | |
| download | gnupg-1abfce82bd525de2976c31b83bb0e67e33364e58.tar.gz gnupg-1abfce82bd525de2976c31b83bb0e67e33364e58.zip | |
card: List more info for an OpenPGP key.
* tools/gpg-card.h (struct pubkey_s): Add field created.
* tools/card-keys.c (parse_key_record): Set that field.
* tools/gpg-card.c (print_shax_fpr): Print the fingerprint without
spaces for easier c+p.
(list_one_kinfo): Print the actual used fingerprint and creation date
from the keyblock.
--
A common problem with OpenPGP cards is that the fingerprint as stored
on the card does not match the actual fingerprint. Print both values
to be able to investigate such issues.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tools/gpg-card.c')
| -rw-r--r-- | tools/gpg-card.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/gpg-card.c b/tools/gpg-card.c index 0b640dee0..c526d56f7 100644 --- a/tools/gpg-card.c +++ b/tools/gpg-card.c @@ -537,13 +537,8 @@ print_shax_fpr (estream_t fp, const unsigned char *fpr, unsigned int fprlen) if (fpr) { - /* FIXME: Fix formatting for FPRLEN != 20 */ - for (i=0; i < fprlen ; i+=2, fpr += 2 ) - { - if (i == 10 ) - tty_fprintf (fp, " "); - tty_fprintf (fp, " %02X%02X", *fpr, fpr[1]); - } + for (i=0; i < fprlen ; i++, fpr++) + tty_fprintf (fp, "%02X", *fpr); } else tty_fprintf (fp, " [none]"); @@ -698,7 +693,7 @@ list_one_kinfo (key_info_t firstkinfo, key_info_t kinfo, if (kinfo->fprlen && kinfo->created) { - tty_fprintf (fp, " fingerprint :"); + tty_fprintf (fp, " stored fpr .: "); print_shax_fpr (fp, kinfo->fpr, kinfo->fprlen); tty_fprintf (fp, " created ....: %s\n", isotimestamp (kinfo->created)); @@ -725,7 +720,7 @@ list_one_kinfo (key_info_t firstkinfo, key_info_t kinfo, * fingerprint or a reference to it. */ if (kb->protocol == GNUPG_PROTOCOL_OPENPGP) { - tty_fprintf (fp, " main key .:"); + tty_fprintf (fp, " main key .: "); for (ki=firstkinfo; ki; ki = ki->next) if (pubkey->grip_valid && !memcmp (ki->grip, pubkey->grip, KEYGRIP_LEN)) @@ -744,11 +739,20 @@ list_one_kinfo (key_info_t firstkinfo, key_info_t kinfo, else s = NULL; if (s) - tty_fprintf (fp, " <%s>\n", s); + tty_fprintf (fp, "<%s>\n", s); else - tty_fprintf (fp, " <Key %s>\n", ki->keyref); + tty_fprintf (fp, "<Key %s>\n", ki->keyref); + + tty_fprintf (fp, " fpr ......: "); + for (; pubkey; pubkey = pubkey->next) + if (pubkey->grip_valid + && !memcmp (ki->grip, pubkey->grip, KEYGRIP_LEN)) + break; + print_shax_fpr (fp, pubkey->fpr, pubkey->fprlen); + tty_fprintf (fp, " created ..: %s\n", + isotimestamp (pubkey->created)); } - else + else /* Print the primary key as fallback. */ print_shax_fpr (fp, pubkey->fpr, pubkey->fprlen); } for (uid = kb->uids; uid; uid = uid->next) |
