aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src
Commit message (Collapse)AuthorAgeFilesLines
...
* | proto: Authenticate a relay channelDavid Goulet2026-01-223-32/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a bit loaded but it is coherent. First, we set Eq and PartialEq to the channel message Authenticate so we can compare it with the one we expected. Second, the AuthenticationCell enum is introduced to store either an AUTH_CHALLENGE or an AUTHENTICATE since one side of the handshake can only have one. This allows us to store one or the other in UnverifiedRelayChannel. Depending on what we have, the authentication process is different as it dictates which side we are on (initiator vs responder). Keep in mind that the handshake code enforces receiving a AUTH_CHALLENGE along side CERTS. And same goes for AUTHENTICATE which means that if we have an AUTH_CHALLENGE in the UnverifiedRelayChannel, it is certain that the other side wants to authenticate and we are the initiator. Finally, the sending of CERTS and AUTHENTICATE by the initiator is now in UnverifiedRelayChannel::check() done right after verifying the channel CERTS and holding a "VerifiedChannel" object. This means that the last piece, sending the `NETINFO` by the initiator will be done in the check() but in a future commit. This leaves the VerifiableChannel::finish() to send nothing and only finalize the channel with the NETINFO (canonicity). Signed-off-by: David Goulet <[email protected]>
* | proto: Make VerifiableChannel::check() asyncDavid Goulet2026-01-223-3/+6
| | | | | | | | | | | | | | | | | | Relay initiator needs to send CERTS and AUTHENTICATE in that function after verifiying the channel. And thus require to be async. Signed-off-by: David Goulet <[email protected]>
* | proto: Add CertifiedConn to relay handshakeDavid Goulet2026-01-222-17/+17
| | | | | | | | | | | | | | We need this trait for the underlying TLS stream in order to access data such as the certificates or keying material. Signed-off-by: David Goulet <[email protected]>
* | proto: Add relay link signing kp to RelayIdentitiesDavid Goulet2026-01-221-0/+5
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | proto: Add UnverifiedRelayChannel::build_auth_data()David Goulet2026-01-221-37/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reason for this is because both initiator and responder build the authentication data in order to send it (initiator) and validate it (responder). The build_auth_data() function takes a VerifiedChannel as an argument in order to access the CLOG/SLOG data and authentication data MUST always be handled after a channel is verified as in its CERTS has been checked. Take the opportunity also to add the NETINFO and relay identities data into the verified channel which will be needed to finalize the channel. The check() function is now missing the actual validation of the AUTHENTICATE for a responder which will come in the next commit(s). Signed-off-by: David Goulet <[email protected]>
* | proto: Implement RelayResponderHandshakeDavid Goulet2026-01-222-2/+264
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces the RelayResponderHandshake object used when accepting an inbound connection to open a channel. There are still TODOs pepperred in the code but the base is implemented. The Unverified and Verified channel need to be adjusted for this new handshake. This will come in the next commits. Signed-off-by: David Goulet <[email protected]>
* | proto: Add helper to build NETINFO cellDavid Goulet2026-01-221-13/+25
| | | | | | | | | | | | | | Again, as the CERTS helper, this is used by both initiator and responder handshake. Signed-off-by: David Goulet <[email protected]>
* | proto: Add a helper function to build CERTS cellDavid Goulet2026-01-221-1/+47
| | | | | | | | | | | | Both initiator and responder send CERTS cell hence this helper. Signed-off-by: David Goulet <[email protected]>
* | proto: Make CERTS cell optionnable for UnverifiedChannelDavid Goulet2026-01-225-21/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This requires to make a series of cert and digest also optionnable in the VerifiedChannel. This change is needed because as a relay responder, you might get the CERTS or not depending on if the other side wants to authenticate. Client and bridges do not authenticate and thus it is expected to not have a CERTS cell. This leads to the UnverifiedChannel::check() function to return early with a VerifiedChannel without any identity attached to it. Signed-off-by: David Goulet <[email protected]>
* | proto: Move relay channel related structs outside of handshake.rsDavid Goulet2026-01-222-269/+272
|/ | | | | | Code movement only. Signed-off-by: David Goulet <[email protected]>
* Merge branch 'ticket1599_02' into 'main'David Goulet2026-01-137-92/+164
|\ | | | | | | | | chanmgr: Ability for the ChanMgr to be channel type specific and launch relay channels See merge request tpo/core/arti!3563
| * proto: Fix comments documentationDavid Goulet2026-01-133-4/+4
| |
| * proto: Seal the VerifiableChannel and FinalizableChannel traitsDavid Goulet2026-01-133-2/+38
| | | | | | | | | | | | They are public but avoid anyone outside implementing them. Signed-off-by: David Goulet <[email protected]>
| * chanmgr: Spawn task for ChannelProvider impl of get_or_launch()David Goulet2026-01-131-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | To pull this off, ChannelProvider::get_or_launch() needed to change from "&self" to "self: Arc<Self>" so we could pass self to the spawned task. This is fine as the caller of ChannelProvider (circuit reactor) has a Arc<ChanMgr>. This also removes the PhantomData for the runtime as we now actually use it. Signed-off-by: David Goulet <[email protected]>
| * proto: Improve channel trait commentsDavid Goulet2026-01-131-0/+7
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
| * proto: Add link_protocol() to VerifiableChannel traitDavid Goulet2026-01-133-12/+16
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
| * chanmgr: Implement tor_proto::ChannelProvider for ChanMgrDavid Goulet2026-01-131-2/+4
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
| * proto: Add traits for public channel viewsDavid Goulet2026-01-135-93/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add traits that will be returned outside tor-proto allowing us to not expose client and relay specific channels. The goal is for the tor-chanmgr to get those objects implementing those traits and can build and run the reactor without knowing the specific underlying type. This allows us to have less code duplication and less client/relay distinction in the chanmgr. Signed-off-by: David Goulet <[email protected]>
| * proto: Add clock_skew() helper to relay unverified channelDavid Goulet2026-01-131-1/+13
| | | | | | | | Signed-off-by: David Goulet <[email protected]>
* | Merge branch 'dedupe-handler' into 'main'gabi-2502026-01-136-58/+48
|\ \ | |/ |/| | | | | proto: Dedupe IncomingStreamRequestHandler See merge request tpo/core/arti!3572
| * proto: Fix docs post-refactoringGabriela Moldovan2026-01-131-2/+2
| |
| * proto: Dedupe IncomingStreamRequestHandlerGabriela Moldovan2026-01-126-62/+47
| |
| * proto: Give IncomingStreamRequestHandler a HopNumGabriela Moldovan2026-01-122-1/+6
| | | | | | | | | | | | | | | | This currently duplicates the client `IncomingStreamRequestHandler`. To deduplicate it, we need the `hop_num` to be optional (it will be `None` for relays, and `Some(hopnum)` in the client reactor). The next commit will fix the code duplication.
* | proto: Update outdated reference to rxs in StreamMap docsGabriela Moldovan2026-01-121-1/+1
|/
* proto: Add an immediate order for client CircuitEvent orderingDavid Goulet2025-12-101-4/+7
| | | | | | | With a protocol violation, we have to immediately deal with such event before emitting anything on the wire. Signed-off-by: David Goulet <[email protected]>
* proto: Rename CircuitAction and cie to CircuitEventDavid Goulet2025-12-102-75/+67
| | | | | | | | | | This mirrors also the relay reactor. We've introduced the ProtoViolation into a previous commit which is not an action but rather an "event" that happened on a circuit. And so, better semantic. No behavior change. Signed-off-by: David Goulet <[email protected]>
* proto: #[macro_use] be gone!Gabriela Moldovan2025-12-104-2/+4
|
* proto: Rename Circuit{Action/Event}::Shutdown to ProtoViolationDavid Goulet2025-12-103-11/+12
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Add TODO in client reactor for bad cellDavid Goulet2025-12-101-0/+6
| | | | | | Because of https://gitlab.torproject.org/tpo/core/torspec/-/issues/385 Signed-off-by: David Goulet <[email protected]>
* proto: Move relay specific unit test to relay moduleDavid Goulet2025-12-102-25/+41
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Relay circuit reactor now handles AnyChanMsgDavid Goulet2025-12-103-12/+14
| | | | | | | Same as the client reactor, a message outside of our restricted set leads to a reactor shutdown. Signed-off-by: David Goulet <[email protected]>
* proto: Make ClientCircChanMsg pub(super)David Goulet2025-12-101-1/+1
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Move unit tests and minor fixDavid Goulet2025-12-103-24/+23
| | | | | | Move the client specific unit tests into the client module. Signed-off-by: David Goulet <[email protected]>
* proto: Client circuit reactor now handles AnyChanMsgDavid Goulet2025-12-109-34/+51
| | | | | | | | | | | | | | | This commit removes the CircuitRx* based solely on the client circuit message and moves it into the top level of the crate so all reactors can use them. The client reactor then upon receiving the message, it converts the AnyChanMsg into a ClientCircChanMsg. On error, this leads to a shutdown of the entire reactor due to a fatal error. In order to pull this off, we added a CircuitAction::Shutdown that is handled as a priority. Signed-off-by: David Goulet <[email protected]>
* proto: Move RelayCircChanMsg into relay moduleDavid Goulet2025-12-105-27/+29
| | | | | | This follows the move of the client specific object. Signed-off-by: David Goulet <[email protected]>
* proto: Move ClientCircChanMsg into client moduleDavid Goulet2025-12-107-34/+39
| | | | | | | | Next commit will also move the Relay specific set into the relay module. These two sets are becoming specific to the reactor as the circuit reactor communication channel will use AnyChanMsg instead. Signed-off-by: David Goulet <[email protected]>
* proto: Remove unused restricted channel msg setDavid Goulet2025-12-101-26/+0
| | | | Signed-off-by: David Goulet <[email protected]>
* Merge branch 'fix-relay-compile' into 'main'David Goulet2025-12-095-9/+14
|\ | | | | | | | | proto: Fix relay/hs-service feature gating See merge request tpo/core/arti!3534
| * proto: Remove outdated TODO about add_ent_with_id()Gabriela Moldovan2025-12-081-3/+0
| | | | | | | | We now have add_ent_with_id(), so we can just remove the TODO.
| * proto: Fix relay/hs-service feature gating (fmt)Gabriela Moldovan2025-12-081-1/+1
| |
| * proto: Fix relay/hs-service feature gatingGabriela Moldovan2025-12-085-6/+14
| | | | | | | | | | Without this, `tor-proto` doesn't compile if you enable the `relay` feature but not `hs-service`.
* | Remove unnecessary `doc(cfg(...))` attributesNeel Chauhan2025-12-046-9/+0
|/ | | | | | | | | Fixes part of #2193. (Edits from nickm: I selected the cases here that I could verify were correct from immediate context.) Edited-by: Nick Mathewson <[email protected]>
* proto: Add comment about create_firsthop_fastNick Mathewson2025-12-031-1/+2
|
* Merge branch 'relay-streams2' into 'main'David Goulet2025-12-0218-696/+1658
|\ | | | | | | | | proto: Start handling incoming streams in the relay reactor See merge request tpo/core/arti!3487
| * proto: Remove incorrect padding logicGabriela Moldovan2025-12-021-18/+5
| | | | | | | | | | This was all wrong, as mentioned in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3487#note_3296033
| * proto: Add TODO about our TRUNCATE plansGabriela Moldovan2025-12-021-0/+5
| |
| * proto: Move EXTEND handling to catch-all errorGabriela Moldovan2025-12-022-9/+0
| | | | | | | | | | Since EXTEND is not used anymore, it's fine to handle it in our catch-all branch for unrecognized/unsupported cells.
| * proto: Explain why we have the backward sink readiness checkGabriela Moldovan2025-12-021-4/+26
| |
| * proto: Resolve some clippy warnings, remove allowsGabriela Moldovan2025-11-242-6/+3
| |
| * proto: Reword a nonsensical TODOGabriela Moldovan2025-11-241-3/+15
| | | | | | | | | | | | This TODO was copied over from the client reactor, but it doesn't make any sense here (we don't yet handle control messages in the backward reactor).