mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Unification of the search descriptor usage.
This commit is contained in:
parent
bb861ac730
commit
9a96043be4
32 changed files with 501 additions and 599 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-12-08 Werner Koch <wk@g10code.com>
|
||||
|
||||
* keybox-search-desc.h (keydb_search_desc): Use u32 type for
|
||||
KID. Extend the skip function ptr.
|
||||
(gpg_pkt_user_id_t): New.
|
||||
* keybox-search.c (has_short_kid, has_long_kid): Change to use u32
|
||||
args for KID.
|
||||
|
||||
2008-12-09 Werner Koch <wk@g10code.com>
|
||||
|
||||
* kbxutil.c (main): Call i18n_init before init_common_subsystems.
|
||||
|
|
|
@ -48,24 +48,31 @@ typedef enum {
|
|||
KEYDB_SEARCH_MODE_NEXT
|
||||
} KeydbSearchMode;
|
||||
|
||||
struct keydb_search_desc {
|
||||
|
||||
/* Forwward declaration. See g10/packet.h. */
|
||||
struct gpg_pkt_user_id_s;
|
||||
typedef struct gpg_pkt_user_id_s *gpg_pkt_user_id_t;
|
||||
|
||||
/* A search descriptor. */
|
||||
struct keydb_search_desc
|
||||
{
|
||||
KeydbSearchMode mode;
|
||||
int (*skipfnc)(void *,void*); /* used to be: void*, u32* */
|
||||
int (*skipfnc)(void *, u32 *, gpg_pkt_user_id_t);
|
||||
void *skipfncvalue;
|
||||
const unsigned char *sn;
|
||||
int snlen; /* -1 := sn is a hex string */
|
||||
union {
|
||||
const char *name;
|
||||
unsigned char fpr[24];
|
||||
unsigned char kid[8];
|
||||
u32 kid[2]; /* Note that this is in native endianess. */
|
||||
unsigned char grip[20];
|
||||
} u;
|
||||
int exact; /* Use exactly this key ('!' suffix in gpg). */
|
||||
};
|
||||
|
||||
|
||||
struct keydb_search_desc;
|
||||
typedef struct keydb_search_desc KEYDB_SEARCH_DESC;
|
||||
|
||||
typedef struct keydb_search_desc KEYBOX_SEARCH_DESC;
|
||||
|
||||
|
||||
|
|
|
@ -530,15 +530,29 @@ blob_x509_has_grip (KEYBOXBLOB blob, const unsigned char *grip)
|
|||
The has_foo functions are used as helpers for search
|
||||
*/
|
||||
static inline int
|
||||
has_short_kid (KEYBOXBLOB blob, const unsigned char *kid)
|
||||
has_short_kid (KEYBOXBLOB blob, u32 lkid)
|
||||
{
|
||||
return blob_cmp_fpr_part (blob, kid+4, 16, 4);
|
||||
unsigned char buf[4];
|
||||
buf[0] = lkid >> 24;
|
||||
buf[1] = lkid >> 16;
|
||||
buf[2] = lkid >> 8;
|
||||
buf[3] = lkid;
|
||||
return blob_cmp_fpr_part (blob, buf, 16, 4);
|
||||
}
|
||||
|
||||
static inline int
|
||||
has_long_kid (KEYBOXBLOB blob, const unsigned char *kid)
|
||||
has_long_kid (KEYBOXBLOB blob, u32 mkid, u32 lkid)
|
||||
{
|
||||
return blob_cmp_fpr_part (blob, kid, 12, 8);
|
||||
unsigned char buf[8];
|
||||
buf[0] = mkid >> 24;
|
||||
buf[1] = mkid >> 16;
|
||||
buf[2] = mkid >> 8;
|
||||
buf[3] = mkid;
|
||||
buf[4] = lkid >> 24;
|
||||
buf[5] = lkid >> 16;
|
||||
buf[6] = lkid >> 8;
|
||||
buf[7] = lkid;
|
||||
return blob_cmp_fpr_part (blob, buf, 12, 8);
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
@ -877,11 +891,11 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_SHORT_KID:
|
||||
if (has_short_kid (blob, desc[n].u.kid))
|
||||
if (has_short_kid (blob, desc[n].u.kid[1]))
|
||||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_LONG_KID:
|
||||
if (has_long_kid (blob, desc[n].u.kid))
|
||||
if (has_long_kid (blob, desc[n].u.kid[0], desc[n].u.kid[1]))
|
||||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
|
@ -909,7 +923,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
for (n=any_skip?0:ndesc; n < ndesc; n++)
|
||||
{
|
||||
/* if (desc[n].skipfnc */
|
||||
/* && desc[n].skipfnc (desc[n].skipfncvalue, aki)) */
|
||||
/* && desc[n].skipfnc (desc[n].skipfncvalue, aki, NULL)) */
|
||||
/* break; */
|
||||
}
|
||||
if (n == ndesc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue