From: Nick Mathewson Date: Mon, 2 Jun 2025 14:21:05 +0000 (-0400) Subject: Move parameter initialization to the start of the client handshake X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a72d907d6cfcceb5bf2ea40439dc5daed5d4089a;p=thirdparty%2Ftor.git Move parameter initialization to the start of the client handshake 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. --- diff --git a/src/core/crypto/onion_crypto.c b/src/core/crypto/onion_crypto.c index 787238b278..ed3340fa2d 100644 --- a/src/core/crypto/onion_crypto.c +++ b/src/core/crypto/onion_crypto.c @@ -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: diff --git a/src/core/or/crypt_path_st.h b/src/core/or/crypt_path_st.h index 8b6eba01a7..b7f9a06cd7 100644 --- a/src/core/or/crypt_path_st.h +++ b/src/core/or/crypt_path_st.h @@ -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;