Browse Source

Rename handshake_digest to rend_circ_nonce

The handshake_digest field was never meaningfully a digest *of* the
handshake, but rather is a digest *from* the handshake that we exapted
to prevent replays of ESTABLISH_INTRO cells.  The ntor handshake will
generate it as more key material rather than taking it from any part
of the circuit handshake reply..
Nick Mathewson 12 years ago
parent
commit
18c7d3f157
4 changed files with 11 additions and 12 deletions
  1. 3 3
      src/or/circuitbuild.c
  2. 3 4
      src/or/or.h
  3. 2 2
      src/or/rendmid.c
  4. 3 3
      src/or/rendservice.c

+ 3 - 3
src/or/circuitbuild.c

@@ -1409,7 +1409,7 @@ circuit_finish_handshake(origin_circuit_t *circ, uint8_t reply_type,
                                     &hop->handshake_state,
                                     &hop->handshake_state,
                                     reply,
                                     reply,
                                     (uint8_t*)keys, sizeof(keys),
                                     (uint8_t*)keys, sizeof(keys),
-                                    (uint8_t*)hop->handshake_digest) < 0) {
+                                    (uint8_t*)hop->rend_circ_nonce) < 0) {
       log_warn(LD_CIRC,"onion_skin_client_handshake failed.");
       log_warn(LD_CIRC,"onion_skin_client_handshake failed.");
       return -END_CIRC_REASON_TORPROTOCOL;
       return -END_CIRC_REASON_TORPROTOCOL;
     }
     }
@@ -1517,9 +1517,9 @@ onionskin_answer(or_circuit_t *circ, uint8_t cell_type, const char *payload,
 
 
   /* XXXX Move responsibility for extracting this. */
   /* XXXX Move responsibility for extracting this. */
   if (cell_type == CELL_CREATED)
   if (cell_type == CELL_CREATED)
-    memcpy(circ->handshake_digest, cell.payload+DH_KEY_LEN, DIGEST_LEN);
+    memcpy(circ->rend_circ_nonce, cell.payload+DH_KEY_LEN, DIGEST_LEN);
   else
   else
-    memcpy(circ->handshake_digest, cell.payload+DIGEST_LEN, DIGEST_LEN);
+    memcpy(circ->rend_circ_nonce, cell.payload+DIGEST_LEN, DIGEST_LEN);
 
 
   circ->is_first_hop = (cell_type == CELL_CREATED_FAST);
   circ->is_first_hop = (cell_type == CELL_CREATED_FAST);
 
 

+ 3 - 4
src/or/or.h

@@ -2568,8 +2568,7 @@ typedef struct crypt_path_t {
   crypto_dh_t *rend_dh_handshake_state;
   crypto_dh_t *rend_dh_handshake_state;
 
 
   /** Negotiated key material shared with the OR at this step. */
   /** Negotiated key material shared with the OR at this step. */
-  /* XXXX RENAME */
-  char handshake_digest[DIGEST_LEN];/* KH in tor-spec.txt */
+  char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
 
 
   /** Information to extend to the OR at this step. */
   /** Information to extend to the OR at this step. */
   extend_info_t *extend_info;
   extend_info_t *extend_info;
@@ -2978,8 +2977,8 @@ typedef struct or_circuit_t {
   char rend_token[REND_TOKEN_LEN];
   char rend_token[REND_TOKEN_LEN];
 
 
   /* ???? move to a subtype or adjunct structure? Wastes 20 bytes -NM */
   /* ???? move to a subtype or adjunct structure? Wastes 20 bytes -NM */
-  /* XXXX rename this. */
-  char handshake_digest[DIGEST_LEN]; /**< Stores KH for the handshake. */
+  /** Stores KH for the handshake. */
+  char rend_circ_nonce[DIGEST_LEN];/* KH in tor-spec.txt */
 
 
   /** How many more relay_early cells can we send on this circuit, according
   /** How many more relay_early cells can we send on this circuit, according
    * to the specification? */
    * to the specification? */

+ 2 - 2
src/or/rendmid.c

@@ -56,8 +56,8 @@ rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
     goto err;
     goto err;
   }
   }
 
 
-  /* Next 20 bytes: Hash of handshake_digest | "INTRODUCE" */
-  memcpy(buf, circ->handshake_digest, DIGEST_LEN);
+  /* Next 20 bytes: Hash of rend_circ_nonce | "INTRODUCE" */
+  memcpy(buf, circ->rend_circ_nonce, DIGEST_LEN);
   memcpy(buf+DIGEST_LEN, "INTRODUCE", 9);
   memcpy(buf+DIGEST_LEN, "INTRODUCE", 9);
   if (crypto_digest(expected_digest, buf, DIGEST_LEN+9) < 0) {
   if (crypto_digest(expected_digest, buf, DIGEST_LEN+9) < 0) {
     log_warn(LD_BUG, "Internal error computing digest.");
     log_warn(LD_BUG, "Internal error computing digest.");

+ 3 - 3
src/or/rendservice.c

@@ -1382,7 +1382,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   dh = NULL;
   dh = NULL;
   if (circuit_init_cpath_crypto(cpath,keys+DIGEST_LEN,1)<0)
   if (circuit_init_cpath_crypto(cpath,keys+DIGEST_LEN,1)<0)
     goto err;
     goto err;
-  memcpy(cpath->handshake_digest, keys, DIGEST_LEN);
+  memcpy(cpath->rend_circ_nonce, keys, DIGEST_LEN);
 
 
   goto done;
   goto done;
 
 
@@ -2483,7 +2483,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
   len = r;
   len = r;
   set_uint16(buf, htons((uint16_t)len));
   set_uint16(buf, htons((uint16_t)len));
   len += 2;
   len += 2;
-  memcpy(auth, circuit->cpath->prev->handshake_digest, DIGEST_LEN);
+  memcpy(auth, circuit->cpath->prev->rend_circ_nonce, DIGEST_LEN);
   memcpy(auth+DIGEST_LEN, "INTRODUCE", 9);
   memcpy(auth+DIGEST_LEN, "INTRODUCE", 9);
   if (crypto_digest(buf+len, auth, DIGEST_LEN+9))
   if (crypto_digest(buf+len, auth, DIGEST_LEN+9))
     goto err;
     goto err;
@@ -2630,7 +2630,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
     reason = END_CIRC_REASON_INTERNAL;
     reason = END_CIRC_REASON_INTERNAL;
     goto err;
     goto err;
   }
   }
-  memcpy(buf+REND_COOKIE_LEN+DH_KEY_LEN, hop->handshake_digest,
+  memcpy(buf+REND_COOKIE_LEN+DH_KEY_LEN, hop->rend_circ_nonce,
          DIGEST_LEN);
          DIGEST_LEN);
 
 
   /* Send the cell */
   /* Send the cell */