mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
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.
This commit is contained in:
parent
a8eccb6363
commit
e1d31f2a2f
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user