cscvs to tla changeset 86
authorJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:48 +0000 (23:47 +0000)
committerJonathan McDowell <noodles@earth.li>
Mon, 31 May 2004 23:47:48 +0000 (23:47 +0000)
Author: noodles
Date: 2003/06/08 21:11:00
First attempt at supporting revoked keys.

keydb.c
keydb.h
keydb_pg.c
keyindex.c
keystructs.h
stats.c

diff --git a/keydb.c b/keydb.c
index 347b406bd7daf0a61fd23280132192bf7983567c..1eb9deff1edd1846d68993bb389ba6a375fbdb16 100644 (file)
--- a/keydb.c
+++ b/keydb.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb.c,v 1.9 2003/06/04 20:57:08 noodles Exp $
+ * $Id: keydb.c,v 1.10 2003/06/08 21:11:00 noodles Exp $
  */
 
 /**
@@ -63,11 +63,13 @@ char *keyid2uid(uint64_t keyid)
 /**
  *     getkeysigs - Gets a linked list of the signatures on a key.
  *     @keyid: The keyid to get the sigs for.
+ *     @revoked: Is the key revoked?
  *
  *     This function gets the list of signatures on a key. Used for key 
- *     indexing and doing stats bits.
+ *     indexing and doing stats bits. If revoked is non-NULL then if the key
+ *     is revoked it's set to true.
  */
-struct ll *getkeysigs(uint64_t keyid)
+struct ll *getkeysigs(uint64_t keyid, bool *revoked)
 {
        struct ll *sigs = NULL;
        struct openpgp_signedpacket_list *uids = NULL;
@@ -79,6 +81,9 @@ struct ll *getkeysigs(uint64_t keyid)
                for (uids = publickey->uids; uids != NULL; uids = uids->next) {
                        sigs = keysigs(sigs, uids->sigs);
                }
+               if (revoked != NULL) {
+                       *revoked = (publickey->revocations != NULL);
+               }
                free_publickey(publickey);
        }
 
@@ -99,6 +104,7 @@ struct ll *cached_getkeysigs(uint64_t keyid)
        struct stats_key *key = NULL;
        struct stats_key *signedkey = NULL;
        struct ll        *cursig = NULL;
+       bool              revoked = false;
 
        if (keyid == 0)  {
                return NULL;
@@ -107,7 +113,8 @@ struct ll *cached_getkeysigs(uint64_t keyid)
        key = createandaddtohash(keyid);
 
        if (key->gotsigs == false) {
-               key->sigs = getkeysigs(key->keyid);
+               key->sigs = getkeysigs(key->keyid, &revoked);
+               key->revoked = revoked;
                for (cursig = key->sigs; cursig != NULL;
                                cursig = cursig->next) {
                        signedkey = (struct stats_key *) cursig->object;
diff --git a/keydb.h b/keydb.h
index b356bb85380340b6d0f6f06aaa609c59587a0241..ea4a78999ce4b217f150ad22288f7c17ef27d29f 100644 (file)
--- a/keydb.h
+++ b/keydb.h
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb.h,v 1.8 2003/06/07 13:45:34 noodles Exp $
+ * $Id: keydb.h,v 1.9 2003/06/08 21:11:00 noodles Exp $
  */
 
 #ifndef __KEYDB_H__
@@ -110,11 +110,13 @@ char *keyid2uid(uint64_t keyid);
 /**
  *     getkeysigs - Gets a linked list of the signatures on a key.
  *     @keyid: The keyid to get the sigs for.
+ *     @revoked: Is the key revoked?
  *
  *     This function gets the list of signatures on a key. Used for key 
- *     indexing and doing stats bits.
+ *     indexing and doing stats bits. If revoked is non-NULL then if the key
+ *     is revoked it's set to true.
  */
-struct ll *getkeysigs(uint64_t keyid);
+struct ll *getkeysigs(uint64_t keyid, bool *revoked);
 
 /**
  *     cached_getkeysigs - Gets the signatures on a key.
index c643a79a57c38bd9e44305daec3af1a0282e6fee..cdfbe63d4fbeb8f6103c31aed7be56bad1e8823c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keydb_pg.c,v 1.11 2003/06/05 07:32:00 noodles Exp $
+ * $Id: keydb_pg.c,v 1.12 2003/06/08 21:11:01 noodles Exp $
  */
 
 #include <postgresql/libpq-fe.h>
@@ -504,11 +504,12 @@ char *keyid2uid(uint64_t keyid)
 /**
  *     getkeysigs - Gets a linked list of the signatures on a key.
  *     @keyid: The keyid to get the sigs for.
+ *     @revoked: If the key is revoked.
  *
  *     This function gets the list of signatures on a key. Used for key 
  *     indexing and doing stats bits.
  */
-struct ll *getkeysigs(uint64_t keyid)
+struct ll *getkeysigs(uint64_t keyid, bool *revoked)
 {
        struct ll *sigs = NULL;
        PGresult *result = NULL;
@@ -556,6 +557,16 @@ struct ll *getkeysigs(uint64_t keyid)
                result = PQexec(dbconn, "COMMIT");
                PQclear(result);
        }
+
+       /*
+        * TODO: What do we do about revocations? We don't have the details
+        * stored in a separate table, so we'd have to grab the key and decode
+        * it, which we're trying to avoid by having a signers table.
+        */
+       if (revoked != NULL) {
+               *revoked = false;
+       }
+       
        return sigs;
 }
 
index 6593224885df754e01d5c98ad68772c41e2633b5..464a7baaecd76d1eacbbb7726d2264851b265229 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keyindex.c,v 1.11 2003/06/08 19:04:32 noodles Exp $
+ * $Id: keyindex.c,v 1.12 2003/06/08 21:11:01 noodles Exp $
  */
 
 #include <assert.h>
@@ -227,7 +227,10 @@ int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint,
                        snprintf(buf, 1023, "%.*s",
                                (int) curuid->packet->length,
                                curuid->packet->data);
-                       printf("%s\n", (html) ? txt2html(buf) : buf);
+                       printf("%s%s\n", 
+                               (html) ? txt2html(buf) : buf,
+                               (keys->revocations == NULL) ? "" :
+                                       " *** REVOKED ***");
                        if (fingerprint) {
                                display_fingerprint(keys);
                        }
@@ -236,7 +239,9 @@ int key_index(struct openpgp_publickey *keys, bool verbose, bool fingerprint,
                        }
                        curuid = curuid->next;
                } else {
-                       putchar('\n');
+                       printf("%s\n", 
+                               (keys->revocations == NULL) ? "" :
+                                       "*** REVOKED ***");
                        if (fingerprint) {
                                display_fingerprint(keys);
                        }
@@ -272,8 +277,6 @@ int mrkey_index(struct openpgp_publickey *keys)
        size_t                                   fplength = 0;
        unsigned char                            fp[20];
 
-
-
        while (keys != NULL) {
                created_time = (keys->publickey->data[1] << 24) +
                                        (keys->publickey->data[2] << 16) +
@@ -306,10 +309,11 @@ int mrkey_index(struct openpgp_publickey *keys)
                                keys->publickey->data[0]);
                }
 
-               printf(":%d:%d:%ld::\n",
+               printf(":%d:%d:%ld::%s\n",
                        type,
                        length,
-                       created_time);
+                       created_time,
+                       (keys->revocations == NULL) ? "" : "r");
        
                for (curuid = keys->uids; curuid != NULL;
                         curuid = curuid->next) {
index 42f097118341b7a6b3e2e33263629243568c5817..24799eb5101ffdcb9dbf4de7d84c6f753dad4caf 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright 2002 Project Purple
  *
- * $Id: keystructs.h,v 1.6 2003/06/04 20:57:09 noodles Exp $
+ * $Id: keystructs.h,v 1.7 2003/06/08 21:11:01 noodles Exp $
  */
 
 #ifndef __KEYSTRUCTS_H__
@@ -90,6 +90,8 @@ struct openpgp_publickey {
  *     @parent: The key that lead us to this one for DFS/BFS.
  *     @sigs: A linked list of the signatures on this key.
  *     @gotsigs: A bool indicating if we've initialized the sigs element yet.
+ *     @disabled: If we shouldn't consider the key in calculations.
+ *     @revoked: If the key is revoked (and shouldn't be considered).
  */
 struct stats_key {
        uint64_t keyid;
@@ -99,6 +101,7 @@ struct stats_key {
        struct ll *signs;
        bool gotsigs;
        bool disabled;
+       bool revoked;
 };
 
 #endif /* __KEYSTRUCTS_H__ */
diff --git a/stats.c b/stats.c
index 6a61879814b5c88b674d8982e5ed47cf92bc9ccd..108b8cc9a778b774a20a0e452df61f65d0a9b55b 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -5,7 +5,7 @@
  *
  * Copyright 2000-2002 Project Purple
  *
- * $Id: stats.c,v 1.11 2003/06/04 22:32:56 noodles Exp $
+ * $Id: stats.c,v 1.12 2003/06/08 21:11:01 noodles Exp $
  */
 
 #include <stdio.h>
@@ -77,6 +77,7 @@ unsigned long findpath(struct stats_key *have, struct stats_key *want)
                         * it and add its sigs to the list we want to look at.
                         */
                        if (!((struct stats_key *)sigs->object)->disabled &&
+                           !((struct stats_key *)sigs->object)->revoked &&
                            ((struct stats_key *)sigs->object)->colour == 0) {
                                count++;
                                ((struct stats_key *)sigs->object)->colour =