2 * maxpath.c - Find the longest trust path in the key database.
4 * Jonathan McDowell <noodles@earth.li>
6 * Copyright 2001-2002 Project Purple.
17 #include "onak-conf.h"
20 void findmaxpath(unsigned long max)
22 struct stats_key *from, *to, *tmp;
24 unsigned long distance, loop;
27 from = to = tmp = NULL;
30 * My (noodles@earth.li, DSA) key is in the strongly connected set of
31 * keys, so we use it as a suitable starting seed.
33 cached_getkeysigs(0xF1BD4BE45B430367);
36 * Loop through the hash examining each key present and finding the
37 * furthest key from it. If it's further than our current max then
38 * store it as our new max and print out the fact we've found a new
41 for (loop = 0; (loop < HASHSIZE) && (distance < max); loop++) {
42 curkey = gethashtableentry(loop);
43 while (curkey != NULL && distance < max) {
44 cached_getkeysigs(((struct stats_key *)
45 curkey->object)->keyid);
47 tmp = furthestkey((struct stats_key *)
49 if (tmp->colour > distance) {
50 from = (struct stats_key *)curkey->object;
52 distance = to->colour;
53 printf("Current max path (#%ld) is from %llX"
54 " to %llX (%ld steps)\n",
63 printf("Max path is from %llX to %llX (%ld steps)\n",
67 dofindpath(to->keyid, from->keyid, false, 1);
70 int main(int argc, char *argv[])