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

[tor-commits] [tor/master] Update the consdiff directory code based on #22143 fixes



commit e1d31f2a2f5c7810c9c34ffa57e4b86ec8fd860b
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu May 4 08:49:02 2017 -0400

    Update the consdiff directory code based on #22143 fixes
    
    These are mostly just identifier renames, except for one place in
    routerparse.c where we switch to using a correct hash.
---
 src/or/directory.c     | 4 ++--
 src/or/dirserv.c       | 5 ++---
 src/or/networkstatus.c | 2 +-
 src/or/or.h            | 7 ++++---
 src/or/routerparse.c   | 8 +++-----
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 1b37743..917dfee 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -517,7 +517,7 @@ dir_consensus_request_set_additional_headers(directory_request_t *req,
         ims_delay = (v->fresh_until - v->valid_after)/2;
       }
       if_modified_since = v->valid_after + ims_delay;
-      memcpy(or_diff_from, v->digest_full_sha3, DIGEST256_LEN);
+      memcpy(or_diff_from, v->digest_sha3_as_signed, DIGEST256_LEN);
       or_diff_from_is_set = 1;
     }
   } else {
@@ -528,7 +528,7 @@ dir_consensus_request_set_additional_headers(directory_request_t *req,
      * unparsed consensus, so we use the default. */
     if (cd) {
       if_modified_since = cd->published + DEFAULT_IF_MODIFIED_SINCE_DELAY;
-      memcpy(or_diff_from, cd->digest_sha3_full, DIGEST256_LEN);
+      memcpy(or_diff_from, cd->digest_sha3_as_signed, DIGEST256_LEN);
       or_diff_from_is_set = 1;
     }
   }
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index af7ec97..7de72df 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1212,8 +1212,7 @@ void
 dirserv_set_cached_consensus_networkstatus(const char *networkstatus,
                                            const char *flavor_name,
                                            const common_digests_t *digests,
-                                           // XXXX rename after 22143
-                                           const uint8_t *sha3_full_digest,
+                                           const uint8_t *sha3_as_signed,
                                            time_t published)
 {
   cached_dir_t *new_networkstatus;
@@ -1223,7 +1222,7 @@ dirserv_set_cached_consensus_networkstatus(const char *networkstatus,
 
   new_networkstatus = new_cached_dir(tor_strdup(networkstatus), published);
   memcpy(&new_networkstatus->digests, digests, sizeof(common_digests_t));
-  memcpy(&new_networkstatus->digest_sha3_full, sha3_full_digest,
+  memcpy(&new_networkstatus->digest_sha3_as_signed, sha3_as_signed,
          DIGEST256_LEN);
   old_networkstatus = strmap_set(cached_consensuses, flavor_name,
                                  new_networkstatus);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 18537a3..1b21dd7 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -2002,7 +2002,7 @@ networkstatus_set_current_consensus(const char *consensus,
     dirserv_set_cached_consensus_networkstatus(consensus,
                                                flavor,
                                                &c->digests,
-                                               c->digest_full_sha3,
+                                               c->digest_sha3_as_signed,
                                                c->valid_after);
     if (server_mode(get_options())) {
       consdiffmgr_add_consensus(consensus, c);
diff --git a/src/or/or.h b/src/or/or.h
index b69fcf1..423f66c 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1938,7 +1938,8 @@ typedef struct cached_dir_t {
   size_t dir_z_len; /**< Length of <b>dir_z</b>. */
   time_t published; /**< When was this object published. */
   common_digests_t digests; /**< Digests of this object (networkstatus only) */
-  uint8_t digest_sha3_full[DIGEST256_LEN]; /**< sha3 digest (also ns only) */
+  /** Sha3 digest (also ns only) */
+  uint8_t digest_sha3_as_signed[DIGEST256_LEN];
   int refcnt; /**< Reference count for this cached_dir_t. */
 } cached_dir_t;
 
@@ -2639,9 +2640,9 @@ typedef struct networkstatus_t {
 
   /** Digests of this document, as signed. */
   common_digests_t digests;
-  /** A SHA3-256 digest of the document, including signatures: used for
+  /** A SHA3-256 digest of the document, not including signatures: used for
    * consensus diffs */
-  uint8_t digest_full_sha3[DIGEST256_LEN];
+  uint8_t digest_sha3_as_signed[DIGEST256_LEN];
 
   /** List of router statuses, sorted by identity digest.  For a vote,
    * the elements are vote_routerstatus_t; for a consensus, the elements
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 4def75a..fa79cf7 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -3384,7 +3384,7 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
   networkstatus_voter_info_t *voter = NULL;
   networkstatus_t *ns = NULL;
   common_digests_t ns_digests;
-  uint8_t sha3_full[DIGEST256_LEN];
+  uint8_t sha3_as_signed[DIGEST256_LEN];
   const char *cert, *end_of_header, *end_of_footer, *s_dup = s;
   directory_token_t *tok;
   struct in_addr in;
@@ -3398,10 +3398,8 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
   if (eos_out)
     *eos_out = NULL;
 
-  // XXXX replace SHA3_full with as_signed digest once #22143 is merged.
-  // XXXX Merge #22143 before this!
   if (router_get_networkstatus_v3_hashes(s, &ns_digests) ||
-      crypto_digest256((char *)sha3_full, s, strlen(s), DIGEST_SHA3_256)<0) {
+      router_get_networkstatus_v3_sha3_as_signed(sha3_as_signed, s)<0) {
     log_warn(LD_DIR, "Unable to compute digest of network-status");
     goto err;
   }
@@ -3418,7 +3416,7 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
 
   ns = tor_malloc_zero(sizeof(networkstatus_t));
   memcpy(&ns->digests, &ns_digests, sizeof(ns_digests));
-  memcpy(&ns->digest_full_sha3, sha3_full, sizeof(sha3_full));
+  memcpy(&ns->digest_sha3_as_signed, sha3_as_signed, sizeof(sha3_as_signed));
 
   tok = find_by_keyword(tokens, K_NETWORK_STATUS_VERSION);
   tor_assert(tok);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits