summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/channel
Commit message (Collapse)AuthorAgeFilesLines
* proto: Apply deferred rustfmtGabriela Moldovan2026-04-231-5/+2
|
* proto: Build the PeerInfo from the dummy target in the testsGabriela Moldovan2026-04-231-5/+14
| | | | | The new relay circuit reactor test expect the `PeerInfo` to be populated with the identity keys of the peer, and won't work without this change.
* relay: Modify RelayNtorKeys to use a constructorDavid Goulet2026-04-211-7/+5
| | | | | | | | | | | | Because of the sorting requirement and the fact that a `KeyMgr` can have multiple Ntor keys, the caller now explicitly extract the two Ntor keys it wants from the `KeyMgr` and then creates a `RelayNtorKeys` object with them. Future changes (#2495) will move this into a view and warn if there are more than 2 keys. Signed-off-by: David Goulet <[email protected]>
* proto: Make the CreateRequestHandler::new() take the ntor keysDavid Goulet2026-04-211-0/+16
| | | | Signed-off-by: David Goulet <[email protected]>
* tor-proto: give our rsa ident to the channel reactorSteven Engler2026-04-161-1/+5
| | | | This will be needed for ntor handshakes.
* proto: Remove unused imports in unit testsDavid Goulet2026-04-141-1/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Fix relay unit tests with new CreateRequestHandlerDavid Goulet2026-04-141-1/+13
| | | | | | | The CreateRequestHandler was introduced prior to the relay handshake unit tests so fix them now that we have a way to build one. Signed-off-by: David Goulet <[email protected]>
* proto: Add channel relay handshake unit testsDavid Goulet2026-04-141-4/+268
| | | | | | | | | | | | | Instead of copying the client unit tests into the channel module, just make both current unit tests run on a client and relay handshake. This required a bit of trickery with type HandshakeConnectFn but works out in the end. It also adds the RelayMsgBuf that wraps a MsgBuf in order to implement CertifiedConn which is very relay only. Signed-off-by: David Goulet <[email protected]>
* proto: Move test certs module at the topDavid Goulet2026-04-141-31/+31
| | | | | | | | | Just for mental sanity to have all const at the same place and easily readable. No behavior change. Signed-off-by: David Goulet <[email protected]>
* proto: Move channel client handshake tests into client moduleDavid Goulet2026-04-141-218/+10
| | | | | | | | | No behavior change. Make the const cells public as they will be useful for more upcoming unit tests especially on the relay side. Signed-off-by: David Goulet <[email protected]>
* tor-proto: small comment improvementSteven Engler2026-04-091-1/+2
|
* tor-proto: replace a tuple with a dedicated structSteven Engler2026-04-091-13/+23
|
* tor-proto: give our ed ident to the channel reactorSteven Engler2026-04-091-2/+7
| | | | This will be needed for ntor handshakes.
* Merge branch 'create-fast' into 'main'gabi-2502026-04-091-1/+1
|\ | | | | | | | | tor-proto: Move CREATE_FAST handling to a helper See merge request tpo/core/arti!3869
| * tor-proto: take `CreateRequest` message by referenceSteven Engler2026-04-081-1/+1
| | | | | | | | | | Clippy has started warning about this since we moved the CREATE_FAST handling to a helper, so this resolves that.
* | proto: Bring back AuthLogDigest and explicitly convert to SLOG/CLOGDavid Goulet2026-04-082-24/+21
| | | | | | | | | | | | | | | | | | | | | | | | From opara's comment: https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3844#note_3388789 Keep the low level AuthLogDigest type alias and return it. The callsite is the one deciding if the returned digest is a Clog or a Slog. Related to #2441 Signed-off-by: David Goulet <[email protected]>
* | proto: Add ClogDigest and SlogDigest typesDavid Goulet2026-04-082-16/+51
|/ | | | | | | | | Introduce those types in order to avoid mixing them up as the previous AuthLogDigest was just a type alias over [u8; 32] Fixes #2441 Signed-off-by: David Goulet <[email protected]>
* tor-proto: replace use of `ChannelDirection` with `CircIdRange`Steven Engler2026-04-081-1/+1
|
* Revert "tor-proto: change `CreateResponse` to `restricted_msg!`"Steven Engler2026-04-081-13/+2
| | | | This reverts commit 9c38daf2d3548feca2ff555f5bd52165add0d20c.
* tor-{proto,chanmgr}: change how channels accept a CREATE* handlerSteven Engler2026-04-082-28/+14
| | | | | | | | | | | Instead of giving the `CreateRequestHandler` to the channel after it's constructed, we integrate it into the handshake so that we can give it to the channel constructor. The `ChannelType` is no longer part of the `Channel`. Some of the tests could be cleaned up slightly now that the channel doesn't need the `ChannelType`, but I don't want to conflict with !3853.
* tor-proto: rename `CircIdRange::is_allowed_by_peer()` to `is_allowed_for_peer()`Steven Engler2026-04-081-2/+2
|
* tor-proto: remove TODO about `UniqId` overflowSteven Engler2026-04-081-2/+2
|
* tor-proto: handle incoming RELAY_EARLY messagesSteven Engler2026-04-081-2/+10
|
* tor-proto: add `Channel::set_create_request_handler()`Steven Engler2026-04-081-0/+21
| | | | | | We can't pass the request handler during the `Channel` constructor since it would require conditionally compiled function arguments, which aren't nice.
* tor-proto: add `CreateRequestHandler`Steven Engler2026-04-081-0/+99
| | | | for handling CREATE* messages on channels.
* tor-proto: change `CreateResponse` to `restricted_msg!`Steven Engler2026-04-081-2/+13
| | | | | This better fits with existing code that uses `restricted_msg!` and is a bit more flexible.
* tor-proto: change channel to use `Runtime`Steven Engler2026-04-082-10/+16
| | | | | When used for relay channels, the channel reactor will soon need to spawn relay circuit reactors.
* tor-proto: support relay circs in channel's `CircMap`Steven Engler2026-04-082-11/+87
|
* tor-proto: rename `CircEnt::Open` to `CircEnt::OpenOrigin`Steven Engler2026-04-082-18/+20
| | | | And rename `CircMap::add_ent()` to `add_origin_ent()`.
* tor-proto: add `CircIdRange::is_allowed_by_peer()`Steven Engler2026-03-311-0/+8
|
* tor-proto: add `CircIdRange::integer_range()`Steven Engler2026-03-311-6/+15
|
* proto: Improve check_relay_identities() documentationDavid Goulet2026-03-301-3/+7
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Rename many variables with more fine grained namingDavid Goulet2026-03-301-74/+86
| | | | | | | | | | Mostly, identity a `ChanTarget` as a "target" since we juggle with PeerInfo and OwnedChanTarget nowadays. All certificate and keys have very specific names which attempts to match the spec as much as possible. Signed-off-by: David Goulet <[email protected]>
* proto: Add documentation for the channel verify()David Goulet2026-03-301-1/+15
| | | | | | | | https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374476 and https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374478 Signed-off-by: David Goulet <[email protected]>
* proto: Remove duplicate use of read_msg() helperDavid Goulet2026-03-301-37/+37
| | | | | | | | | | Make read_msg() into a helper and use it accross the handshake code. No behavior change. https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374466 Signed-off-by: David Goulet <[email protected]>
* proto: Fix a set of commentsDavid Goulet2026-03-301-4/+4
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Add AuthLogAction enum helperDavid Goulet2026-03-301-3/+22
| | | | | | | | | We can remove the "/* take_slog */ true" pattern and instead have an explicit type at the callsite for semantic. https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374457 Signed-off-by: David Goulet <[email protected]>
* proto: Add a type alias for SLOG/CLOG digestDavid Goulet2026-03-302-10/+13
| | | | | | https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374457 Signed-off-by: David Goulet <[email protected]>
* tor-proto: Port to web-time-compatNick Mathewson2026-03-262-6/+6
|
* Fix typosTobias Stoeckmann2026-03-243-4/+4
| | | | Typos found with codespell
* proto: The relay signing key signs the auth certDavid Goulet2026-03-191-3/+3
| | | | | | In other words kp_relaysign_ed. Signed-off-by: David Goulet <[email protected]>
* tor-proto: fix the relay initiator's SLOG digestSteven Engler2026-03-191-3/+23
|
* tor-proto: improve chan send/recv-log error messagesSteven Engler2026-03-191-2/+6
|
* proto: Set the link protocol outside the recv VERSIONS helperDavid Goulet2026-03-191-3/+9
| | | | | | | | | | | | | | | | | | | It used to work for an initiator to set the link protocol once a VERSIONS is received because initiator send their VERSIONS before. This failed with responders because a responder channel sends their VERSIONS after receiving one from the initiator. This reverse logic means that the channel cell handler was transitionned to the Handshake state before a responder was able to send a VERSIONS cell leading to a failure because VERSIONS cell aren't allowed at the Handshake state. To fix this, the send/recv or recv/send is now explicit per channel type and once this is done and successful, the link protocol is set. A `set_link_protocol()` is added to the ChannelBaseHandshake trait so it can be used to set the cell handler. Signed-off-by: David Goulet <[email protected]>
* proto: Fix unit testsDavid Goulet2026-03-191-7/+17
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Improve logging in channel handshakeDavid Goulet2026-03-191-2/+2
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Add specialized build functions for ChannelAuthenticationDataDavid Goulet2026-03-191-8/+1
| | | | | | | | | | | The initiator and responder are quite different. Building an AUTHENTICATE cell is delicate and so this change differenticates clearly between the two. This allows us to remove the peer_cert_digest from an UnverifiedChannel which is only something that makes sense for an initiator. Signed-off-by: David Goulet <[email protected]>
* proto: New UnverifiedInitiatorChannelDavid Goulet2026-03-191-66/+109
| | | | | | | | Both client and relay specialized channel now use it as their inner base channel so they can use the same common verify() function since it is the same validation for both. Signed-off-by: David Goulet <[email protected]>
* proto: Move cert validation per specialized channelDavid Goulet2026-03-191-81/+14
| | | | | | | | | | | | | | | | | | | | | | | | Remove the last part from check_internal() that is specific to an initiator channel. At this commit, all three specialized channel do the verify process within their own verify() function. The client and relay initiator both look at the TLS cert (code duplication unfortunately). And the relay responder looks at the LINK_AUTH cert extracting the peer KP_link_ed key for validation. The CERTS cell is removed from UnverifiedChannel as it is now only useful within the verification process which is now specialized. A series of TODO(relay) is added to point out the current problem and how to fix them. The next step is to create an UnverifiedInitiatorChannel that will hold the verity_tls_cert() function and peer cert information which is only relevant to an initiator. This will remove code duplication. Signed-off-by: David Goulet <[email protected]>
* proto: Add the verify_link_auth_cert() helperDavid Goulet2026-03-191-1/+57
| | | | | | The responder channel will soon use it. Signed-off-by: David Goulet <[email protected]>