[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Remove onion_pkey from connection, since onion keys can cha...



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv2339/src/or

Modified Files:
	circuit.c connection.c connection_or.c dirserv.c onion.c or.h 
	router.c routerlist.c 
Log Message:
Remove onion_pkey from connection, since onion keys can change more often than connections. Also add more log messages

Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -d -r1.217 -r1.218
--- circuit.c	18 Apr 2004 09:27:05 -0000	1.217
+++ circuit.c	25 Apr 2004 19:04:11 -0000	1.218
@@ -1485,7 +1485,14 @@
     cell.command = CELL_CREATE;
     cell.circ_id = circ->n_circ_id;
 
-    if(onion_skin_create(circ->n_conn->onion_pkey,
+    router = router_get_by_nickname(circ->n_conn->nickname);
+    if (!router) {
+      log_fn(LOG_WARN,"Couldn't find routerinfo for %s",
+             circ->n_conn->nickname);
+      return -1;
+    }
+
+    if(onion_skin_create(router->onion_pkey,
                          &(circ->cpath->handshake_state),
                          cell.payload) < 0) {
       log_fn(LOG_WARN,"onion_skin_create (first hop) failed.");

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -d -r1.197 -r1.198
--- connection.c	25 Apr 2004 04:49:11 -0000	1.197
+++ connection.c	25 Apr 2004 19:04:11 -0000	1.198
@@ -114,8 +114,6 @@
       tor_tls_free(conn->tls);
   }
 
-  if (conn->onion_pkey)
-    crypto_free_pk_env(conn->onion_pkey);
   if (conn->identity_pkey)
     crypto_free_pk_env(conn->identity_pkey);
   tor_free(conn->nickname);
@@ -819,7 +817,7 @@
     conn = carray[i];
     assert(conn);
     if(connection_state_is_open(conn) &&
-       !crypto_pk_cmp_keys(conn->onion_pkey, router->onion_pkey)) {
+       !crypto_pk_cmp_keys(conn->identity_pkey, router->identity_pkey)) {
       log(LOG_DEBUG,"connection_twin_get_by_addr_port(): Found twin (%s).",conn->address);
       return conn;
     }

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- connection_or.c	24 Apr 2004 22:40:32 -0000	1.97
+++ connection_or.c	25 Apr 2004 19:04:11 -0000	1.98
@@ -83,7 +83,6 @@
   conn->addr = router->addr;
   conn->port = router->or_port;
   conn->receiver_bucket = conn->bandwidth = router->bandwidthburst;
-  conn->onion_pkey = crypto_pk_dup_key(router->onion_pkey);
   conn->identity_pkey = crypto_pk_dup_key(router->identity_pkey);
   conn->nickname = tor_strdup(router->nickname);
   tor_free(conn->address);

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- dirserv.c	24 Apr 2004 22:17:50 -0000	1.38
+++ dirserv.c	25 Apr 2004 19:04:11 -0000	1.39
@@ -284,9 +284,11 @@
       return 1;
     }
     /* We don't have a newer one; we'll update this one. */
+    log_fn(LOG_INFO,"Dirserv updating desc for nickname %s",ri->nickname);
     free_descriptor_entry(*desc_ent_ptr);
   } else {
     /* Add this at the end. */
+    log_fn(LOG_INFO,"Dirserv adding desc for nickname %s",ri->nickname);
     desc_ent_ptr = &descriptor_list[n_descriptors++];
     /* XXX check if n_descriptors is too big */
   }

Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- onion.c	24 Apr 2004 22:17:50 -0000	1.156
+++ onion.c	25 Apr 2004 19:04:11 -0000	1.157
@@ -402,8 +402,9 @@
 
   n = smartlist_len(routers);
   for(i=0;i<n;i++) {
-    log_fn(LOG_DEBUG,"Contemplating whether router %d is a new option...",i);
     r = smartlist_get(routers, i);
+    log_fn(LOG_DEBUG,"Contemplating whether router %d (%s) is a new option...",
+           i, r->nickname);
     if(r->is_running == 0) {
       log_fn(LOG_DEBUG,"Nope, the directory says %d is not running.",i);
       goto next_i_loop;
@@ -426,7 +427,7 @@
     num++;
     log_fn(LOG_DEBUG,"I like %d. num_acceptable_routers now %d.",i, num);
     next_i_loop:
-      ; /* our compiler may need an explicit statement after the label */
+      ; /* C requires an explicit statement after the label */
   }
 
   return num;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.323
retrieving revision 1.324
diff -u -d -r1.323 -r1.324
--- or.h	24 Apr 2004 22:17:50 -0000	1.323
+++ or.h	25 Apr 2004 19:04:11 -0000	1.324
@@ -383,7 +383,6 @@
   char *address; /* FQDN (or IP) of the guy on the other end.
                   * strdup into this, because free_connection frees it
                   */
-  crypto_pk_env_t *onion_pkey; /* public RSA key for the other side's onions */
   crypto_pk_env_t *identity_pkey; /* public RSA key for the other side's signing */
   char *nickname;
 

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- router.c	25 Apr 2004 05:19:03 -0000	1.30
+++ router.c	25 Apr 2004 19:04:11 -0000	1.31
@@ -73,6 +73,7 @@
     crypto_free_pk_env(lastonionkey);
   /* XXXX WINDOWS on windows, we need to protect this next bit with a lock.
    */
+  log_fn(LOG_INFO, "Rotating onion key");
   lastonionkey = onionkey;
   set_onion_key(prkey);
   return;

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- routerlist.c	24 Apr 2004 22:50:09 -0000	1.62
+++ routerlist.c	25 Apr 2004 19:04:11 -0000	1.63
@@ -395,6 +395,20 @@
 
 /* ------------------------------------------------------------ */
 
+static void dump_onion_keys(int severity)
+{
+  int i;
+  char buf[FINGERPRINT_LEN+1];
+  routerinfo_t *r;
+
+  log_fn(severity, "Parsed a directory.  Here are the onion keys:");
+  for (i = 0; i < smartlist_len(routerlist->routers); i++) {
+    r = smartlist_get(routerlist->routers, i);
+    crypto_pk_get_fingerprint(r->onion_pkey, buf);
+    log_fn(severity, "%10s: %s", r->nickname, buf);
+  }
+}
+
 /* Replace the current router list with the one stored in 'routerfile'. */
 int router_set_routerlist_from_file(char *routerfile)
 {
@@ -411,6 +425,7 @@
     free(string);
     return -1;
   }
+  /* dump_onion_keys(LOG_NOTICE); */
 
   free(string);
   return 0;
@@ -429,6 +444,8 @@
     log(LOG_WARN, "Error resolving routerlist");
     return -1;
   }
+  /* dump_onion_keys(LOG_NOTICE); */
+
   return 0;
 }
 
@@ -496,6 +513,7 @@
       exit(0);
     }
   }
+  /* dump_onion_keys(LOG_NOTICE); */
   return 0;
 }
 
@@ -879,6 +897,7 @@
   *dest = tor_malloc(sizeof(routerlist_t));
   (*dest)->routers = routers;
   (*dest)->software_versions = NULL;
+
   return 0;
 }