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:
parent
4be79b5abe
commit
0af1c6447d
3 changed files with 77 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue