From df3098367cd4e17411310bece45fc2991a90b039 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 13 Oct 2004 18:28:39 +0000 Subject: [PATCH] Make directories get generated properly again; debug key lookup. Also, it is hard to find entries in a table when you never put them there. svn:r2462 --- src/or/config.c | 2 ++ src/or/routerlist.c | 1 + src/or/routerparse.c | 14 +++++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index 72ef2d5e16..27d133e1ab 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1096,6 +1096,8 @@ static int parse_dir_server_line(const char *line) log_fn(LOG_WARN, "Unable to decode DirServer key digest."); goto err; } + log_fn(LOG_DEBUG, "Trusted dirserver at %s:%d (%s)", address,(int)port, + (char*)smartlist_get(items,1)); add_trusted_dir_server(address, port, digest); r = 0; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1bcaeb4ee2..a3aa231820 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1159,6 +1159,7 @@ void add_trusted_dir_server(const char *addr, uint16_t port, const char *digest) ent->dir_port = port; ent->is_running = 1; memcpy(ent->digest, digest, DIGEST_LEN); + smartlist_add(trusted_dir_servers, ent); } static void clear_trusted_dir_servers(void) diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 2f63139d3b..b29f835794 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -610,6 +610,8 @@ static int check_directory_signature(const char *digest, { char signed_digest[PK_BYTES]; routerinfo_t *r; + crypto_pk_env_t *_pkey = NULL; + if (tok->n_args != 1) { log_fn(LOG_WARN, "Too many or too few arguments to directory-signature"); @@ -618,14 +620,16 @@ static int check_directory_signature(const char *digest, if (declared_key) { if (dir_signing_key_is_trusted(declared_key)) - pkey = declared_key; - } else { + _pkey = declared_key; + } + if (!_pkey) { r = router_get_by_nickname(tok->args[0]); log_fn(LOG_DEBUG, "Got directory signed by %s", tok->args[0]); if (r && r->is_trusted_dir) { - pkey = r->identity_pkey; + _pkey = r->identity_pkey; } else if (!r && pkey) { /* pkey provided for debugging purposes. */ + _pkey = pkey; } else if (!r) { log_fn(LOG_WARN, "Directory was signed by unrecognized server %s", tok->args[0]); @@ -642,9 +646,9 @@ static int check_directory_signature(const char *digest, return -1; } - tor_assert(pkey); + tor_assert(_pkey); - if (crypto_pk_public_checksig(pkey, tok->object_body, 128, signed_digest) + if (crypto_pk_public_checksig(_pkey, tok->object_body, 128, signed_digest) != 20) { log_fn(LOG_WARN, "Error reading directory: invalid signature."); return -1;