[or-cvs] start generating new version of introduce1 cells

Roger Dingledine arma at seul.org
Sun Oct 24 19:08:10 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	rendclient.c rendmid.c rendservice.c 
Log Message:
start generating new version of introduce1 cells


Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendclient.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- rendclient.c	16 Oct 2004 22:14:52 -0000	1.57
+++ rendclient.c	24 Oct 2004 19:08:07 -0000	1.58
@@ -56,7 +56,7 @@
   size_t payload_len;
   int r;
   char payload[RELAY_PAYLOAD_SIZE];
-  char tmp[(MAX_NICKNAME_LEN+1)+REND_COOKIE_LEN+DH_KEY_LEN];
+  char tmp[1+(MAX_HEX_NICKNAME_LEN+1)+REND_COOKIE_LEN+DH_KEY_LEN];
   rend_cache_entry_t *entry;
   crypt_path_t *cpath;
 
@@ -92,17 +92,20 @@
   }
 
   /* write the remaining items into tmp */
-  strncpy(tmp, rendcirc->build_state->chosen_exit_name, (MAX_NICKNAME_LEN+1)); /* nul pads */
-  memcpy(tmp+MAX_NICKNAME_LEN+1, rendcirc->rend_cookie, REND_COOKIE_LEN);
+  tmp[0] = 1; /* version 1 of the cell format */
+  strncpy(tmp+1, rendcirc->build_state->chosen_exit_name, (MAX_HEX_NICKNAME_LEN+1)); /* nul pads */
+  memcpy(tmp+1+MAX_HEX_NICKNAME_LEN+1, rendcirc->rend_cookie, REND_COOKIE_LEN);
   if (crypto_dh_get_public(cpath->handshake_state,
-                           tmp+MAX_NICKNAME_LEN+1+REND_COOKIE_LEN,
+                           tmp+1+MAX_HEX_NICKNAME_LEN+1+REND_COOKIE_LEN,
                            DH_KEY_LEN)<0) {
     log_fn(LOG_WARN, "Couldn't extract g^x");
     goto err;
   }
 
+  /*XXX maybe give crypto_pk_public_hybrid_encrypt a max_len arg,
+   * to avoid buffer overflows? */
   r = crypto_pk_public_hybrid_encrypt(entry->parsed->pk, tmp,
-                           MAX_NICKNAME_LEN+1+REND_COOKIE_LEN+DH_KEY_LEN,
+                           1+MAX_HEX_NICKNAME_LEN+1+REND_COOKIE_LEN+DH_KEY_LEN,
                                       payload+DIGEST_LEN,
                                       PK_PKCS1_OAEP_PADDING, 0);
   if (r<0) {

Index: rendmid.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendmid.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- rendmid.c	14 Oct 2004 03:18:14 -0000	1.27
+++ rendmid.c	24 Oct 2004 19:08:07 -0000	1.28
@@ -122,6 +122,8 @@
     goto err;
   }
 
+/* change MAX_NICKNAME_LEN to MAX_HEX_NICKNAME_LEN when 0.0.8.1 and
+ * 0.0.9pre3-4 are obsolete. */
   if (request_len < (DIGEST_LEN+(MAX_NICKNAME_LEN+1)+REND_COOKIE_LEN+
                      DH_KEY_LEN+CIPHER_KEY_LEN+PKCS1_OAEP_PADDING_OVERHEAD)) {
     log_fn(LOG_WARN,
@@ -153,7 +155,7 @@
     log_fn(LOG_WARN, "Unable to send INTRODUCE2 cell to OP.");
     goto err;
   }
-  /* And sent an ack down the cirecuit.  Empty body->succeeded. */
+  /* And sent an ack down Alice's circuit.  Empty body means succeeded. */
   if (connection_edge_send_command(NULL,circ,RELAY_COMMAND_INTRODUCE_ACK,
                                    NULL,0,NULL)) {
     log_fn(LOG_WARN, "Unable to send INTRODUCE_ACK cell to OP.");

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- rendservice.c	16 Oct 2004 22:14:52 -0000	1.92
+++ rendservice.c	24 Oct 2004 19:08:07 -0000	1.93
@@ -400,13 +400,15 @@
   len = r;
   if (*buf == 1) {
     rp_nickname = buf+1;
-    nickname_field_len = HEX_DIGEST_LEN+2;
+    nickname_field_len = MAX_HEX_NICKNAME_LEN+1;
     version = 1;
   } else {
     nickname_field_len = MAX_NICKNAME_LEN+1;
     rp_nickname = buf;
     version = 0;
   }
+  /* XXX when 0.0.8.1 and 0.0.9pre3-4 are obsolete, change this to
+   * reject version != 1. */
   ptr=memchr(rp_nickname,0,nickname_field_len);
   if (!ptr || ptr == rp_nickname) {
     log_fn(LOG_WARN, "Couldn't find a null-padded nickname in INTRODUCE2 cell");



More information about the tor-commits mailing list