2 * maxpath.c - Find the longest trust path in the key database.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2001-2002 Project Purple.
18 #include "onak-conf.h"
21 void findmaxpath(unsigned long max)
23 struct stats_key *from, *to, *tmp;
25 unsigned long distance, loop;
28 from = to = tmp = NULL;
31 * My (noodles@earth.li, DSA) key is in the strongly connected set of
32 * keys, so we use it as a suitable starting seed.
34 config.dbbackend->cached_getkeysigs(0xF1BD4BE45B430367);
37 * Loop through the hash examining each key present and finding the
38 * furthest key from it. If it's further than our current max then
39 * store it as our new max and print out the fact we've found a new
42 for (loop = 0; (loop < HASHSIZE) && (distance < max); loop++) {
43 curkey = gethashtableentry(loop);
44 while (curkey != NULL && distance < max) {
45 config.dbbackend->cached_getkeysigs(
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 %"
66 printf("Max path is from %" PRIx64 " to %" PRIx64 " (%ld steps)\n",
70 dofindpath(to->keyid, from->keyid, false, 1);
73 int main(int argc, char *argv[])
76 initlogthing("maxpath", config.logfile);
77 config.dbbackend->initdb(true);
83 config.dbbackend->cleanupdb();