Browse Source

start generating new version of introduce1 cells

svn:r2586
Roger Dingledine 19 years ago
parent
commit
defe1e5f3c
3 changed files with 14 additions and 7 deletions
  1. 8 5
      src/or/rendclient.c
  2. 3 1
      src/or/rendmid.c
  3. 3 1
      src/or/rendservice.c

+ 8 - 5
src/or/rendclient.c

@@ -56,7 +56,7 @@ rend_client_send_introduction(circuit_t *introcirc, circuit_t *rendcirc) {
   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 @@ rend_client_send_introduction(circuit_t *introcirc, circuit_t *rendcirc) {
   }
 
   /* 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) {

+ 3 - 1
src/or/rendmid.c

@@ -122,6 +122,8 @@ rend_mid_introduce(circuit_t *circ, const char *request, size_t request_len)
     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 @@ rend_mid_introduce(circuit_t *circ, const char *request, size_t request_len)
     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.");

+ 3 - 1
src/or/rendservice.c

@@ -400,13 +400,15 @@ rend_service_introduce(circuit_t *circuit, const char *request, size_t request_l
   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");