aboutsummaryrefslogtreecommitdiffstats
path: root/kbx/keybox-dump.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-11-28 08:39:35 +0000
committerWerner Koch <[email protected]>2019-11-28 10:16:13 +0000
commit915297705af6f1db74dacf0d6665b83eb0a58459 (patch)
tree7e7cdc2f55f3d7d218a90f9eada3327a4dc534ff /kbx/keybox-dump.c
parentdirmngr: Replace no-strict-overflow pragma by wrapv pragma. (diff)
downloadgnupg-915297705af6f1db74dacf0d6665b83eb0a58459.tar.gz
gnupg-915297705af6f1db74dacf0d6665b83eb0a58459.zip
kbx: Redefine the UBID which is now the primary fingerprint.
* common/util.h (UBID_LEN): New. Use it at all places. * kbx/keybox-blob.c (create_blob_finish): Do not write the UBID item. * kbx/keybox-dump.c (print_ubib): Remove. (_keybox_dump_blob): Do not print the now removed ubid flag. * kbx/keybox-search-desc.h (struct keydb_search_desc): Use constants for the size of the ubid and grip. * kbx/keybox-search.c (blob_cmp_ubid): New. (has_ubid): Make it a simple wrapper around blob_cmp_ubid. (keybox_get_data): Add arg 'r_ubid'. * kbx/frontend.h (enum kbxd_store_modes): New. * kbx/kbxserver.c (cmd_store): Add new option --insert. * kbx/backend-cache.c (be_cache_initialize): New. (be_cache_add_resource): Call it here. * kbx/backend-kbx.c (be_kbx_seek): Remove args 'fpr' and 'fprlen'. (be_kbx_search): Get the UBID from keybox_get_data. * kbx/backend-support.c (be_fingerprint_from_blob): Replace by ... (be_ubid_from_blob): new. Change all callers. * kbx/frontend.c (kbxd_add_resource): Temporary disable the cache but use the new cache init function. (kbxd_store): Replace arg 'only_update' by 'mode'. Seek using the ubid. Take care of the mode. -- It turned out that using the hash of the entire blob was not helpful. Thus we redefine the Unique-Blob-ID (UBID) as the primary fingerprint of the blob. In case this is a v5 OpenPGP key a left truncated version of the SHA-256 hash is used; in all other cases the full SHA-1 hash. Using a SHA-256 hash does not make sense because v4 keys are and will for some time be the majority of keys and thus padding them with zeroes won't make any difference. Even if fingerprint collisions can eventually be created we will assume that the keys are bogus and that it does not make sense to store its twin also in our key storage. We can also easily extend the update code to detect a collision and reject the update. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'kbx/keybox-dump.c')
-rw-r--r--kbx/keybox-dump.c48
1 files changed, 1 insertions, 47 deletions
diff --git a/kbx/keybox-dump.c b/kbx/keybox-dump.c
index 55a47a403..0c289d50a 100644
--- a/kbx/keybox-dump.c
+++ b/kbx/keybox-dump.c
@@ -63,41 +63,6 @@ print_string (FILE *fp, const byte *p, size_t n, int delim)
}
-static void
-print_ubib (const byte *buffer, size_t length, FILE *fp)
-{
- const byte *p;
- int i;
- size_t image_off, image_len;
- unsigned char digest[20];
-
- fprintf (fp, "UBIB: ");
- if (length < 40)
- {
- fputs ("[blob too short for a stored UBIB]\n", fp);
- return;
- }
-
- p = buffer + length - 40;
- for (i=0; i < 20; p++, i++)
- fprintf (fp, "%02X", *p);
-
- image_off = get32 (buffer+8);
- image_len = get32 (buffer+12);
- if ((uint64_t)image_off+(uint64_t)image_len > (uint64_t)length)
- {
- fputs (" [image claims to be longer than the blob]\n", fp);
- return;
- }
-
- gcry_md_hash_buffer (GCRY_MD_SHA1, digest, buffer+image_off,image_len);
- if (memcmp (digest, buffer + length - 40, 20))
- fputs (" [does not match the image]\n", fp);
- else
- fputc ('\n', fp);
-}
-
-
static int
print_checksum (const byte *buffer, size_t length, size_t unhashed, FILE *fp)
{
@@ -205,8 +170,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
ulong nserial;
ulong unhashed;
const byte *p;
- int is_fpr32; /* blob ersion 2 */
- int have_ubib = 0;
+ int is_fpr32; /* blob version 2 */
buffer = _keybox_get_blob_image (blob, &length);
@@ -273,14 +237,6 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
fputs ("ephemeral", fp);
any++;
}
- if ((n & 4))
- {
- if (any)
- putc (',', fp);
- fputs ("ubid", fp);
- any++;
- have_ubib = 1;
- }
putc (')', fp);
}
putc ('\n', fp);
@@ -466,8 +422,6 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
n = get32 ( buffer + length - unhashed);
fprintf (fp, "Storage-Flags: %08lx\n", n );
}
- if (have_ubib)
- print_ubib (buffer, length, fp);
print_checksum (buffer, length, unhashed, fp);
return 0;
}