From: Jonathan McDowell Date: Mon, 31 May 2004 23:47:48 +0000 (+0000) Subject: cscvs to tla changeset 86 X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/bff92fa7e9583ebaa3de745aba04c66b132c849e?hp=576754568dc383e78065e88e05eeb2d078524f9c cscvs to tla changeset 86 Author: noodles Date: 2003/06/08 21:11:00 First attempt at supporting revoked keys. --- diff --git a/keydb.c b/keydb.c index 347b406..1eb9def 100644 --- 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 b356bb8..ea4a789 100644 --- 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. diff --git a/keydb_pg.c b/keydb_pg.c index c643a79..cdfbe63 100644 --- a/keydb_pg.c +++ b/keydb_pg.c @@ -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 @@ -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; } diff --git a/keyindex.c b/keyindex.c index 6593224..464a7ba 100644 --- a/keyindex.c +++ b/keyindex.c @@ -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 @@ -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) { diff --git a/keystructs.h b/keystructs.h index 42f0971..24799eb 100644 --- a/keystructs.h +++ b/keystructs.h @@ -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 6a61879..108b8cc 100644 --- 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 @@ -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 =