diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 36f328d6c5..f11b871e50 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -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. */ diff --git a/src/or/dirvote_common.c b/src/or/dirvote_common.c index a28a441d64..354ee0ce72 100644 --- a/src/or/dirvote_common.c +++ b/src/or/dirvote_common.c @@ -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 voter using the algorithm - * alg, 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; -} - diff --git a/src/or/dirvote_common.h b/src/or/dirvote_common.h index 857b8497ee..096e5b0300 100644 --- a/src/or/dirvote_common.h +++ b/src/or/dirvote_common.h @@ -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 */ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 1267d9d6bc..99f1490203 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -390,6 +390,20 @@ networkstatus_get_voter_by_id(networkstatus_t *vote, return NULL; } +/** Return the signature made by voter using the algorithm + * alg, 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 sig is correctly signed with the * signing key in cert. Return -1 if cert doesn't match the * signing key; otherwise set the good_signature or bad_signature flag on diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h index bd78292050..0c325959d7 100644 --- a/src/or/networkstatus.h +++ b/src/or/networkstatus.h @@ -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, diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 3a55c00cc1..e4833b4419 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -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 "