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

[tor-commits] [tor/master] Move back dirvote_authority_cert_dup to dirvote.c



commit 15e8ce39379fde7b6cddb4b06b3d8e01fadd4867
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Tue May 1 08:58:57 2018 -0400

    Move back dirvote_authority_cert_dup to dirvote.c
    
    Originally, it was made public outside of the dirauth module but it is no
    longer needed. In doing so, we put it back in dirvote.c and reverted its name
    to the original one:
    
    dirvote_authority_cert_dup() --> authority_cert_dup()
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 src/or/dirauth/dirvote.c   | 26 +++++++++++++++++++++++++-
 src/or/dirauth/dirvote.h   |  2 ++
 src/or/dirvote_common.c    | 24 ------------------------
 src/or/dirvote_common.h    |  3 ---
 src/test/test_dir_common.c |  6 +++---
 5 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c
index 683cfdfca..dc978f26e 100644
--- a/src/or/dirauth/dirvote.c
+++ b/src/or/dirauth/dirvote.c
@@ -95,6 +95,30 @@ static int dirvote_compute_consensuses(void);
 static int dirvote_publish_consensus(void);
 
 /* =====
+ * Certificate functions
+ * ===== */
+
+/** Allocate and return a new authority_cert_t with the same contents as
+ * <b>cert</b>. */
+STATIC authority_cert_t *
+authority_cert_dup(authority_cert_t *cert)
+{
+  authority_cert_t *out = tor_malloc(sizeof(authority_cert_t));
+  tor_assert(cert);
+
+  memcpy(out, cert, sizeof(authority_cert_t));
+  /* Now copy pointed-to things. */
+  out->cache_info.signed_descriptor_body =
+    tor_strndup(cert->cache_info.signed_descriptor_body,
+                cert->cache_info.signed_descriptor_len);
+  out->cache_info.saved_location = SAVED_NOWHERE;
+  out->identity_key = crypto_pk_dup_key(cert->identity_key);
+  out->signing_key = crypto_pk_dup_key(cert->signing_key);
+
+  return out;
+}
+
+/* =====
  * Voting
  * =====*/
 
@@ -4472,7 +4496,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
 
   v3_out->voters = smartlist_new();
   smartlist_add(v3_out->voters, voter);
-  v3_out->cert = dirvote_authority_cert_dup(cert);
+  v3_out->cert = authority_cert_dup(cert);
   v3_out->routerstatus_list = routerstatuses;
   /* Note: networkstatus_digest is unset; it won't get set until we actually
    * format the vote. */
diff --git a/src/or/dirauth/dirvote.h b/src/or/dirauth/dirvote.h
index 59cfd6b99..2c3b1a1cf 100644
--- a/src/or/dirauth/dirvote.h
+++ b/src/or/dirauth/dirvote.h
@@ -202,6 +202,8 @@ vote_microdesc_hash_t *dirvote_format_all_microdesc_vote_lines(
  */
 #ifdef DIRVOTE_PRIVATE
 
+/* Cert manipulation */
+STATIC authority_cert_t *authority_cert_dup(authority_cert_t *cert);
 STATIC int32_t dirvote_get_intermediate_param_value(
                                    const smartlist_t *param_list,
                                    const char *keyword,
diff --git a/src/or/dirvote_common.c b/src/or/dirvote_common.c
index 9d2c867c8..a28a441d6 100644
--- a/src/or/dirvote_common.c
+++ b/src/or/dirvote_common.c
@@ -193,27 +193,3 @@ dirvote_get_voter_sig_by_alg(const networkstatus_voter_info_t *voter,
   return NULL;
 }
 
-/* =====
- * Certificate functions
- * ===== */
-
-/** Allocate and return a new authority_cert_t with the same contents as
- * <b>cert</b>. */
-authority_cert_t *
-dirvote_authority_cert_dup(authority_cert_t *cert)
-{
-  authority_cert_t *out = tor_malloc(sizeof(authority_cert_t));
-  tor_assert(cert);
-
-  memcpy(out, cert, sizeof(authority_cert_t));
-  /* Now copy pointed-to things. */
-  out->cache_info.signed_descriptor_body =
-    tor_strndup(cert->cache_info.signed_descriptor_body,
-                cert->cache_info.signed_descriptor_len);
-  out->cache_info.saved_location = SAVED_NOWHERE;
-  out->identity_key = crypto_pk_dup_key(cert->identity_key);
-  out->signing_key = crypto_pk_dup_key(cert->signing_key);
-
-  return out;
-}
-
diff --git a/src/or/dirvote_common.h b/src/or/dirvote_common.h
index 07e625937..857b8497e 100644
--- a/src/or/dirvote_common.h
+++ b/src/or/dirvote_common.h
@@ -62,8 +62,5 @@ document_signature_t *dirvote_get_voter_sig_by_alg(
                            const networkstatus_voter_info_t *voter,
                            digest_algorithm_t alg);
 
-/* Cert manipulation */
-authority_cert_t *dirvote_authority_cert_dup(authority_cert_t *cert);
-
 #endif /* TOR_DIRVOTE_COMMON_H */
 
diff --git a/src/test/test_dir_common.c b/src/test/test_dir_common.c
index 8c6d99cce..02d3295ca 100644
--- a/src/test/test_dir_common.c
+++ b/src/test/test_dir_common.c
@@ -307,7 +307,7 @@ dir_common_construct_vote_1(networkstatus_t **vote, authority_cert_t *cert,
    * Set up a vote; generate it; try to parse it.
    */
   smartlist_add((*vote)->voters, voter);
-  (*vote)->cert = dirvote_authority_cert_dup(cert);
+  (*vote)->cert = authority_cert_dup(cert);
   smartlist_split_string((*vote)->net_params, "circuitwindow=101 foo=990",
                          NULL, 0, 0);
   *n_vrs = 0;
@@ -356,7 +356,7 @@ dir_common_construct_vote_2(networkstatus_t **vote, authority_cert_t *cert,
    * Set up a vote; generate it; try to parse it.
    */
   smartlist_add((*vote)->voters, voter);
-  (*vote)->cert = dirvote_authority_cert_dup(cert);
+  (*vote)->cert = authority_cert_dup(cert);
   if (! (*vote)->net_params)
     (*vote)->net_params = smartlist_new();
   smartlist_split_string((*vote)->net_params,
@@ -407,7 +407,7 @@ dir_common_construct_vote_3(networkstatus_t **vote, authority_cert_t *cert,
    * Set up a vote; generate it; try to parse it.
    */
   smartlist_add((*vote)->voters, voter);
-  (*vote)->cert = dirvote_authority_cert_dup(cert);
+  (*vote)->cert = authority_cert_dup(cert);
   smartlist_split_string((*vote)->net_params, "circuitwindow=80 foo=660",
                          NULL, 0, 0);
   /* add routerstatuses */



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