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

kbx: Store the UBIB in the blob.

* kbx/keybox-blob.c (create_blob_header): New blob flag UBIB.
(create_blob_finish): Write the UBIB.
* kbx/keybox-dump.c (print_ubib): New.
(_keybox_dump_blob): Print UBIB flag.
* kbx/keybox-search.c (has_ubid): Compare the stored UBIB if
available.
--

This make scanning the keybox for a given UBIB much faster once it has
been stored.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-09-27 13:51:52 +02:00
parent 4be79b5abe
commit 0af1c6447d
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
3 changed files with 77 additions and 11 deletions

View file

@ -707,14 +707,23 @@ has_ubid (KEYBOXBLOB blob, const unsigned char *ubid)
buffer = _keybox_get_blob_image (blob, &length);
if (length < 40)
return 0; /*GPG_ERR_TOO_SHORT*/
image_off = get32 (buffer+8);
image_len = get32 (buffer+12);
if ((uint64_t)image_off+(uint64_t)image_len > (uint64_t)length)
return 0; /*GPG_ERR_TOO_SHORT*/
gcry_md_hash_buffer (GCRY_MD_SHA1, ubid_blob, buffer + image_off, image_len);
if ((get16 (buffer + 6) & 4))
{
/* The blob has a stored UBID. */
return !memcmp (ubid, buffer + length - 40, 20);
}
else
{
/* Need to compute the UBID. */
image_off = get32 (buffer+8);
image_len = get32 (buffer+12);
if ((uint64_t)image_off+(uint64_t)image_len > (uint64_t)length)
return 0; /*GPG_ERR_TOO_SHORT*/
return !memcmp (ubid, ubid_blob, 20);
gcry_md_hash_buffer (GCRY_MD_SHA1, ubid_blob, buffer+image_off,image_len);
return !memcmp (ubid, ubid_blob, 20);
}
}
static inline int