aboutsummaryrefslogtreecommitdiffstats
path: root/kbx/kbxutil.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-01-29 18:52:08 +0000
committerWerner Koch <[email protected]>2019-01-29 19:10:11 +0000
commitc128667b3cba749dd14262e032d4c260a2b0acd3 (patch)
tree69a5bd841fa2f85d8c43e05b6e57b70ffb9cc32c /kbx/kbxutil.c
parentcommon: Provide some convenient OpenPGP related constants. (diff)
downloadgnupg-c128667b3cba749dd14262e032d4c260a2b0acd3.tar.gz
gnupg-c128667b3cba749dd14262e032d4c260a2b0acd3.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]>
Diffstat (limited to 'kbx/kbxutil.c')
-rw-r--r--kbx/kbxutil.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kbx/kbxutil.c b/kbx/kbxutil.c
index 2cfd07019..35f92ab6e 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);