ns: Move dirvote_get_voter_sig_by_alg() to networkstatus.c

It makes more sense to be in networkstatus.c so move it there and rename it
with the "networkstatus_" prefix.

Part of #25988

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2018-05-01 10:59:10 -04:00
parent afd4fc689a
commit 098b7fe25b
6 changed files with 20 additions and 20 deletions

View File

@ -2516,7 +2516,7 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
continue;
}
old_sig = dirvote_get_voter_sig_by_alg(target_voter, sig->alg);
old_sig = networkstatus_get_voter_sig_by_alg(target_voter, sig->alg);
/* If the target already has a good signature from this voter, then skip
* this one. */

View File

@ -179,17 +179,3 @@ dirvote_recalculate_timing(const or_options_t *options, time_t now)
voting_schedule_free(new_voting_schedule);
}
/** Return the signature made by <b>voter</b> using the algorithm
* <b>alg</b>, or NULL if none is found. */
document_signature_t *
dirvote_get_voter_sig_by_alg(const networkstatus_voter_info_t *voter,
digest_algorithm_t alg)
{
if (!voter->sigs)
return NULL;
SMARTLIST_FOREACH(voter->sigs, document_signature_t *, sig,
if (sig->alg == alg)
return sig);
return NULL;
}

View File

@ -58,9 +58,5 @@ time_t dirvote_get_start_of_next_interval(time_t now,
int offset);
time_t dirvote_get_next_valid_after_time(void);
document_signature_t *dirvote_get_voter_sig_by_alg(
const networkstatus_voter_info_t *voter,
digest_algorithm_t alg);
#endif /* TOR_DIRVOTE_COMMON_H */

View File

@ -390,6 +390,20 @@ networkstatus_get_voter_by_id(networkstatus_t *vote,
return NULL;
}
/** Return the signature made by <b>voter</b> using the algorithm
* <b>alg</b>, or NULL if none is found. */
document_signature_t *
networkstatus_get_voter_sig_by_alg(const networkstatus_voter_info_t *voter,
digest_algorithm_t alg)
{
if (!voter->sigs)
return NULL;
SMARTLIST_FOREACH(voter->sigs, document_signature_t *, sig,
if (sig->alg == alg)
return sig);
return NULL;
}
/** Check whether the signature <b>sig</b> is correctly signed with the
* signing key in <b>cert</b>. Return -1 if <b>cert</b> doesn't match the
* signing key; otherwise set the good_signature or bad_signature flag on

View File

@ -30,6 +30,10 @@ void ns_detached_signatures_free_(ns_detached_signatures_t *s);
networkstatus_voter_info_t *networkstatus_get_voter_by_id(
networkstatus_t *vote,
const char *identity);
document_signature_t *networkstatus_get_voter_sig_by_alg(
const networkstatus_voter_info_t *voter,
digest_algorithm_t alg);
int networkstatus_check_consensus_signature(networkstatus_t *consensus,
int warn);
int networkstatus_check_document_signature(const networkstatus_t *consensus,

View File

@ -3912,7 +3912,7 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
}
}
if (dirvote_get_voter_sig_by_alg(v, sig->alg)) {
if (networkstatus_get_voter_sig_by_alg(v, sig->alg)) {
/* We already parsed a vote with this algorithm from this voter. Use the
first one. */
log_fn(LOG_PROTOCOL_WARN, LD_DIR, "We received a networkstatus "