aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/relay/channel
Commit message (Collapse)AuthorAgeFilesLines
...
* relay: Pass advertise SocketAddr to channel builder instead of IpAddrDavid Goulet2026-04-091-5/+5
| | | | | | | | | | This trickles down to the tor-proto channel handshake code. But, the real need is in the channel builder in order to validate the outbound channel target. Fixes #2440 Signed-off-by: David Goulet <[email protected]>
* Merge branch 'create-fast' into 'main'gabi-2502026-04-091-55/+70
|\ | | | | | | | | 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-5/+4
| | | | | | | | | | Clippy has started warning about this since we moved the CREATE_FAST handling to a helper, so this resolves that.
| * tor-proto: move a TODOSteven Engler2026-04-081-2/+1
| |
| * tor-proto: remove old TODOSteven Engler2026-04-081-4/+1
| |
| * tor-proto: rustfmtSteven Engler2026-04-081-6/+3
| | | | | | | | Fix formatting from previous code movement.
| * tor-proto: move CREATE_FAST handlingSteven Engler2026-04-081-45/+43
| | | | | | | | | | This moves the code, changes the indentation, and wraps the result in an `Ok()`.
| * tor-proto: prepare to move CREATE_FAST handling to a helperSteven Engler2026-04-081-8/+34
| |
| * tor-proto: remove old TODOSteven Engler2026-04-081-1/+0
| | | | | | | | This had already been resolved.
* | proto: Bring back AuthLogDigest and explicitly convert to SLOG/CLOGDavid Goulet2026-04-082-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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-083-11/+19
|/ | | | | | | | | 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-082-5/+7
|
* tor-{proto,chanmgr}: change how channels accept a CREATE* handlerSteven Engler2026-04-083-5/+48
| | | | | | | | | | | 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: simplify error handling in `CreateRequestHandler::handle_create()`Steven Engler2026-04-081-71/+85
|
* tor-proto: add `CreateRequestHandler`Steven Engler2026-04-081-0/+340
| | | | for handling CREATE* messages on channels.
* tor-proto: change channel to use `Runtime`Steven Engler2026-04-082-5/+14
| | | | | When used for relay channels, the channel reactor will soon need to spawn relay circuit reactors.
* proto: Import read_msg() instead of refering to itDavid Goulet2026-03-301-19/+4
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Rename RelayIdentities to RelayChannelAuthMaterialDavid Goulet2026-03-303-24/+27
| | | | | | | | | | | | This object contains a melting pot of public keys, private keys and certificates. Rename it to reflect that it is channel authentication material and not "identities. https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374454 Signed-off-by: David Goulet <[email protected]>
* proto: Remove noop function for initiator channelDavid Goulet2026-03-301-12/+1
| | | | | | | | | | | | No need to call `set_authenticated()` for a relay initiator channel because relay initiator channel are always authenticated and thus the underlying channel cell codec will always use the R2R restricted message set. This is only useful to a relay responder channel. The naming of that function is not great actually and should probably change. Signed-off-by: David Goulet <[email protected]>
* proto: Rename many variables with more fine grained namingDavid Goulet2026-03-303-37/+42
| | | | | | | | | | 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: Transform inner into verified after verificationDavid Goulet2026-03-301-7/+11
| | | | | | | | | | | | | Only get the inner generic unverified channel into a verified channel after the actual verification in the relay responder handshake. Some variables needed a rename as this was dangerously named. No behavior change. https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3791#note_3374481 Signed-off-by: David Goulet <[email protected]>
* proto: Add documentation for the channel verify()David Goulet2026-03-301-1/+16
| | | | | | | | 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-45/+21
| | | | | | | | | | 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-302-6/+5
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Add AuthLogAction enum helperDavid Goulet2026-03-301-5/+4
| | | | | | | | | 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-303-13/+9
| | | | | | 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-4/+5
|
* Fix typosTobias Stoeckmann2026-03-241-1/+1
| | | | Typos found with codespell
* proto: Compare AUTHENTICATE expected body in constant-timeDavid Goulet2026-03-191-1/+3
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: The relay signing key signs the auth certDavid Goulet2026-03-191-6/+3
| | | | | | In other words kp_relaysign_ed. Signed-off-by: David Goulet <[email protected]>
* proto: Check the AUTHENTICATE auth type that we support itDavid Goulet2026-03-191-0/+1
| | | | | | | | As a responder, we should check the AUTHENTICATE auth type and make sure we support it. We were not doing that, we were simply putting in our max version. Signed-off-by: David Goulet <[email protected]>
* chanmgr: Clarify the use of no identity ChanTargetDavid Goulet2026-03-191-3/+4
| | | | Signed-off-by: David Goulet <[email protected]>
* tor-proto: fix the relay responder's CLOG/SLOG digestsSteven Engler2026-03-192-20/+37
|
* tor-proto: fix the relay initiator's SLOG digestSteven Engler2026-03-192-6/+19
|
* tor-proto: get SLOG/CLOG outside of `ChannelAuthenticationData`Steven Engler2026-03-192-0/+16
|
* tor-proto: build AUTHENTICATE after sending CERTSSteven Engler2026-03-191-15/+22
| | | | | | The AUTHENTICATE cell contents depends on all bytes sent on the channel before the AUTHENTICATE cell itself is sent (the CLOG). So we can only build a correct AUTHENTICATE cell after the CERTS cell has been sent.
* cell: Simplify the Authenticate APIDavid Goulet2026-03-191-5/+8
| | | | | | | | | | Remove the is_equal_no_sig() and instead add a getter that returns a reference to the body without the random part so it can be used to verify the signature. The caller now checks the equality with what it is expected. Signed-off-by: David Goulet <[email protected]>
* proto: Fix AUTHENTICATE equality check and signature checkDavid Goulet2026-03-191-2/+2
| | | | | | | | | | | | | | This fixes two things. 1. The "is_equal_no_sig()", if true, was going into the error path. 2. The signature verification is done against the body of the AUTHENTICATE cell that is all fields except the signature. Next commit will change the is_equal_no_sig() to make more sense with the "body" semantic. Signed-off-by: David Goulet <[email protected]>
* proto: Set the link protocol outside the recv VERSIONS helperDavid Goulet2026-03-191-14/+13
| | | | | | | | | | | | | | | | | | | 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: Responder channel properly validates the AUTHENTICATE cellDavid Goulet2026-03-191-11/+20
| | | | | | | | It is now validated against the received KP_link_ed of the initiator peer and we compare only the section of the AUTHENTICATE cell that we can compare (minus random bytes and sig). Signed-off-by: David Goulet <[email protected]>
* proto: Add specialized build functions for ChannelAuthenticationDataDavid Goulet2026-03-192-9/+6
| | | | | | | | | | | 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-193-56/+19
| | | | | | | | 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-193-11/+98
| | | | | | | | | | | | | | | | | | | | | | | | 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: Use RelayIds in a VerifiedChannelDavid Goulet2026-03-192-3/+5
| | | | | | | | | | | | | | | | In order to pull this off, make UnverifiedChannel::check_relay_identities() to return a RelayIds that it builds after checking if they match the peer we were expecting. This part is moved in this commit so once check_relay_identities() returns, we are certain of the relay identity validity on both "it identified properly" and "it is the right expected relay". This makes it that the check_relay_identities() returns the RelayIds, the signing key and the RSA id digest (which is needed for authentication later). Signed-off-by: David Goulet <[email protected]>
* tor-cell: rename `RestrictedMsg::restricted_cmds()` to `cmds_for_logging()`Steven Engler2026-03-041-1/+1
|
* tor-proto: small code cleanupSteven Engler2026-03-031-9/+3
|
* tor-proto: improve error messages using `RestrictedMsg`Steven Engler2026-03-031-19/+7
|
* tor-proto: improve error messages during handshakeSteven Engler2026-03-031-1/+2
|
* tor-proto: during handshake ensure circ id is 0Steven Engler2026-03-031-2/+9
|
* tor-proto: require cells from initiator to be orderedSteven Engler2026-03-031-61/+112
|