1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

card: Make printing of key information more flexible.

* tools/card-tool-misc.c: New.
* tools/card-tool.h: Rewored data structures for key infos.
* tools/gpg-card-tool.c: Ditto.
* tools/card-call-scd.c: Ditto.
--

Note that this also changes the way the key information is printed.
Formerly we printed it like:

  Signature key ....: <openpgp-fingerprint>
        created ....: <timestamp>
        keygrip ... : <keygrip>

now we do:

  Signature key ....: <keygrip>
        fingerprint : <openpgp-fingerprint>
        created ....: <timestamp>

This is because a keygrip is always available but a fingerprint and
the creation date are properties of an OpenPGP card.  A standard way
of listing keys is better than one depending on the type of card.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-01-29 08:48:53 +01:00
parent 02a2633a7f
commit 237880175f
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
5 changed files with 293 additions and 86 deletions

View file

@ -76,6 +76,26 @@ struct key_attr
};
};
/* An object to store information pertaining to a key pair. This is
* commonly used as a linked list with all keys known for the current
* card. */
struct key_info_s
{
struct key_info_s *next;
unsigned char grip[20];/* The keygrip. */
unsigned char xflag; /* Temporary flag to help processing a list. */
/* The three next items are mostly useful for OpenPGP cards. */
unsigned char fprlen; /* Use length of the next item. */
unsigned char fpr[32]; /* The binary fingerprint of length FPRLEN. */
u32 created; /* The time the key was created. */
char keyref[1]; /* String with the keyref (e.g. OPENPGP.1). */
};
typedef struct key_info_s *key_info_t;
/*
* The object used to store information about a card.
@ -100,18 +120,7 @@ struct card_info_s
char cafpr1[20];
char cafpr2[20];
char cafpr3[20];
unsigned char fpr1len; /* Length of the fingerprint or 0 if invalid. */
unsigned char fpr2len;
unsigned char fpr3len;
char fpr1[20];
char fpr2[20];
char fpr3[20];
u32 fpr1time;
u32 fpr2time;
u32 fpr3time;
char grp1[20]; /* The keygrip for OPENPGP.1 */
char grp2[20]; /* The keygrip for OPENPGP.2 */
char grp3[20]; /* The keygrip for OPENPGP.3 */
key_info_t kinfo; /* Linked list with all keypair related data. */
unsigned long sig_counter;
int chv1_cached; /* True if a PIN is not required for each
signing. Note that the gpg-agent might cache
@ -133,6 +142,10 @@ struct card_info_s
typedef struct card_info_s *card_info_t;
/*-- card-tool-misc.c --*/
key_info_t find_kinfo (card_info_t info, const char *keyref);
/*-- card-call-scd.c --*/
void release_card_info (card_info_t info);
const char *app_type_string (app_type_t app_type);