diff options
author | Werner Koch <wk@gnupg.org> | 2019-11-28 09:39:35 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2019-11-28 11:16:13 +0100 |
commit | 915297705af6f1db74dacf0d6665b83eb0a58459 (patch) | |
tree | 7e7cdc2f55f3d7d218a90f9eada3327a4dc534ff /kbx/keybox-blob.c | |
parent | dirmngr: Replace no-strict-overflow pragma by wrapv pragma. (diff) | |
download | gnupg2-915297705af6f1db74dacf0d6665b83eb0a58459.tar.xz gnupg2-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 <wk@gnupg.org>
Diffstat (limited to 'kbx/keybox-blob.c')
-rw-r--r-- | kbx/keybox-blob.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/kbx/keybox-blob.c b/kbx/keybox-blob.c index 0fced7e1c..b953e8c57 100644 --- a/kbx/keybox-blob.c +++ b/kbx/keybox-blob.c @@ -67,7 +67,6 @@ - u16 Blob flags bit 0 = contains secret key material (not used) bit 1 = ephemeral blob (e.g. used while querying external resources) - bit 2 = blob has an UBID field. - u32 Offset to the OpenPGP keyblock or the X.509 DER encoded certificate - u32 The length of the keyblock or certificate @@ -145,9 +144,6 @@ - bN Space for the keyblock or certificate. - bN RFU. This is the remaining space after keyblock and before the checksum. Not part of the SHA-1 checksum. - - bN Only if blob flags bit 2 is set: 20 octet Unique Blob-ID (UBID). - This is the SHA-1 checksum of the keyblock or certificate. - This is not part of the SHA-1 checksum below. - b20 SHA-1 checksum (useful for KS synchronization?) Note, that KBX versions before GnuPG 2.1 used an MD5 checksum. However it was only created but never checked. @@ -694,8 +690,8 @@ create_blob_finish (KEYBOXBLOB blob) unsigned char *pp; size_t n; - /* Write placeholders for the UBID and the checksum */ - put_membuf (a, NULL, 40); + /* Write placeholders for the checksum. */ + put_membuf (a, NULL, 20); /* get the memory area */ n = 0; /* (Just to avoid compiler warning.) */ @@ -729,9 +725,6 @@ create_blob_finish (KEYBOXBLOB blob) blob->fixups = NULL; } - /* Compute and store the UBID. (image_off) (image_len) */ - gcry_md_hash_buffer (GCRY_MD_SHA1, p + n - 40, p + get32 (p+8), get32 (p+12)); - /* Compute and store the SHA-1 checksum. */ gcry_md_hash_buffer (GCRY_MD_SHA1, p + n - 20, p, n - 40); |