]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Move parameter initialization to the start of the client handshake
authorNick Mathewson <nickm@torproject.org>
Mon, 2 Jun 2025 14:21:05 +0000 (10:21 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 10 Jun 2025 23:06:47 +0000 (19:06 -0400)
Since we're going to be determining cell format and relay crypto
algorithm when we send our negotiation message, we'll need to
initialize it here.

src/core/crypto/onion_crypto.c
src/core/or/crypt_path_st.h

index 787238b278d08b84d9bdd178ac8460c6dfd19155..ed3340fa2df746e0353ae0c0656c1454302a2916 100644 (file)
@@ -147,6 +147,8 @@ onion_skin_create(int type,
 {
   int r = -1;
 
+  circuit_params_init(&state_out->chosen_params);
+
   switch (type) {
   case ONION_HANDSHAKE_TYPE_TAP:
     return -1;
@@ -483,7 +485,8 @@ onion_skin_client_handshake(int type,
   }
   *keys_len_out = keys_out_needed;
 
-  circuit_params_init(params_out);
+  memcpy(params_out, &handshake_state->chosen_params,
+         sizeof(circuit_params_t));
 
   switch (type) {
   case ONION_HANDSHAKE_TYPE_TAP:
index 8b6eba01a7e70fc78e38b1c43d1aff00f8a422a2..b7f9a06cd7a7d98b2e55beca9f598b0e0c1d392a 100644 (file)
@@ -13,6 +13,7 @@
 #define CRYPT_PATH_ST_H
 
 #include "core/crypto/relay_crypto_st.h"
+#include "core/crypto/onion_crypto.h"
 
 #define CRYPT_PATH_MAGIC 0x70127012u
 
@@ -22,6 +23,9 @@ struct onion_handshake_state_t {
   /** One of `ONION_HANDSHAKE_TYPE_*`.  Determines which member of the union
    * is accessible. */
   uint16_t tag;
+  /** Initial circuit parameters (selected during first stage of negotiation;
+   * may be changed based on response from relay). */
+  circuit_params_t chosen_params;
   union {
     struct fast_handshake_state_t *fast;
     struct ntor_handshake_state_t *ntor;