summaryrefslogtreecommitdiff
path: root/crates/tor-cell/src
Commit message (Collapse)AuthorAgeFilesLines
* Allow clippy::collapsible_if to triggerGabriela Moldovan2026-02-161-0/+1
| | | | | | | | | `clippy::collapsible_if` started triggering after bumping the MSRV to 1.88. Since this triggers from a lot of places, and since there even are a couple of instances where we explicitly allow `clippy::collapsible_ifs`, I've opened #2342 for deciding what to do about it.
* proto: Implement a Canonicity structDavid Goulet2026-02-121-0/+12
| | | | | | | | | | | | | | | | | This struct will be put in a Channel and derived from the received NETINFO cell. This follows the C-tor implementation for which we have two indicator of canonicity: 1. Peer is canonical: the address they advertise in the NETINFO cell matches the one we see on the TCP connection. 2. Canonical to peer: the peer sees us as canonical. Those flag will get used to select "the best" channel. Signed-off-by: David Goulet <[email protected]>
* cell: Add an accessor for the linkspecs of an EXTEND2Gabriela Moldovan2026-02-051-0/+5
|
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* proto: Authenticate a relay channelDavid Goulet2026-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* Remove unnecessary `doc(cfg(...))` attributesNeel Chauhan2025-12-041-3/+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]>
* cell: Add missing docs to internal macroGabriela Moldovan2025-12-011-0/+2
|
* Merge branch 'bug2172' into 'main'Nick Mathewson2025-11-241-1/+1
|\ | | | | | | | | | | | | tor-llcrypto: Stop deriving Deref in CtByteArray Closes #2172 See merge request tpo/core/arti!3432
| * tor-llcrypto: Stop deriving Deref in CtByteArrayNeel Chauhan2025-11-241-1/+1
| |
* | Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-065-5/+5
| | | | | | | | Run maint/add_warning
* | Decorate a use with an allowIan Jackson2025-11-061-0/+1
|/ | | | | | | This seems to depend on cfgs. As I say in #1060, I don't think precise cfg decoration of imports is sensible. Also, it shouldn't be my job to fix whatever this is...
* proto: Add the channel authentication dataDavid Goulet2025-10-231-0/+5
| | | | | | | | | | | This commit only adds a struct holding all the authentication data that needs to be built during the verification process after all handshake cells needed for authentication have been sent. It lives in the VerifiedChannel struct so it can be used to build the AUTHENTICATE cell and be sent before the NETINFO. Signed-off-by: David Goulet <[email protected]>
* Remove a couple of unused imports.Nick Mathewson2025-10-161-1/+0
|
* Remove "doc_auto_cfg" incantation from all crates.Nick Mathewson2025-09-291-1/+1
| | | | This feature has been removed from nightly, in favor of doc_cfg.
* tor-cell: add `Display` impl for `XonKbpsEwma`Steven Engler2025-09-221-0/+9
|
* tor-cell: add pub `PAYLOAD_MAX_SIZE_{ALL,ANY}`Steven Engler2025-09-151-0/+50
|
* padding: Report when we have received padding or data.Nick Mathewson2025-09-021-0/+11
| | | | (This was so much easier than reporting on the send side.)
* proto: Remove the AUTHORIZE as a parsable cellDavid Goulet2025-08-212-36/+1
| | | | | | | | | | | | | The AUTHORIZE cell command is simply reserved but not defined. The tor specification, at this point in time, is allowing such cell before the handshake starts but it is very unclear on what ordering is allowed nor how many can are allowed. C-tor silents drop them like VPADDING and so clearly unused. Instead of dealing with it, simply remove its support but keeping its reserved number. Signed-off-by: David Goulet <[email protected]>
* proto: Make the OutboundClientHandshake use new cell handlerDavid Goulet2025-08-201-1/+1
| | | | | | | | | | | | | | | | | Use the ChannelFrame<> for the entirety of the outbound client handshake that is the ClientInitiator channel type. With this change, the codec.rs code is not needed anymore along its CodecError as well which has been normalized onto the crate::Error instead in order to simplify error handling and avoid duplication of error types. Unit tests have been modified to reflect this change of what can be done with a channel frame. Also renamed to focus on client behavior. Part of #1597 Signed-off-by: David Goulet <[email protected]>
* cell: Add helper functionsDavid Goulet2025-08-201-0/+5
| | | | | | | | | | | | Add is_known_cmd() to the restricted_msg!() macro which can be used to learn if a specific ChanCmd is part of the restricted set or not. Then add a simple function to get the link protocol version from a channel codec. Part of #1597 Signed-off-by: David Goulet <[email protected]>
* tor-hsservice: Change capping of PoW effort.Wesley Aptekar-Cassels2025-08-131-10/+0
| | | | | | | | This caps the PoW effort during sorting, rather than at intake. This allows us to record efforts that are capped in our metrics histogram while only recording metrics after the PoW solve has actually been verified.
* tor-cell: fix comment in `ChannelCodec::encode`Steven Engler2025-08-121-1/+3
| | | | | | This comment isn't correct if the encode() was given a non-empty buffer (for example if two cells were written to the same buffer, the second encode() would be given a non-empty buffer, so `pos != 5`).
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-0710-25/+21
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* Merge branch 'msrv-fixes' into 'main'Nick Mathewson2025-08-051-5/+11
|\ | | | | | | | | Resolve a few issues that had been waiting for an MSRV update. See merge request tpo/core/arti!3129
| * tor-cell: Check strictly-ascending property more efficientlyNick Mathewson2025-08-051-5/+11
| | | | | | | | | | | | I had been planning to use `[]::is_sorted` here, once we had MSRV >= 1.82, but it turns out that we wanted strictly ascending sequence, whereas `is_sorted` checks for a non-descreasing sequence.
* | tor-cell: Add ProofOfWorkV1::cap_effort function.Wesley Aptekar-Cassels2025-08-051-0/+10
|/
* tor-cell: add `FlowCtrlVersion::V0`Steven Engler2025-07-161-0/+3
|
* tor-cell: change `UnparsedRelayMsg::data_len`Steven Engler2025-07-151-6/+32
| | | | | | | | | It now performs some validation and can return a `Result`. We perform validation here since different cell formats may have different maximum data lengths in the future, and `UnparsedRelayMsg` doesn't expose the cell format so it's difficult to perform this validation at a higher layer.
* tor-cell: remove `flowctl-cc` feature and make XON/XOFF cells stableSteven Engler2025-07-152-8/+1
| | | | | I don't see any further changes being needed for these types, and it simplifies a lot of future code in tor-proto that uses these types.
* tor-cell: add a const constructor for `FlowCtrlVersion`Steven Engler2025-07-151-7/+14
|
* Temporarily suppress mismatched_lifetime_syntaxes.Gabriela Moldovan2025-07-071-0/+1
| | | | See #2060.
* tor-cell: fix incorrect XON/XOFF cell command integersSteven Engler2025-06-231-5/+5
|
* tor-cell: add `Xon`/`Xoff` cellsSteven Engler2025-06-093-1/+185
|
* arti, cell, dirclient: Use expect instead of unwrap.Nick Mathewson2025-05-291-2/+3
| | | | | | Clippy nightly detects this problem, though earlier clippy verisons haven't. The common element here is applying unwrap() to the result from a write!().
* cell: fix warning from nightly about unused function.Nick Mathewson2025-05-291-0/+1
|
* Add methods for getting proof-of-work extension from intro request.Wesley Aptekar-Cassels2025-05-272-1/+10
|
* cell: Teach extlist definition macro to make conditional extensionsNick Mathewson2025-05-072-1/+7
| | | | | We need the macro to propagate only certain #[meta] values to all places where a case is used.
* cell: Implement SubprotocolRequest extension from prop346.Nick Mathewson2025-05-071-1/+138
| | | | Part of #1945.
* cell: Unify HS-ntor and ntor-v3 extensions.Nick Mathewson2025-05-076-32/+22
| | | | | | Implements proposal 358. Closes #1946.
* cell,proto: Split request/response extensions into seprate typesNick Mathewson2025-05-071-21/+44
| | | | Implements part of proposal 358.
* cell: Use ExtList to implement CircRequestExt.Nick Mathewson2025-05-072-105/+100
| | | | This required some renaming, so that the types and their codes matched.
* Rename NtorV3Extension to CircRequestExtNick Mathewson2025-05-071-18/+19
| | | | | | | This type will, because of prop358, be shared by ntorv3, hs-ntor, and probably other future handshakes. There will also be a CircResponseExt type.
* cell: Make decl_extension_group macro more self-contained.Nick Mathewson2025-05-074-14/+21
| | | | Previously it required the caller to import a whole bunch of stuff.
* cell: Clarify documentation in extlist.rs.Nick Mathewson2025-05-071-11/+10
| | | | It is no longer hs only.
* cell: move ExtList module out of hs module.Nick Mathewson2025-05-076-7/+6
| | | | We're going to use it for ntorv3 extensions as well.
* proto, cell: Remove RelayCellFormatTrait.Nick Mathewson2025-05-061-51/+0
| | | | | | | | | | | | | | | | The purpose of the trait was to parameterize the tor1 cell crypto on the different possible relay cell layouts. It made sense to have this trait when we thought we would implement the new cell layout for prop340 (packed-and-fragmented) well before we implemented CGO. But it now appears all but certain that CGO will land long before we make any more headway on prop340. Therefore, it doesn't make sense to carry the ability to customize `tor1` for other relay cell layouts. Removing this trait saves a fair bit of complexity.
* proto: Use SendmeTag in place of CircTagNick Mathewson2025-05-061-4/+2
| | | | | This doesn't make much change yet, but does save us an allocation when handling SENDMEs.
* tor-cell: define a new SendmeTag typeNick Mathewson2025-05-061-9/+149
| | | | | | | | | | | | | | | | This is a more efficient representation for the tag on an authenticated SENDME message: it comes in at 21 bytes. Previously, we used Vec<u8>, which has 24 bytes of overhead (on a 64 bit system), plus malloc overhead, plus 20 bytes of allocated tag. We had a similar type to this as `tor_proto::congestion::sendme::CircTag`, but it could only accomodate 20-byte values. I don't expect that we will have enough of these simultaneously that the memory savings will matter, but the allocation savings could be significant.
* tor-cell: optimize slice indexingSteven Engler2025-04-301-2/+2
|
* tor-cell: rename `STREAM_ID_OFFSET` to `STREAM_ID_OFFSET_V0`Steven Engler2025-04-301-3/+3
|