Prechádzať zdrojové kódy

Hiding crypt_path_t: Hide 'crypto' usage in sendme.c

George Kadianakis 5 rokov pred
rodič
commit
7f2cd6545c

+ 3 - 4
scripts/maint/practracker/exceptions.txt

@@ -54,9 +54,9 @@ problem function-size /src/app/main/main.c:sandbox_init_filter() 291
 problem function-size /src/app/main/main.c:run_tor_main_loop() 105
 problem function-size /src/app/main/ntmain.c:nt_service_install() 125
 problem include-count /src/app/main/shutdown.c 52
-problem file-size /src/core/mainloop/connection.c 5559
+problem file-size /src/core/mainloop/connection.c 5560
 problem include-count /src/core/mainloop/connection.c 62
-problem function-size /src/core/mainloop/connection.c:connection_free_minimal() 184
+problem function-size /src/core/mainloop/connection.c:connection_free_minimal() 185
 problem function-size /src/core/mainloop/connection.c:connection_listener_new() 328
 problem function-size /src/core/mainloop/connection.c:connection_handle_listener_read() 161
 problem function-size /src/core/mainloop/connection.c:connection_connect_sockaddr() 103
@@ -79,7 +79,6 @@ problem function-size /src/core/or/channeltls.c:channel_tls_process_netinfo_cell
 problem function-size /src/core/or/channeltls.c:channel_tls_process_certs_cell() 246
 problem function-size /src/core/or/channeltls.c:channel_tls_process_authenticate_cell() 202
 problem file-size /src/core/or/circuitbuild.c 3061
-problem include-count /src/core/or/circuitbuild.c 53
 problem include-count /src/core/or/circuitbuild.c 54
 problem function-size /src/core/or/circuitbuild.c:get_unique_circ_id_by_chan() 128
 problem function-size /src/core/or/circuitbuild.c:circuit_extend() 147
@@ -246,7 +245,7 @@ problem function-size /src/feature/rend/rendmid.c:rend_mid_establish_intro_legac
 problem function-size /src/feature/rend/rendparse.c:rend_parse_v2_service_descriptor() 187
 problem function-size /src/feature/rend/rendparse.c:rend_decrypt_introduction_points() 104
 problem function-size /src/feature/rend/rendparse.c:rend_parse_introduction_points() 131
-problem file-size /src/feature/rend/rendservice.c 4510
+problem file-size /src/feature/rend/rendservice.c 4511
 problem function-size /src/feature/rend/rendservice.c:rend_service_prune_list_impl_() 107
 problem function-size /src/feature/rend/rendservice.c:rend_config_service() 164
 problem function-size /src/feature/rend/rendservice.c:rend_service_load_auth_keys() 178

+ 1 - 1
src/core/crypto/relay_crypto.c

@@ -164,7 +164,7 @@ relay_decrypt_cell(circuit_t *circ, cell_t *cell,
             /* This cell is for us. Keep a record of this cell because we will
              * use it in the next SENDME cell. */
             if (sendme_circuit_cell_is_next(thishop->deliver_window)) {
-              sendme_circuit_record_inbound_cell(thishop);
+              cpath_sendme_circuit_record_inbound_cell(thishop);
             }
             return 0;
           }

+ 18 - 0
src/core/or/crypt_path.c

@@ -202,6 +202,24 @@ cpath_set_cell_forward_digest(crypt_path_t *cpath, cell_t *cell)
   relay_set_digest(cpath->pvt_crypto.f_digest, cell);
 }
 
+/************ cpath sendme API ***************************/
+
+/** Keep the current inbound cell digest for the next SENDME digest. This part
+ * is only done by the client as the circuit came back from the Exit. */
+void
+cpath_sendme_circuit_record_inbound_cell(crypt_path_t *cpath)
+{
+  tor_assert(cpath);
+  relay_crypto_record_sendme_digest(&cpath->pvt_crypto);
+}
+
+/** Return the sendme_digest of this <b>cpath</b>. */
+uint8_t *
+cpath_get_sendme_digest(crypt_path_t *cpath)
+{
+  return relay_crypto_get_sendme_digest(&cpath->pvt_crypto);
+}
+
 /************ other cpath functions ***************************/
 
 /** Return the first non-open hop in cpath, or return NULL if all

+ 4 - 0
src/core/or/crypt_path.h

@@ -32,6 +32,10 @@ cpath_set_cell_forward_digest(crypt_path_t *cpath, cell_t *cell);
 
 crypt_path_t *cpath_get_next_non_open_hop(crypt_path_t *cpath);
 
+void cpath_sendme_circuit_record_inbound_cell(crypt_path_t *cpath);
+
+uint8_t *cpath_get_sendme_digest(crypt_path_t *cpath);
+
 #if defined(TOR_UNIT_TESTS)
 unsigned int cpath_get_n_hops(crypt_path_t **head_ptr);
 #endif /* defined(TOR_UNIT_TESTS) */

+ 2 - 10
src/core/or/sendme.c

@@ -15,6 +15,7 @@
 #include "core/crypto/relay_crypto.h"
 #include "core/mainloop/connection.h"
 #include "core/or/cell_st.h"
+#include "core/or/crypt_path.h"
 #include "core/or/circuitlist.h"
 #include "core/or/circuituse.h"
 #include "core/or/or_circuit_st.h"
@@ -299,15 +300,6 @@ sendme_circuit_record_outbound_cell(or_circuit_t *or_circ)
   relay_crypto_record_sendme_digest(&or_circ->crypto);
 }
 
-/** Keep the current inbound cell digest for the next SENDME digest. This part
- * is only done by the client as the circuit came back from the Exit. */
-void
-sendme_circuit_record_inbound_cell(crypt_path_t *cpath)
-{
-  tor_assert(cpath);
-  relay_crypto_record_sendme_digest(&cpath->crypto);
-}
-
 /** Return true iff the next cell for the given cell window is expected to be
  * a SENDME.
  *
@@ -387,7 +379,7 @@ sendme_circuit_consider_sending(circuit_t *circ, crypt_path_t *layer_hint)
     log_debug(LD_CIRC,"Queuing circuit sendme.");
     if (layer_hint) {
       layer_hint->deliver_window += CIRCWINDOW_INCREMENT;
-      digest = relay_crypto_get_sendme_digest(&layer_hint->crypto);
+      digest = cpath_get_sendme_digest(layer_hint);
     } else {
       circ->deliver_window += CIRCWINDOW_INCREMENT;
       digest = relay_crypto_get_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto);

+ 0 - 1
src/core/or/sendme.h

@@ -36,7 +36,6 @@ int sendme_note_stream_data_packaged(edge_connection_t *conn);
 
 /* Track cell digest. */
 void sendme_record_cell_digest(circuit_t *circ);
-void sendme_circuit_record_inbound_cell(crypt_path_t *cpath);
 void sendme_circuit_record_outbound_cell(or_circuit_t *or_circ);
 
 /* Circuit level information. */