2 * maxpath.c - Find the longest trust path in the key database.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2001-2002 Project Purple.
8 * $Id: maxpath.c,v 1.9 2003/06/04 20:57:10 noodles Exp $
19 #include "onak-conf.h"
22 void findmaxpath(unsigned long max)
24 struct stats_key *from, *to, *tmp;
26 unsigned long distance, loop;
29 from = to = tmp = NULL;
32 * My (noodles@earth.li, DSA) key is in the strongly connected set of
33 * keys, so we use it as a suitable starting seed.
35 cached_getkeysigs(0xF1BD4BE45B430367);
38 * Loop through the hash examining each key present and finding the
39 * furthest key from it. If it's further than our current max then
40 * store it as our new max and print out the fact we've found a new
43 for (loop = 0; (loop < HASHSIZE) && (distance < max); loop++) {
44 curkey = gethashtableentry(loop);
45 while (curkey != NULL && distance < max) {
46 cached_getkeysigs(((struct stats_key *)
47 curkey->object)->keyid);
49 tmp = furthestkey((struct stats_key *)
51 if (tmp->colour > distance) {
52 from = (struct stats_key *)curkey->object;
54 distance = to->colour;
55 printf("Current max path (#%ld) is from %llX"
56 " to %llX (%ld steps)\n",
65 printf("Max path is from %llX to %llX (%ld steps)\n",
69 dofindpath(to->keyid, from->keyid, false, 1);
72 int main(int argc, char *argv[])