Commit 098b7fe2 authored by David Goulet's avatar David Goulet 🐼
Browse files

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's avatarDavid Goulet <dgoulet@torproject.org>
parent afd4fc68
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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. */
+0 −14
Original line number Diff line number Diff line
@@ -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;
}
+0 −4
Original line number Diff line number Diff line
@@ -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 */
+14 −0
Original line number Diff line number Diff line
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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,
Loading