commit a72d907d6cfcceb5bf2ea40439dc5daed5d4089a
parent 5721efc427ee1c0f826239395af9cd8d72f6634c
Author: Nick Mathewson <nickm@torproject.org>
Date: Mon, 2 Jun 2025 10:21:05 -0400
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.
Diffstat:
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git 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
@@ -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;