]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
sendme: Move note_cell_digest() to relay_crypto module
authorDavid Goulet <dgoulet@torproject.org>
Mon, 29 Apr 2019 15:29:05 +0000 (11:29 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Mon, 29 Apr 2019 16:17:57 +0000 (12:17 -0400)
Because this function is poking within the relay_crypto_t object, move the
function to the module so we can keep it opaque as much as possible.

Part of #26288

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/core/crypto/relay_crypto.c
src/core/crypto/relay_crypto.h
src/core/or/sendme.c

index eddc4298e29526177d17cef1e10118d7ddb5952b..3a6dad4b1dea4dae56b6a90024b2ea676a987666 100644 (file)
@@ -91,6 +91,15 @@ relay_crypt_one_payload(crypto_cipher_t *cipher, uint8_t *in)
   crypto_cipher_crypt_inplace(cipher, (char*) in, CELL_PAYLOAD_SIZE);
 }
 
+/** Record the b_digest from <b>crypto</b> and put it in the sendme_digest. */
+void
+relay_crypto_record_sendme_digest(relay_crypto_t *crypto)
+{
+  tor_assert(crypto);
+  crypto_digest_get_digest(crypto->b_digest, (char *) crypto->sendme_digest,
+                           sizeof(crypto->sendme_digest));
+}
+
 /** Do the appropriate en/decryptions for <b>cell</b> arriving on
  * <b>circ</b> in direction <b>cell_direction</b>.
  *
index 45a21d14ab840ada98f9955f5cc636a22545f386..1009f1841b95a197dbe8174c4322b3d574182b63 100644 (file)
@@ -27,5 +27,7 @@ void relay_crypto_clear(relay_crypto_t *crypto);
 
 void relay_crypto_assert_ok(const relay_crypto_t *crypto);
 
+void relay_crypto_record_sendme_digest(relay_crypto_t *crypto);
+
 #endif /* !defined(TOR_RELAY_CRYPTO_H) */
 
index b384a19164b639708389b099a8853810aef8a4f0..b65f30ba9753ad891fadc6bf40c58bc27122826d 100644 (file)
@@ -12,6 +12,7 @@
 #include "core/or/or.h"
 
 #include "app/config/config.h"
+#include "core/crypto/relay_crypto.h"
 #include "core/mainloop/connection.h"
 #include "core/or/cell_st.h"
 #include "core/or/circuitlist.h"
@@ -286,15 +287,6 @@ send_circuit_level_sendme(circuit_t *circ, crypt_path_t *layer_hint,
   return 0;
 }
 
-/* Put the crypto.b_digest in the sendme_digest. */
-static void
-note_cell_digest(const relay_crypto_t *crypto)
-{
-  tor_assert(crypto);
-  crypto_digest_get_digest(crypto->b_digest, (char *) crypto->sendme_digest,
-                           sizeof(crypto->sendme_digest));
-}
-
 /*
  * Public API
  */
@@ -305,7 +297,7 @@ void
 sendme_circuit_note_outbound_cell(or_circuit_t *or_circ)
 {
   tor_assert(or_circ);
-  note_cell_digest(&or_circ->crypto);
+  relay_crypto_record_sendme_digest(&or_circ->crypto);
 }
 
 /** Keep the current inbound cell digest for the next SENDME digest. This part
@@ -314,7 +306,7 @@ void
 sendme_circuit_note_inbound_cell(crypt_path_t *cpath)
 {
   tor_assert(cpath);
-  note_cell_digest(&cpath->crypto);
+  relay_crypto_record_sendme_digest(&cpath->crypto);
 }
 
 /** Return true iff the next cell for the given cell window is expected to be