2 * maxpath.c - Find the longest trust path in the key database.
4 * Copyright 2001-2002 Jonathan McDowell <noodles@earth.li>
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #include "onak-conf.h"
32 void findmaxpath(unsigned long max)
34 struct stats_key *from, *to, *tmp;
36 unsigned long distance, loop;
39 from = to = tmp = NULL;
42 * My (noodles@earth.li, RSA) key is in the strongly connected set of
43 * keys, so we use it as a suitable starting seed.
45 config.dbbackend->cached_getkeysigs(0x94FA372B2DA8B985);
48 * Loop through the hash examining each key present and finding the
49 * furthest key from it. If it's further than our current max then
50 * store it as our new max and print out the fact we've found a new
53 for (loop = 0; (loop < HASHSIZE) && (distance < max); loop++) {
54 curkey = gethashtableentry(loop);
55 while (curkey != NULL && distance < max) {
56 config.dbbackend->cached_getkeysigs(
58 curkey->object)->keyid);
60 tmp = furthestkey((struct stats_key *)
62 if (tmp->colour > distance) {
63 from = (struct stats_key *)curkey->object;
65 distance = to->colour;
66 printf("Current max path (#%ld) is from %"
77 printf("Max path is from %" PRIX64 " to %" PRIX64 " (%ld steps)\n",
81 dofindpath(to->keyid, from->keyid, false, 1);
84 int main(int argc, char *argv[])
87 initlogthing("maxpath", config.logfile);
88 config.dbbackend->initdb(true);
94 config.dbbackend->cleanupdb();