diff options
author | Werner Koch <[email protected]> | 2019-01-29 18:52:08 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-01-29 19:19:22 +0000 |
commit | 5e5f3ca0c2e08185a236b4d04b318f81004e3223 (patch) | |
tree | decb1c5ae124321c661b9824157e502c14ff037d /kbx/kbxutil.c | |
parent | common: Provide some convenient OpenPGP related constants. (diff) | |
download | gnupg-5e5f3ca0c2e08185a236b4d04b318f81004e3223.tar.gz gnupg-5e5f3ca0c2e08185a236b4d04b318f81004e3223.zip |
gpg: Implement searching keys via keygrip.
* kbx/keybox-defs.h (struct _keybox_openpgp_key_info): Add field grip.
* kbx/keybox-openpgp.c (struct keyparm_s): New.
(keygrip_from_keyparm): New.
(parse_key): Compute keygrip.
* kbx/keybox-search.c (blob_openpgp_has_grip): New.
(has_keygrip): Call it.
--
This has been marked for too long as not yet working. However, it is
a pretty useful feature and will come pretty handy when looking for
all keys matching one keygrip.
Can be optimized a lot by storing the keygrip in the meta data. This
will be done along with the upgrade of KBX for v5 fingerprints.
Signed-off-by: Werner Koch <[email protected]>
(cherry picked from commit c128667b3cba749dd14262e032d4c260a2b0acd3)
Diffstat (limited to 'kbx/kbxutil.c')
-rw-r--r-- | kbx/kbxutil.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kbx/kbxutil.c b/kbx/kbxutil.c index 07774f2d9..f156122e2 100644 --- a/kbx/kbxutil.c +++ b/kbx/kbxutil.c @@ -330,6 +330,18 @@ dump_fpr (const unsigned char *buffer, size_t len) static void +dump_grip (const unsigned char *buffer, size_t len) +{ + int i; + + for (i=0; i < len; i++, buffer++) + { + printf ("%02X", buffer[0]); + } +} + + +static void dump_openpgp_key (keybox_openpgp_info_t info, const unsigned char *image) { printf ("pub %2d %02X%02X%02X%02X", @@ -338,6 +350,9 @@ dump_openpgp_key (keybox_openpgp_info_t info, const unsigned char *image) info->primary.keyid[6], info->primary.keyid[7] ); dump_fpr (info->primary.fpr, info->primary.fprlen); putchar ('\n'); + fputs ("grp ", stdout); + dump_grip (info->primary.grip, 20); + putchar ('\n'); if (info->nsubkeys) { struct _keybox_openpgp_key_info *k; @@ -351,6 +366,9 @@ dump_openpgp_key (keybox_openpgp_info_t info, const unsigned char *image) k->keyid[6], k->keyid[7] ); dump_fpr (k->fpr, k->fprlen); putchar ('\n'); + fputs ("grp ", stdout); + dump_grip (k->grip, 20); + putchar ('\n'); k = k->next; } while (k); |