]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Rename two "record_*_digest functions to "save".
authorNick Mathewson <nickm@torproject.org>
Wed, 28 May 2025 12:27:58 +0000 (08:27 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 10 Jun 2025 23:06:47 +0000 (19:06 -0400)
This makes an important distinction: "recording" a digest puts
it in the expected-sendme queue, whereas "saving" a digest makes
a temporary copy inside the relay_crypto_t.

src/core/crypto/relay_crypto.c
src/core/crypto/relay_crypto.h
src/core/or/crypt_path.c
src/core/or/crypt_path.h
src/core/or/relay.c
src/core/or/sendme.c
src/core/or/sendme.h

index 00d8feb360b842d96e3b0e1ef10d7e54e6861f43..39a678ebfb62bfceb615b1a60396c23a77e4f13f 100644 (file)
@@ -109,7 +109,10 @@ tor1_crypt_one_payload(crypto_cipher_t *cipher, uint8_t *in)
   crypto_cipher_crypt_inplace(cipher, (char*) in, CELL_PAYLOAD_SIZE);
 }
 
-/** Return the sendme_digest within the <b>crypto</b> object. */
+/** Return the sendme_digest within the <b>crypto</b> object.
+ *
+ * Before calling this function, you must call relay_crypto_save_sendme_digest.
+ */
 uint8_t *
 relay_crypto_get_sendme_digest(relay_crypto_t *crypto)
 {
@@ -117,11 +120,15 @@ relay_crypto_get_sendme_digest(relay_crypto_t *crypto)
   return crypto->sendme_digest;
 }
 
-/** Record the cell digest, indicated by is_foward_digest or not, as the
- * SENDME cell digest. */
+/** Save the cell digest, indicated by is_foward_digest or not, as the
+ * SENDME cell digest inside this relay_crypto_t.
+ *
+ * This function must be called before relay_crypto_get_sendme_digest
+ * will work correctly.
+ */
 void
-relay_crypto_record_sendme_digest(relay_crypto_t *crypto,
-                                  bool is_foward_digest)
+tor1_save_sendme_digest(relay_crypto_t *crypto,
+                          bool is_foward_digest)
 {
   struct crypto_digest_t *digest;
 
@@ -233,7 +240,7 @@ relay_encrypt_cell_outbound(cell_t *cell,
   cpath_set_cell_forward_digest(layer_hint, cell);
 
   /* Record cell digest as the SENDME digest if need be. */
-  sendme_record_sending_cell_digest(TO_CIRCUIT(circ), layer_hint);
+  sendme_save_sending_cell_digest(TO_CIRCUIT(circ), layer_hint);
 
   thishop = layer_hint;
   /* moving from farthest to nearest hop */
@@ -260,7 +267,7 @@ relay_encrypt_cell_inbound(cell_t *cell,
   tor1_set_digest_v0(or_circ->crypto.b_digest, cell);
 
   /* Record cell digest as the SENDME digest if need be. */
-  sendme_record_sending_cell_digest(TO_CIRCUIT(or_circ), NULL);
+  sendme_save_sending_cell_digest(TO_CIRCUIT(or_circ), NULL);
 
   /* encrypt one layer */
   tor1_crypt_one_payload(or_circ->crypto.b_crypto, cell->payload);
index a735b696ecec84c6cfce44ec619e050b962b6a37..341c612fca5b03a59ace0d36c8df6d45ac2d7470 100644 (file)
@@ -29,8 +29,8 @@ void relay_crypto_assert_ok(const relay_crypto_t *crypto);
 
 uint8_t *relay_crypto_get_sendme_digest(relay_crypto_t *crypto);
 
-void relay_crypto_record_sendme_digest(relay_crypto_t *crypto,
-                                       bool is_foward_digest);
+void tor1_save_sendme_digest(relay_crypto_t *crypto,
+                             bool is_foward_digest);
 
 void
 tor1_crypt_one_payload(crypto_cipher_t *cipher, uint8_t *in);
index 9214bbc26fe4859cd03df7319be858ab0413cbf3..b2cf7a8d595c7e546aad85f446f2b0bd5fed56ca 100644 (file)
@@ -213,13 +213,14 @@ cpath_get_sendme_digest(crypt_path_t *cpath)
   return relay_crypto_get_sendme_digest(&cpath->pvt_crypto);
 }
 
-/** Record the cell digest, indicated by is_foward_digest or not, as the
- * SENDME cell digest. */
+/** Save the cell digest, indicated by is_foward_digest or not, as the
+ * SENDME cell digest inside the cpath's relay_crypto_t.
+ */
 void
-cpath_sendme_record_cell_digest(crypt_path_t *cpath, bool is_foward_digest)
+cpath_sendme_save_cell_digest(crypt_path_t *cpath, bool is_foward_digest)
 {
   tor_assert(cpath);
-  relay_crypto_record_sendme_digest(&cpath->pvt_crypto, is_foward_digest);
+  tor1_save_sendme_digest(&cpath->pvt_crypto, is_foward_digest);
 }
 
 /************ other cpath functions ***************************/
index 7a95fec2b4607aedcea18595dc3a85c935c1d767..dfd2ed485745bca574ae599eb647a3fa8b881d4a 100644 (file)
@@ -27,7 +27,7 @@ cpath_crypt_cell(const crypt_path_t *cpath, uint8_t *payload, bool is_decrypt);
 struct crypto_digest_t *
 cpath_get_incoming_digest(const crypt_path_t *cpath);
 
-void cpath_sendme_record_cell_digest(crypt_path_t *cpath,
+void cpath_sendme_save_cell_digest(crypt_path_t *cpath,
                                      bool is_foward_digest);
 
 void
index 84dfe00157632a77d537a92401e15b0c7f9d81af..6616b92d77b38b757f3de5dcba8bd12fe82cee30 100644 (file)
@@ -267,7 +267,7 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
 
     /* Recognized cell, the cell digest has been updated, we'll record it for
      * the SENDME if need be. */
-    sendme_record_received_cell_digest(circ, layer_hint);
+    sendme_save_received_cell_digest(circ, layer_hint);
 
     relay_msg_t msg_buf;
     if (relay_msg_decode_cell_in_place(format, cell, &msg_buf) < 0) {
index 933170d9f0fd284746df58c65f21f0eb5979033e..426495d745ff5d61fa6d7f516ad6fc88f3cda44b 100644 (file)
@@ -720,11 +720,12 @@ sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath)
   record_cell_digest_on_circ(circ, sendme_digest);
 }
 
-/* Called once we decrypted a cell and recognized it. Record the cell digest
- * as the next sendme digest only if the next cell we'll send on the circuit
+/* Called once we decrypted a cell and recognized it. Save the cell digest
+ * as the next sendme digest in the cpath's relay_crypto_t,
+ * only if the next cell we'll send on the circuit
  * is expected to be a SENDME. */
 void
-sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath)
+sendme_save_received_cell_digest(circuit_t *circ, crypt_path_t *cpath)
 {
   tor_assert(circ);
 
@@ -737,18 +738,19 @@ sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath)
 
   if (cpath) {
     /* Record incoming digest. */
-    cpath_sendme_record_cell_digest(cpath, false);
+    cpath_sendme_save_cell_digest(cpath, false);
   } else {
     /* Record forward digest. */
-    relay_crypto_record_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, true);
+    tor1_save_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, true);
   }
 }
 
-/* Called once we encrypted a cell. Record the cell digest as the next sendme
- * digest only if the next cell we expect to receive is a SENDME so we can
- * match the digests. */
+/* Called once we encrypted a cell. Save the cell digest as the next sendme
+ * as the next sendme digest in the cpath's relay_crypto_t
+ * only if the we expect to receive a SENDME matching this cell's digest.
+ */
 void
-sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath)
+sendme_save_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath)
 {
   tor_assert(circ);
 
@@ -759,10 +761,10 @@ sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath)
 
   if (cpath) {
     /* Record the forward digest. */
-    cpath_sendme_record_cell_digest(cpath, true);
+    cpath_sendme_save_cell_digest(cpath, true);
   } else {
     /* Record the incoming digest. */
-    relay_crypto_record_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, false);
+    tor1_save_sendme_digest(&TO_OR_CIRCUIT(circ)->crypto, false);
   }
 
  end:
index bc1daef23d027582cf3b0d082c83587e5e96cb75..fe6dc74542d507ce943248a123dd4acd75c0f6f1 100644 (file)
@@ -38,8 +38,8 @@ int sendme_note_stream_data_packaged(edge_connection_t *conn, size_t len);
 /* Record cell digest on circuit. */
 void sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath);
 /* Record cell digest as the SENDME digest. */
-void sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
-void sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
+void sendme_save_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
+void sendme_save_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
 
 /* Private section starts. */
 #ifdef SENDME_PRIVATE