aboutsummaryrefslogtreecommitdiffstats
path: root/kbx
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2009-12-08 16:30:33 +0000
committerWerner Koch <[email protected]>2009-12-08 16:30:33 +0000
commit9a96043be4bed4e18320918e042b1601c9d93e95 (patch)
tree0066f7268d25aa95d59cf5fbb7570e487b809c52 /kbx
parentSupport CERT records via ADNS (diff)
downloadgnupg-9a96043be4bed4e18320918e042b1601c9d93e95.tar.gz
gnupg-9a96043be4bed4e18320918e042b1601c9d93e95.zip
Unification of the search descriptor usage.
Diffstat (limited to 'kbx')
-rw-r--r--kbx/ChangeLog8
-rw-r--r--kbx/keybox-search-desc.h15
-rw-r--r--kbx/keybox-search.c28
3 files changed, 40 insertions, 11 deletions
diff --git a/kbx/ChangeLog b/kbx/ChangeLog
index b4f988234..7b5a546c4 100644
--- a/kbx/ChangeLog
+++ b/kbx/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-08 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
* kbxutil.c (main): Call i18n_init before init_common_subsystems.
diff --git a/kbx/keybox-search-desc.h b/kbx/keybox-search-desc.h
index 98d813507..e5da155f8 100644
--- a/kbx/keybox-search-desc.h
+++ b/kbx/keybox-search-desc.h
@@ -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;
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index 1680dd732..be4ca4579 100644
--- a/kbx/keybox-search.c
+++ b/kbx/keybox-search.c
@@ -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)