aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2021-09-14 15:01:45 -0400
committerMike Perry <mikeperry-git@torproject.org>2022-02-22 19:28:33 +0000
commitbd2e9a44097ff85934bc1c34f4fce2017a7a92c8 (patch)
tree90f31985afb3132ff57645be058e5774830941db /src/core/or/circuitbuild.c
parent244444e8b1ac36bf9148aa656e4eb9e293daa5b4 (diff)
downloadtor-bd2e9a44097ff85934bc1c34f4fce2017a7a92c8.tar.gz
tor-bd2e9a44097ff85934bc1c34f4fce2017a7a92c8.zip
Implement core of ntor3 negotiation.
There are a lot of TODOs about what to send, whom to send it to, and etc.
Diffstat (limited to 'src/core/or/circuitbuild.c')
-rw-r--r--src/core/or/circuitbuild.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index f67fe196e5..ffb2c00493 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -841,7 +841,10 @@ circuit_pick_create_handshake(uint8_t *cell_type_out,
* using the TAP handshake, and CREATE2 otherwise. */
if (extend_info_supports_ntor(ei)) {
*cell_type_out = CELL_CREATE2;
- *handshake_type_out = ONION_HANDSHAKE_TYPE_NTOR;
+ if (ei->supports_ntor3_and_param_negotiation)
+ *handshake_type_out = ONION_HANDSHAKE_TYPE_NTOR_V3;
+ else
+ *handshake_type_out = ONION_HANDSHAKE_TYPE_NTOR;
} else {
/* XXXX030 Remove support for deciding to use TAP and EXTEND. */
*cell_type_out = CELL_CREATE;
@@ -2579,3 +2582,24 @@ circuit_upgrade_circuits_from_guard_wait(void)
smartlist_free(to_upgrade);
}
+
+/**
+ * Try to generate a circuit-negotiation message for communication with a
+ * given relay. Assumes we are using ntor v3, or some later version that
+ * supports parameter negotiatoin.
+ *
+ * On success, return 0 and pass back a message in the `out` parameters.
+ * Otherwise, return -1.
+ **/
+int
+client_circ_negotiation_message(const extend_info_t *ei,
+ uint8_t **msg_out,
+ size_t *msg_len_out)
+{
+ tor_assert(ei && msg_out && msg_len_out);
+ if (! ei->supports_ntor3_and_param_negotiation)
+ return -1;
+
+ /* TODO: fill in the client message that gets sent. */
+ tor_assert_unreached();
+}