aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto
Commit message (Collapse)AuthorAgeFilesLines
...
* chanmgr configuration: Avoid sending needless initial update(s)Ian Jackson2022-08-161-5/+6
| | | | | | | | | | | Change ChannelsParams::initial_update to compare fields with their default values, and, if they're the same as the default, not to include them in the returned update. And if that update is then empty, return None. The overall effect is to avoid the call to chan.reparameterize if we're using the builtin default parameters, which is usual.
* channel: Use channel usage to control channel paddingIan Jackson2022-08-161-8/+111
| | | | | We introduce the per-channel state that is used to keep track of channel usage, and defer padding setup until it's wanted.
* channel: Provide somewhere for the frontend's mutable stateIan Jackson2022-08-161-0/+24
| | | | | Right now this is just furniture. We're going to put channel padding control state here.
* Provide ChannelUsage and plumb it all the way downIan Jackson2022-08-161-0/+27
| | | | | | | | | | | | | Channel padding depends on what the channel is being used for. We therefore need to let the channel code know this information. The implementation of the per-channel padding control logic will be in the new note_usage function, which for now is simply a stub. A future commit will introduce a `PaddingControlState` which lives in the channel frontend; consult the doc comment for that type to see why the plumbing through the channel manager terminates in the channel frontend.
* channel reparameterize: Change error typeIan Jackson2022-08-161-5/+3
| | | | This is going to be able to fail in other ways too, sadly.
* channel params: ChannelsParamssUpdates: provide combine()Ian Jackson2022-08-161-0/+13
| | | | | We're going to need this because the frontend is going to need to defer some channel padding parameters updates.
* channel params: Add a missing comma.Ian Jackson2022-08-161-1/+1
| | | | | | | Unfortunately, because we don't have derive-adhoc here yet, rustfmt didn't get to notice that this comma was needed. We are going to add field(s), so add the comma now.
* channel params: Rename initial_update (from total_update)Ian Jackson2022-08-161-3/+3
| | | | The semantics of this are going to become a bit more subtle.
* tor-proto: padding::Parameters: Provide all_zeroesIan Jackson2022-08-161-0/+10
| | | | | This exists so that we handle this case specially, as we will need to, and so that we can represent disablement in a Parameters.
* tor-proto: padding::Parameters::padding_negotiate_cellIan Jackson2022-08-161-1/+17
| | | | | The channel manager is going to use this as part of constructing the right cell for padding neogotiattion.
* tor-proto: padding::Parameters: Provide default_reduced constructorIan Jackson2022-08-161-0/+12
| | | | We're going to want this so that we can do reduced padding.
* channel padding: Add doc commentary with the channel padding planIan Jackson2022-08-162-0/+27
| | | | | | | Much of this does not exist yet. It will do by the end of this branch. Expand a doc note for ChannelsParamsUpdates too.
* channel: Centralise Channel::send_controlIan Jackson2022-08-161-14/+16
| | | | | | Replaces 4 open-coded call sites. I am going to add one more.
* tor-proto: padding::Parameters: use impl_standard_builderIan Jackson2022-08-162-7/+4
| | | | | | | This is more standard. It also provides the ::build() method. This isn't a config type, and build failures ought not to happen, so we use Bug for the error.
* tor-proto: Add a comment about the tor-proto layer.Nick Mathewson2022-08-101-0/+18
| | | | | | | | | We want to clarify that the tor-proto crate should only know _how_ its objects behave, not _why they behave that way_. (In other words, we can have a "padding strategy" setting on a channel, but not a "general usage" setting.) Closes #531.
* Clarify that tor-proto _does_ create timers.Nick Mathewson2022-08-101-4/+2
|
* Merge branch 'main' into 'linkspec_refactor_v3'Nick Mathewson2022-08-1010-80/+92
|\ | | | | | | # Conflicts: # crates/tor-netdir/semver.md
| * Merge branch 'zeroize' into 'main'Nick Mathewson2022-08-049-79/+91
| |\ | | | | | | | | | | | | | | | | | | Revise our handling of the zeroize trait Closes #254 See merge request tpo/core/arti!655
| | * tor-proto: Use correct SecretBuf in handshakes.Nick Mathewson2022-08-014-17/+27
| | | | | | | | | | | | | | | | | | | | | | | | Everything that is a secret encryption key, or an input that is used to produce a secret encryption key, has to get zeroized. And that's all! Closes #254.
| | * tor-proto: Replace SecretBytes with SecretBuf.Nick Mathewson2022-08-018-63/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This does not yet make sure that `SecretBuf` is used where it _should_ be, but at least it ensures that most uses of `SecretBytes` will indeed act as intended, and make sure that whatever they contain is zeroized. It requires some corresponding changes to method calls for correctness and type conformance.
| | * Use the `zeroize` feature in several cratesNick Mathewson2022-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using `zeroize` here tells these crates that they should make various structures zeroize-on-drop. (This is not yet implemented in `aes` 0.8.1, but support has been merged in the repository for `aes`, so it should go out in the next release.) No corresponding feature flag is needed to enable zeroize-on-drop for `rsa` and `*25519-dalek` private keys.
| * | Merge branch 'inc-rename' into 'main'Ian Jackson2022-08-022-1/+1
| |\ \ | | |/ | |/| | | | | | | | | | | | | Rename `.inc` and other included files to end in `.rs` Closes #381 See merge request tpo/core/arti!645
| | * Rename `.inc` and other included files to end in `.rs`eta2022-07-262-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to mitigate syntax highlighting issues and a rust-analyzer bug (https://github.com/rust-analyzer/rust-analyzer/issues/10178), rename files that are included with the `include!` macro to have a `.rs` extension. Make sure the included files are outside `src/`, in order to not confuse humans and automated editing tools that might mistake them for valid Rust modules. fixes arti#381
* | | tor-proto: Unify the check_match code in channel and handshakeNick Mathewson2022-08-103-46/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This had to become a new internal function, since at the point that the handshake needs this code, it does not yet have a Channel to use. This change made the error messages in the handshake code more informative: and now they require a regex to check. Later, we might want to defer formatting these strings, but I don't think we need to do it now.
* | | Final (?) API revisions for tor-linkspecNick Mathewson2022-08-106-60/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this change, each individual identity type becomes optional. The functions that expose them unconditionally are now in a "legacy" trait that only some downstream types are expected to implement. There are new convenience APIs in HasRelayIds: * to return Option<&keytype>, * to see if one identity-set contains another. This commit will break several downstream crates! For the reviewer's convenience, I will put the fixes for those crates into a series of squash! commits on this one. tor-netdir ---------- Revise tor-netdir to accept optional identities. This required some caveats and workarounds about the cases where we have to deal with a key type that the tor-netdir code does not currently recognize at all. If we start to add more identity types in the future, we may well want more internal indices in this code. tor-proto --------- In order to make tor-proto support optional identities, there were fewer changes than I thought. Some "check" functions needed to start looking at "all the ids we want" rather than at "the two known IDs"; they also needed to accommodate that case where we don't have an ID that we demand. This change will also help with bridges, since we want to be able to connect to a bridge without knowing all of its IDs up front. The protocol currently _requires_ the two current ID types in some places. To deal with that, I added a new `MissingId` error. I also removed a couple of unconditional identity accessors for chanmgr; code should use `target().identity(...)` instead. tor-chanmgr ----------- This is an incomplete conversion: it does not at all handle channel targets without Ed25519 identities yet. It still uses those identities to index its internal map from identity to channel; but it gives a new `MissingId` error type if it's given a channel target that doesn't have one. We'll want to revise the map type again down the road when we implement bridges, but I'd rather not step on the channel-padding work in progress right now. tor-guardmgr ------------ This change is mostly a matter of constructing owned identity types more sensibly, rather than unwrapping them directly. There are some places marked with TODOs where we still depend on particular identity types, because of how the directory protocol works. This will need revisiting when we add bridge support here. tor-circmgr ----------- These changes are just relatively simple API changes in the tests.
* | | tor-linkspec: Refactor out traits to represent a relay's ID set.Nick Mathewson2022-08-022-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We want the set of identities supported by a relay to be extensible in the future with minimal fuss; we'd also like to make working with these ID sets more convenient. To handle that, this commit adds a new trait for "Something that has the same IDs as a relay" and a new object for "an owned representation of a relay's IDs." This commit introduces a similar trait for "Something with a list of SocketAddr, like a relay has." There's no owned equivelent for that, since Vec<SocketAddr> is already a thing. Closes #428.
* | | Remove some testing-only reimplementations of OwnedChanTarget.Nick Mathewson2022-08-023-82/+12
|/ / | | | | | | These predate OwnedChanTarget, and are no longer needed.
* | Now that versions have bumped, remove semver.md files.Nick Mathewson2022-08-011-1/+0
| |
* | Bump patch versions on crates that have new APIs.Nick Mathewson2022-08-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Do _not_ bump the dependency versions on crates that have had no changes since arti 0.0.5, since those crates do not depend on the new APIs. ``` cargo set-version -p tor-basic-utils --bump patch cargo set-version -p tor-llcrypto --bump patch git restore crates/tor-checkable git restore crates/tor-consdiff git restore crates/tor-rtmock ```
* | Bump minor version on crates with deps with breaking changes.Nick Mathewson2022-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This performs the transitive closure of the last operation: everything that depends on a crate with a breaking change gets the version which it depends on bumped. ``` cargo set-version -p tor-proto --bump minor cargo set-version -p tor-netdoc --bump minor cargo set-version -p arti-hyper --bump minor cargo set-version -p arti-bench --bump minor cargo set-version -p arti-testing --bump minor cargo set-version -p tor-config --bump minor ```
* | Bump minor versions on all crates that have had breaking changes.Nick Mathewson2022-08-011-4/+4
|/ | | | | | | | | | | | | | | | | | | | | | Done with these commands: ``` cargo set-version -p fs-mistrust --bump minor cargo set-version -p tor-bytes --bump minor cargo set-version -p tor-socksproto --bump minor cargo set-version -p tor-cert --bump minor cargo set-version -p tor-linkspec --bump minor cargo set-version -p tor-cell --bump minor cargo set-version -p tor-netdir --bump minor cargo set-version -p tor-persist --bump minor cargo set-version -p tor-chanmgr --bump minor cargo set-version -p tor-guardmgr --bump minor cargo set-version -p tor-circmgr --bump minor cargo set-version -p tor-dirclient --bump minor cargo set-version -p tor-dirmgr --bump minor cargo set-version -p arti-client --bump minor cargo set-version -p arti --bump minor ```
* change usage of PublicKey to Ed25519 in tor-certtrinity-1686a2022-07-231-5/+3
| | | | and propagate to other affected crates
* change check_key to take a Option<&_> instead of &Option<_>trinity-1686a2022-07-231-2/+2
|
* tor-proto: Stop using write_infallible in handshake code.Nick Mathewson2022-07-115-138/+196
| | | | | | | | This change was a bit annoying, since most of this code _can't_ fail, and so the only reasonable response is to wrap the input in an internal error... except for one case where we're actually encoding a caller-provided message, so we _do_ want to wrap the EncodeError from tor_bytes.
* tor-cell: Make encoding method signatures fallible.Nick Mathewson2022-07-111-1/+5
|
* Remove "write_and_consume_infallible".Nick Mathewson2022-07-111-7/+12
| | | | | | There were only a few of these. Removing it required porting everything to use `write_and_consume` instead, and handling its (potential) errors.
* Rename "write" methods on tor-bytes to "write_infallible".Nick Mathewson2022-07-113-112/+112
| | | | | | | | | | | | | | | This comprises four renames: ``` write_onto -> write_onto_infallible write_into -> write_into_infallible write -> write_infallible writer_and_consume -> write_and_consume_infallible. ``` The rest of this branch will be concerned with replacing these `_infallible` methods with ones that return a `Result`. This is part of #513.
* Implement a higher-level API for the ntor v3 handshakeeta2022-07-081-23/+162
| | | | | | | | | | | | | | | | | | | This implements a higher-level API for the ntor v3 handshake, in line with that exposed by the ntor handshake. It does not, however, use the existing `ClientHandshake` trait, due to fundamental differences in the handshakes (namely, that the v3 handshake can include some additional extra extension data). Currently, the higher-level API assumes circuit extension, and copies the (undocumented!) magic verification string from c-tor that indicates this usage. A rudimentary set of functions for serializing and deserializing extensions to be sent with the handshake is also included, implementing the protocol in proposal 332 § A.2. Currently, it only implements the congestion control extensions specified in proposal 324 § 10.3. part of arti#88
* Update `rsa` dependency (and use `x25519-dalek` prerelease)eta2022-07-061-6/+5
| | | | | | | | | | | | | | - arti#448 and arti!607 highlight an issue with upgrading `rsa`: namely, the `x25519-dalek` version previously used has a hard dependency on `zeroize` 1.3, which creates a dependency conflict. - However, `x25519-dalek` version `2.0.0-pre.1` relaxes this dependency. Reviewing the changelogs, it doesn't look like that version is substantially different from the current one at all, so it should be safe to use despite the "prerelease" tag. - The new `x25519-dalek` version also bumps `rand_core`, which means we don't have to use the RNG compat wrapper in `tor-llcrypto` as much. closes arti#448
* Remove semver.md files now that 0.5.0 is outNick Mathewson2022-06-241-3/+0
|
* Bump crate and dependency versions.Nick Mathewson2022-06-241-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were done with the following commands: ``` cargo set-version -p tor-basic-utils --bump patch cargo set-version -p fs-mistrust --bump minor cargo set-version -p tor-error --bump patch cargo set-version -p tor-config --bump patch cargo set-version -p tor-units --bump patch cargo set-version -p tor-rtcompat --bump minor cargo set-version -p tor-llcrypto --bump patch cargo set-version -p tor-bytes --bump minor cargo set-version -p tor-socksproto --bump minor cargo set-version -p tor-cert --bump minor cargo set-version -p tor-cell --bump minor cargo set-version -p tor-proto --bump minor cargo set-version -p tor-netdoc --bump patch cargo set-version -p tor-netdir --bump minor cargo set-version -p tor-persist --bump patch cargo set-version -p tor-chanmgr --bump minor cargo set-version -p tor-guardmgr --bump minor cargo set-version -p tor-circmgr --bump patch cargo set-version -p tor-dirclient --bump patch cargo set-version -p tor-dirmgr --bump minor cargo set-version -p arti-client --bump patch cargo set-version -p arti --bump minor cargo set-version -p arti-bench --bump minor cargo set-version -p arti-testing --bump minor ```
* Merge branch 'clippy' into 'main'Ian Jackson2022-06-242-3/+12
|\ | | | | | | | | Fix clippy nightly again See merge request tpo/core/arti!603
| * clippy: Consolidate many lints in maint/add_warningIan Jackson2022-06-241-3/+9
| | | | | | | | | | | | Found these by disabling the nightly dbg macro special case. Now, we have a mechanism for globally adding suppressions to tests, we can use that instead.
| * Run maint/add_warning crates/*/src/{lib,main}.rsIan Jackson2022-06-231-0/+3
| | | | | | | | Update all lint blocks
* | tor-proto: split and elaborate tor_bytes::Error instancesNick Mathewson2022-06-236-21/+70
| | | | | | | | | | | | | | | | | | Some of these were for decoding particular objects (we now say what kind of objects), and some were unrelated tor_cert errors that for some reason we had shoved into a tor_bytes::Error. There is now a separate tor_cert::CertError type, independent from tor_cert's use of `tor_bytes::Error` for parsing errors.
* | tor-proto: Split CellErr based on activity.Nick Mathewson2022-06-236-18/+54
| | | | | | | | | | | | Failing to encode is fundamentally different from failing to decode. We now treat those separately, and describe _what_ we failed to encode or decode.
* | tor-proto: clean up error names and messagesNick Mathewson2022-06-2312-85/+90
|/ | | | | This avoids adding additional information for now; that will come on the next commits.
* Merge branch 'display_source_cleanup' into 'main'eta2022-06-212-9/+10
|\ | | | | | | | | Do not include error source() in display() format. See merge request tpo/core/arti!598
| * Do not include error source() in display() format.Nick Mathewson2022-06-212-9/+10
| | | | | | | | | | | | | | | | | | According to doc/Errors.md, and in keeping with current best practices, we should not include display an error's `source()` as part of that error's display method. Instead, we should let the caller decide to call source() and display that error in turn. Part of #323.
* | channel padding: Rename ChannelsParams from ChannelsConfig (rustfmt)Ian Jackson2022-06-212-2/+2
| | | | | | | | Consequential ordering changes.