summaryrefslogtreecommitdiffstats
path: root/kbx
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-01-15 14:02:25 +0100
committerWerner Koch <wk@gnupg.org>2002-01-15 14:02:25 +0100
commit9dd0040085a46109d90bc80046ec35b8abee1e90 (patch)
tree67d0fdcaa8ebded0ba2428d8ff0a69d8a9b05bd0 /kbx
parent* maperror.c: Add mapping for Not_Trusted. (diff)
downloadgnupg2-9dd0040085a46109d90bc80046ec35b8abee1e90.tar.xz
gnupg2-9dd0040085a46109d90bc80046ec35b8abee1e90.zip
* keybox-search.c (blob_cmp_fpr): New.
(has_fingerprint): Implemented;
Diffstat (limited to 'kbx')
-rw-r--r--kbx/ChangeLog5
-rw-r--r--kbx/keybox-search.c34
2 files changed, 38 insertions, 1 deletions
diff --git a/kbx/ChangeLog b/kbx/ChangeLog
index 9ad6c3c38..2eabb2178 100644
--- a/kbx/ChangeLog
+++ b/kbx/ChangeLog
@@ -1,3 +1,8 @@
+2002-01-15 Werner Koch <wk@gnupg.org>
+
+ * keybox-search.c (blob_cmp_fpr): New.
+ (has_fingerprint): Implemented;
+
2001-12-20 Werner Koch <wk@gnupg.org>
* keybox-blob.c (_keybox_create_x509_blob): Skip the leading
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index 1c78caedd..4a8a6fec5 100644
--- a/kbx/keybox-search.c
+++ b/kbx/keybox-search.c
@@ -106,6 +106,38 @@ blob_cmp_sn (KEYBOXBLOB blob, const unsigned char *sn, int snlen)
static int
+blob_cmp_fpr (KEYBOXBLOB blob, const unsigned char *fpr)
+{
+ const unsigned char *buffer;
+ size_t length;
+ size_t pos, off;
+ size_t nkeys, keyinfolen;
+ int idx;
+
+ buffer = _keybox_get_blob_image (blob, &length);
+ if (length < 40)
+ return 0; /* blob too short */
+
+ /*keys*/
+ nkeys = get16 (buffer + 16);
+ keyinfolen = get16 (buffer + 18 );
+ if (keyinfolen < 28)
+ return 0; /* invalid blob */
+ pos = 20;
+ if (pos + keyinfolen*nkeys > length)
+ return 0; /* out of bounds */
+
+ for (idx=0; idx < nkeys; idx++)
+ {
+ off = pos + idx*keyinfolen;
+ if (!memcmp (buffer + off, fpr, 20))
+ return 1; /* found */
+ }
+ return 0; /* not found */
+}
+
+
+static int
blob_cmp_name (KEYBOXBLOB blob, int idx, const char *name, size_t namelen)
{
const unsigned char *buffer;
@@ -267,7 +299,7 @@ has_long_kid (KEYBOXBLOB blob, u32 *kid)
static int
has_fingerprint (KEYBOXBLOB blob, const unsigned char *fpr)
{
- return 0;
+ return blob_cmp_fpr (blob, fpr);
}