mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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 <wk@gnupg.org>
This commit is contained in:
parent
2c6092bc5d
commit
1abfce82bd
@ -174,6 +174,10 @@ parse_key_record (char **fields, int nfields, pubkey_t *r_pubkey)
|
|||||||
pubkey = xtrycalloc (1, sizeof *pubkey);
|
pubkey = xtrycalloc (1, sizeof *pubkey);
|
||||||
if (!pubkey)
|
if (!pubkey)
|
||||||
return gpg_error_from_syserror ();
|
return gpg_error_from_syserror ();
|
||||||
|
|
||||||
|
if (nfields > 5)
|
||||||
|
pubkey->created = parse_timestamp (fields[5], NULL);
|
||||||
|
|
||||||
*r_pubkey = pubkey;
|
*r_pubkey = pubkey;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -537,13 +537,8 @@ print_shax_fpr (estream_t fp, const unsigned char *fpr, unsigned int fprlen)
|
|||||||
|
|
||||||
if (fpr)
|
if (fpr)
|
||||||
{
|
{
|
||||||
/* FIXME: Fix formatting for FPRLEN != 20 */
|
for (i=0; i < fprlen ; i++, fpr++)
|
||||||
for (i=0; i < fprlen ; i+=2, fpr += 2 )
|
tty_fprintf (fp, "%02X", *fpr);
|
||||||
{
|
|
||||||
if (i == 10 )
|
|
||||||
tty_fprintf (fp, " ");
|
|
||||||
tty_fprintf (fp, " %02X%02X", *fpr, fpr[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tty_fprintf (fp, " [none]");
|
tty_fprintf (fp, " [none]");
|
||||||
@ -698,7 +693,7 @@ list_one_kinfo (key_info_t firstkinfo, key_info_t kinfo,
|
|||||||
|
|
||||||
if (kinfo->fprlen && kinfo->created)
|
if (kinfo->fprlen && kinfo->created)
|
||||||
{
|
{
|
||||||
tty_fprintf (fp, " fingerprint :");
|
tty_fprintf (fp, " stored fpr .: ");
|
||||||
print_shax_fpr (fp, kinfo->fpr, kinfo->fprlen);
|
print_shax_fpr (fp, kinfo->fpr, kinfo->fprlen);
|
||||||
tty_fprintf (fp, " created ....: %s\n",
|
tty_fprintf (fp, " created ....: %s\n",
|
||||||
isotimestamp (kinfo->created));
|
isotimestamp (kinfo->created));
|
||||||
@ -725,7 +720,7 @@ list_one_kinfo (key_info_t firstkinfo, key_info_t kinfo,
|
|||||||
* fingerprint or a reference to it. */
|
* fingerprint or a reference to it. */
|
||||||
if (kb->protocol == GNUPG_PROTOCOL_OPENPGP)
|
if (kb->protocol == GNUPG_PROTOCOL_OPENPGP)
|
||||||
{
|
{
|
||||||
tty_fprintf (fp, " main key .:");
|
tty_fprintf (fp, " main key .: ");
|
||||||
for (ki=firstkinfo; ki; ki = ki->next)
|
for (ki=firstkinfo; ki; ki = ki->next)
|
||||||
if (pubkey->grip_valid
|
if (pubkey->grip_valid
|
||||||
&& !memcmp (ki->grip, pubkey->grip, KEYGRIP_LEN))
|
&& !memcmp (ki->grip, pubkey->grip, KEYGRIP_LEN))
|
||||||
@ -744,11 +739,20 @@ list_one_kinfo (key_info_t firstkinfo, key_info_t kinfo,
|
|||||||
else
|
else
|
||||||
s = NULL;
|
s = NULL;
|
||||||
if (s)
|
if (s)
|
||||||
tty_fprintf (fp, " <%s>\n", s);
|
tty_fprintf (fp, "<%s>\n", s);
|
||||||
else
|
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);
|
print_shax_fpr (fp, pubkey->fpr, pubkey->fprlen);
|
||||||
}
|
}
|
||||||
for (uid = kb->uids; uid; uid = uid->next)
|
for (uid = kb->uids; uid; uid = uid->next)
|
||||||
|
@ -67,6 +67,7 @@ struct pubkey_s
|
|||||||
unsigned char grip[KEYGRIP_LEN];
|
unsigned char grip[KEYGRIP_LEN];
|
||||||
unsigned char fpr[MAX_FINGERPRINT_LEN];
|
unsigned char fpr[MAX_FINGERPRINT_LEN];
|
||||||
unsigned char fprlen; /* The used length of a FPR. */
|
unsigned char fprlen; /* The used length of a FPR. */
|
||||||
|
time_t created; /* The creation date of the key. */
|
||||||
unsigned int grip_valid:1;/* The grip is valid. */
|
unsigned int grip_valid:1;/* The grip is valid. */
|
||||||
unsigned int requested: 1;/* This is the requested grip. */
|
unsigned int requested: 1;/* This is the requested grip. */
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user