Browse Source

gpg: Support KEYGRIP search with traditional keyring.

* g10/keyring.c (keyring_search): Handle KEYDB_SEARCH_MODE_KEYGRIP.

--

GnuPG-bug-id: 5469
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
master
NIIBE Yutaka 3 weeks ago
parent
commit
9668ee097a
  1. 16
      g10/keyring.c

16
g10/keyring.c

@ -968,7 +968,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
int save_mode;
off_t offset, main_offset;
size_t n;
int need_uid, need_words, need_keyid, need_fpr, any_skip;
int need_uid, need_words, need_keyid, need_fpr, any_skip, need_grip;
int pk_no, uid_no;
int initial_skip;
int scanned_from_start;
@ -976,9 +976,10 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
PKT_user_id *uid = NULL;
PKT_public_key *pk = NULL;
u32 aki[2];
unsigned char grip[KEYGRIP_LEN];
/* figure out what information we need */
need_uid = need_words = need_keyid = need_fpr = any_skip = 0;
need_uid = need_words = need_keyid = need_fpr = any_skip = need_grip = 0;
for (n=0; n < ndesc; n++)
{
switch (desc[n].mode)
@ -1005,8 +1006,11 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
/* always restart the search in this mode */
keyring_search_reset (hd);
break;
case KEYDB_SEARCH_MODE_KEYGRIP:
need_grip = 1;
break;
default: break;
}
}
if (desc[n].skipfnc)
{
any_skip = 1;
@ -1143,6 +1147,8 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
}
if (need_keyid)
keyid_from_pk (pk, aki);
if (need_grip)
keygrip_from_pk (pk, grip);
if (use_key_present_hash
&& !key_present_hash_ready
@ -1197,6 +1203,10 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
if (pk)
goto found;
break;
case KEYDB_SEARCH_MODE_KEYGRIP:
if (pk && !memcmp (desc[n].u.grip, grip, KEYGRIP_LEN))
goto found;
break;
default:
rc = GPG_ERR_INV_ARG;
goto found;

Loading…
Cancel
Save