diff options
author | Neal H. Walfield <neal@g10code.com> | 2015-09-14 11:27:43 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@g10code.com> | 2015-09-16 15:15:20 +0200 |
commit | 9acbeac23668a1d0dabca27d7825430d76e095c2 (patch) | |
tree | 3bdcc4b5f427d14a2b7a505d0cb9d95be4d731a6 /g10/getkey.c | |
parent | g10: Remove unused prototype (get_pubkey_byfpr). (diff) | |
download | gnupg2-9acbeac23668a1d0dabca27d7825430d76e095c2.tar.xz gnupg2-9acbeac23668a1d0dabca27d7825430d76e095c2.zip |
kbx: Change skipfnc's prototype so that we can provide all information.
* kbx/keybox-search-desc.h (struct keydb_search_desc.skipfnc): Change
third parameter to be the index of the user id packet in the keyblock
rather than the packet itself. Update users.
--
Signed-off-by: Neal H. Walfield <neal@g10code.com>.
The keybox code doesn't work directly with keyblocks. As such, the
matched user packet is not readily available to pass to
DESC[n].SKIPFNC. But, we do know the index of the user id packet that
matched. Thus, pass that instead. If the skip function needs the
user id packet, it can use the key id to look up the key block and
find the appropriate packet.
Diffstat (limited to 'g10/getkey.c')
-rw-r--r-- | g10/getkey.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/g10/getkey.c b/g10/getkey.c index 6fb3d867f..56dbfa0b6 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -543,10 +543,11 @@ get_seckey (PKT_public_key *pk, u32 *keyid) static int -skip_unusable (void *dummy, u32 * keyid, PKT_user_id * uid) +skip_unusable (void *dummy, u32 * keyid, int uid_no) { int unusable = 0; KBNODE keyblock; + PKT_public_key *pk; (void) dummy; @@ -557,28 +558,38 @@ skip_unusable (void *dummy, u32 * keyid, PKT_user_id * uid) goto leave; } + pk = keyblock->pkt->pkt.public_key; + /* Is the user ID in question revoked/expired? */ - if (uid) + if (uid_no) { KBNODE node; + int uids_seen = 0; for (node = keyblock; node; node = node->next) { if (node->pkt->pkttype == PKT_USER_ID) { - if (cmp_user_ids (uid, node->pkt->pkt.user_id) == 0 - && (node->pkt->pkt.user_id->is_revoked - || node->pkt->pkt.user_id->is_expired)) - { - unusable = 1; - break; - } + PKT_user_id *user_id = node->pkt->pkt.user_id; + + uids_seen ++; + if (uids_seen != uid_no) + continue; + + if (user_id->is_revoked || user_id->is_expired) + unusable = 1; + + break; } } + + /* If UID_NO is non-zero, then the keyblock better have at least + that many UIDs. */ + assert (uids_seen == uid_no); } if (!unusable) - unusable = pk_is_disabled (keyblock->pkt->pkt.public_key); + unusable = pk_is_disabled (pk); leave: release_kbnode (keyblock); |