Commit Graph

585 Commits

Author SHA1 Message Date
Nick Mathewson 23c67d92e6 Run "fixup-features". 2023-06-29 17:09:52 -04:00
Nick Mathewson d164a9dac2 Mark all {hs,onion-serivce}-client features as non-experimental. 2023-06-29 13:09:37 -04:00
Nick Mathewson 2944d4f91f proto: ClientCirc: remove now-obsolete note on Clone-ness 2023-06-28 15:26:22 -04:00
Nick Mathewson 644c51173a proto: document ClientCirc lifecycle better. 2023-06-28 15:26:22 -04:00
Nick Mathewson e8e95ec03b proto: document channel lifecycle better. 2023-06-28 15:26:22 -04:00
Nick Mathewson f778d32a0e Merge branch 'ticket_914' into 'main'
Remove support for receiving unauthenticated SENDMEs.

Closes #914

See merge request tpo/core/arti!1283
2023-06-28 10:54:05 +00:00
pinkforest 4be2e3ce0f Back down x25519-dalek to 2.0.0-pre.1 from 2.0.0-rc.2
=========================
Notes from nickm:

(This differs from pinkforest's original MR: It removes the
Cargo.lock changes and the version bump on tor-llcrypto.)

Minimal Cargo.lock changes from downgrade.

(These are exactly those changes generated by running "build" and
"test".)

There are several reasons to do this:

  * It's best to bump all of our dalek dependencies at once to rc.3
    or later, rather than the piecemeal approach we've been stuck
    with so far.

  * We don't want to do this bump right now, since there are some
    tricky questions about clamping we need to figure out (see
    #808), and we need to make sure we get them right, and we're in
    a distracted this week.

  * We _do_ need to move away from 2.0.0-rc.2 right now, since
    it was causing a failure in `cargo install arti`, and then it
    got yanked.

Thanks to pinkforest for helping us out here and explaining all of
this!

Fixes #926.

Commit-edited-by: Nick Mathewson <nickm@torproject.org>
2023-06-27 13:55:24 -04:00
Nick Mathewson 0bffdf23a4 Upgrade to itertools 0.11.0
The breaking changes here do not seem to affect us.
2023-06-26 09:30:54 -04:00
Nick Mathewson f4a4c11627 proto: Remove support for receiving unauthenticated SENDMEs
We haven't generated these since Tor 0.3.5, which is no longer
supported on the network.

Closes #914.
2023-06-26 08:38:24 -04:00
Nick Mathewson 1249d803fb Merge branch 'proto-better-path' into 'main'
Better API for getting circuit paths

Closes #787

See merge request tpo/core/arti!1286
2023-06-22 17:53:23 +00:00
Nick Mathewson 8a6836cf4a proto: Resolve/downgrade some path-related "TODO HS" items 2023-06-22 09:45:47 -04:00
Nick Mathewson f80a1189a5 proto: Implement Redactable and Display for PathEntry. 2023-06-22 09:45:47 -04:00
Nick Mathewson f2fc086594 proto: Add ClientCirc::path_ref(), deprecate path().
The new path_ref() method returns an Arc<Path>, which gives a much
better API for reasons discussed in the new documentation of path().

(We could just replace path() if we'd prefer, but IMO having
path_ref() here isn't so bad.)
2023-06-22 09:45:47 -04:00
Nick Mathewson b64cf3f6f0 proto: Make Path and PathEntry at least minimally useful
(I'm not 100% sure about having both hops() and iter(). Should I
remove one?)
2023-06-22 09:45:47 -04:00
Nick Mathewson 1e1a76f7ac proto: Expose an opaque PathEntry.
The new PathEntry struct wraps the old PathEntry enum, which has
been renamed to HopDetail.  It's an opaque struct because we want to
be able to put new information in the enum as we think best.
2023-06-22 09:45:47 -04:00
Nick Mathewson e6735cdd9d proto: Make Path public
(You can't get one yet or do much with it.)
2023-06-22 08:37:34 -04:00
Nick Mathewson 8609b9f92a proto: Remove Mutex from Path.
Now Path is a regular struct with no interior mutability, and we use
Arc::make_mut() for the case when we need to add a hop.
2023-06-22 08:37:18 -04:00
Nick Mathewson 2d3739bfe1 proto: Move Path into a separate shared mutable structure
(We're about to remove the interior mutability from Path.)
2023-06-22 08:23:51 -04:00
Nick Mathewson ea99e728d2 proto: Downgrade a comment about unauthenticated SENDMEs
We never actually need to allow these again; see #914
2023-06-21 15:42:19 -04:00
Nick Mathewson fa9a3821a6 proto::circuit:🤝 downgrade a "TODO HS". 2023-06-21 15:09:02 -04:00
Nick Mathewson 5912509b05 proto: Put client and service hs_ntor behind individual features
This lets us keep the service-side hs-ntor handshake experiemental
for now.
2023-06-21 15:06:20 -04:00
Nick Mathewson cc8c3c0d7d proto: Resolve some hs_ntor "TODO HS" comments. 2023-06-21 14:58:54 -04:00
Nick Mathewson a317476520 proto: downgrade some "TODO HS" comments to "HSS"
These are all related to issues that will come up for the service
side of the onion service implementation.
2023-06-21 14:52:50 -04:00
Ian Jackson 161b9844da lints: Run maint/add_warning to actually apply new lints 2023-06-21 12:15:41 +01:00
Nick Mathewson 25db56777c Lower tor-proto::util::ct::lookup to tor-llcrypto
This is mostly code movement; you may want to review it with
`--color-moved`.

I'm doing this so we can also use the function in netdoc for
looking up hsdesc authentication.
2023-06-16 12:24:05 -04:00
Nick Mathewson 40840b1f3a proto: Make sure that auth tags are truncated to 20 bytes
Onion service hops (pointlessly) use SHA3-256 for their
authentication, but they truncate it to 20 bytes (assuming I'm
reading the C right.)

See torspec#204 for clarification here.
2023-06-13 11:04:23 -04:00
Nick Mathewson beecf3c92c proto: Convert MsgHandler API to expect a message, not a cell.
Closes #887.
2023-06-12 14:55:26 -04:00
Nick Mathewson f78c5a5a42 proto: Add a commment about a problem in my hs_ntor plans.
I am pretty sure that C tor works around this somehow; we should
figure out how!
2023-06-12 13:15:59 -04:00
Nick Mathewson c38ba16a81 proto: code movement and reindentation in hs_ntor 2023-06-12 13:15:59 -04:00
Nick Mathewson 7255b122d7 proto: Remove now-unused hs_ntor APIs 2023-06-12 13:15:59 -04:00
Nick Mathewson bb6115103a proto: refactor hs_ntor to reuse state.
We want the ability to send the same handshake request in parallel
on multiple introduce circuits.  This implies encoding the client
handshake more than once.

(Sadly we can't _actually_ do this in the protocol as it stands,
since the onion service can use a separate KP_hss_ntor for each
introduction point; I'll add a comment to that effect later.)
2023-06-12 13:15:59 -04:00
Ian Jackson 4ee4de2d0a Apply 1 suggestion(s) to 1 file(s) 2023-06-12 13:49:18 +00:00
Nick Mathewson c76fbff125 proto: Have send_control_message take an AnyRelayMsg.
When we break the 1:1 relationship of message and cell, we'll want
this API to take messages, not cells.

This API is experimental, so we don't need to call it a semver
break.

Closes #881.
2023-06-09 15:28:01 -04:00
Nick Mathewson 58babcb756 proto: Correct the docs on send_control_message
Formerly we said that it would not return until the handler
was uninstalled.  This is incorrect: it returns as soon as the
message is sent and the handler installed.

Closes #885.
2023-06-09 15:22:15 -04:00
Ian Jackson e35cd4f115 Fix a silly clippy warning
Fixes
  nailing-cargo +stable clippy -p tor-hsclient --all-features --all-targets
2023-06-08 15:29:06 +01:00
Nick Mathewson e7ebb31009 Merge branch 'remove_arrayref' into 'main'
Remove use of arrayref

Closes #872

See merge request tpo/core/arti!1214
2023-06-06 00:37:31 +00:00
Ian Jackson 660726b2f0 tor-circmgr: send_control_message: Add reference to MR discussion 2023-06-05 13:54:49 +01:00
Ian Jackson bfe575bc64 tor-circmgr: send_control_message: Change a rename proposal
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1218#note_2908119
2023-06-05 13:51:01 +01:00
Ian Jackson 9b36697282 tor-circmgr: send_control_message: Fix reference to circuit 2023-06-05 13:50:51 +01:00
Ian Jackson e35d4e6a46 tor-circmgr: send_control_message: API change proposal
I am hoping we can merge this as a "TODO (Diziet)",  even though I
think it may be controversial.  Ie merging this doesn't represent a
decision to do as I suggest.
2023-06-05 13:19:58 +01:00
Ian Jackson eecbf85b4c tor-circmgr: Propose to rename `MetaCellDisposition::UninstallHandler` 2023-06-05 13:19:58 +01:00
Ian Jackson a9ff778ba5 tor-circmgr: send_control_message: Clarify some corner cases
Also, no longer talk about handlers being "installed".  That's not
something that's exposed by this API.

And, say that `send_control_message` can be called again only
after *`send_control_message`* returns, not when `handle_msg` has
returned `UinstallHandler`.  IMO this makes more sense.

Explain that we can't maintain a continuous watch while holding a
conversation with the peer.  (This is surely an API bug.)
2023-06-05 13:19:58 +01:00
Nick Mathewson 469f62a983 Remove semver.md files from 1.1.5 2023-06-01 14:08:24 -04:00
Nick Mathewson 46d2a768a1 tor-proto: Remove use of arrayref. 2023-06-01 10:32:00 -04:00
Nick Mathewson daf5ecc153 Bump crate versions in preparation for v1.1.5 release.
Generated with the following commands:

```
cargo set-version --bump minor -p tor-cell
cargo set-version --bump minor -p tor-linkspec
cargo set-version --bump minor -p tor-proto
cargo set-version --bump minor -p tor-netdoc
cargo set-version --bump minor -p tor-circmgr

cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-basic-utils
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-hscrypto
cargo set-version --bump patch -p tor-checkable
cargo set-version --bump patch -p tor-async-utils
cargo set-version --bump patch -p caret
cargo set-version --bump patch -p fs-mistrust
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p retry-error
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-events
cargo set-version --bump patch -p tor-units
cargo set-version --bump patch -p tor-rtcompat
cargo set-version --bump patch -p tor-rtmock
cargo set-version --bump patch -p tor-protover
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-socksproto
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-congestion
cargo set-version --bump patch -p tor-persist
cargo set-version --bump patch -p tor-chanmgr
cargo set-version --bump patch -p tor-ptmgr
cargo set-version --bump patch -p tor-guardmgr
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-hsclient
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p arti-rpcserver
cargo set-version --bump patch -p arti-config
cargo set-version --bump patch -p arti-hyper
cargo set-version --bump patch -p arti
cargo set-version --bump patch -p arti-bench
cargo set-version --bump patch -p arti-testing
```
2023-06-01 10:03:05 -04:00
Nick Mathewson 8d32e1f65f Run fixup-features script and resolve its complaints. 2023-05-31 08:04:10 -04:00
Nick Mathewson 6703f3d52a Merge branch 'stream_ctrl' into 'main'
Experimental new stream-ctrl feature

Closes #847

See merge request tpo/core/arti!1198
2023-05-24 20:01:40 +00:00
Nick Mathewson e4758a754e Add "TODO RPC" notes around DataStreamCtrl per review. 2023-05-24 15:25:33 -04:00
Nick Mathewson a397ca77d9 proto: Add stream-status functionality to DataStreamCtrl.
There are some weaknesses and problems here; see TODO notes.
2023-05-24 15:25:33 -04:00
Nick Mathewson 03c81ae5aa proto: Make PathEntry::Virtual feature-conditional.
This fixes a warning when building tor-proto without the
`rpc-common` feature.
2023-05-23 10:59:37 -04:00
Nick Mathewson 0df0cf4250 proto: Create a `DataStreamCtrl` type.
The idea here is that we want to make DataStream visible to the
RPC system without requiring that the RPC session hold the
DataStream itself (or the Reader, or the Writer).  We could solve
this problem by making _all_ the state in the DataStream shared,
but that would introduce unnecessary extra locking in our critical
path.

Instead we're creating the notion of a "control handle" that lets
you manage and observe a stream without actually owning the stream.

Right now the only supported functionality is asking for the
stream's circuit.

Part of #847
2023-05-22 11:27:44 -04:00
Nick Mathewson 0765412fc8 proto: Add a new experimental stream-ctrl feature.
(It doesn't do anything yet. It may eventually become always-on.
But for now let's make this API optional.  Part of #847)
2023-05-22 09:07:03 -04:00
Nick Mathewson b55a3ade33 tor-proto: Move a comment in Cargo.toml 2023-05-22 09:04:44 -04:00
Nick Mathewson f333c9029a Merge branch 'virtual_hop' into 'main'
tor-proto: Add support for extending circuits through virtual hops.

Closes #726

See merge request tpo/core/arti!1191
2023-05-18 17:14:01 +00:00
Nick Mathewson 6f80caed9d proto: Explain "virtual" hops better.
Based on text from @diziet
2023-05-18 12:40:02 -04:00
Nick Mathewson 0230e7bccc proto: Try to improve the documentation in crypto/cell.rs 2023-05-18 12:40:02 -04:00
Nick Mathewson 3b7a20ef4c proto: Allow circuit Paths to represent virtual hops.
Sadly, this adds a few more `TODO HS` entries, but I think we can
clean them up later after a bit of discussion.
2023-05-18 12:40:02 -04:00
Nick Mathewson 663f25d44c proto: Implement Circuit::extend_virtual.
There are a few new TODO hs comments, though, and an XXXX I'll need
to fix up in the next commit.

Implements #726.
2023-05-18 12:40:02 -04:00
Nick Mathewson b9a848a7ac tor-proto: Code to construct crypto layers for virtual hops.
This is fairly straightforward, thanks to our existing design work
on this code.
2023-05-18 12:40:02 -04:00
eta 4665835ee8 tor-guardmgr, tor-proto: minor logging tweaks
- We make the tor-guardmgr "We have found that {} is usable" line
  include the word "guard", otherwise it doesn't appear very useful to a
  user in safe logging mode, since the guard gets replaced with
  [scrubbed].
- The "Actually got an end cell..." message is downgraded to DEBUG.
2023-05-18 16:04:11 +01:00
Nick Mathewson d008c385d5 hs_ntor: several documentation cleanups. 2023-05-17 16:18:55 -04:00
Nick Mathewson 954b41dcf1 hs_ntor: make encrypt_and_mac take a typed public key
This is still not the most beautiful interface, but it'll do for now.
2023-05-17 16:18:55 -04:00
Nick Mathewson 50ce084d64 hs_ntor: remove the last lingering AsRef<[u8]> 2023-05-17 16:18:55 -04:00
Nick Mathewson a6fd8fb347 hs_ntor: Add a test vector case extracted from C tor. 2023-05-17 16:18:55 -04:00
Nick Mathewson 20d6c4b247 hs_ntor: Calculate MAC on introduce1 message correctly.
There were two bugs here that made the behavior unlike that of C
tor: we had swapped the MAC inputs, and we had forgotten to include
the public key X in the input.
2023-05-17 16:18:55 -04:00
Nick Mathewson 1f665d1144 hs_ntor: Make internal no-rng variants of the handshake functions.
We'll want these so we can implement some test vectors.
2023-05-17 16:18:55 -04:00
Nick Mathewson ceaeb61168 hs_ntor: Move extra data outside of the "input" fields.
I think that these Input structs had been defined so that we could
use hs_ntor interchangeably with other handshakes.  The trouble is,
though, that it doesn't really work like any other handshakes we
have.
2023-05-17 16:18:55 -04:00
Nick Mathewson 54665c2b65 hs_ntor: Use MAC implementation from tor-hscrypto
Note that some of the invocations for this function seem to put the
key and the message in a questionable order.  But that's a thing to
figure out later, while debugging.
2023-05-17 16:18:55 -04:00
Nick Mathewson c8ad9450c2 hs_ntor: Use correct PK types from tor_hscrypto. 2023-05-17 16:18:55 -04:00
Nick Mathewson 9d5dd813c0 hs_ntor: Use Subcredential type from tor-hscrypto 2023-05-17 16:18:55 -04:00
gabi-250 fb8bc19b9b Merge branch 'arc_circ' into 'main'
Refactor ClientCirc APIs to use Arc<ClientCirc>.

Closes #846

See merge request tpo/core/arti!1187
2023-05-17 09:47:19 +00:00
Nick Mathewson b84f122aab Merge branch 'ticket_759' into 'main'
tor-cert: Replace the KeyUnknownCert::check_key API

Closes #759

See merge request tpo/core/arti!1184
2023-05-16 22:23:17 +00:00
Nick Mathewson 56c6e4345b Replace usage of KeyUnknownCert::check_key. 2023-05-16 17:53:15 -04:00
Nick Mathewson ee390c423e Refactor ClientCirc APIs to use Arc<ClientCirc>.
Now ClientCirc is no longer `Clone`, and the things that need it
to be `Clone` instead return and use an Arc<ClientCirc>
We're doing this so that ClientCirc can participate in the RPC
system, and so that its semantics are more obvious.

Closes #846.

Thanks to the type system, this was a much simpler refactoring than
I had feared it would be.
2023-05-16 09:02:09 -04:00
Nick Mathewson 6fa821238d Revise all XXXXs from fixup-features 2023-05-15 11:00:28 -04:00
Nick Mathewson 4b08ef76a0 Run fixup-features _with_ annotations.
This litters our Cargo.toml files with "XXX" entries that we should
fix.
2023-05-15 10:41:32 -04:00
Nick Mathewson e2e125fef7 Reformat Cargo.toml files. 2023-05-15 09:09:43 -04:00
Nick Mathewson 7a5373c110 Run fixup-features --no-annotate for initial Cargo.toml fixes.
This does the following:
  - Gives every crate a `full`.
  - Cause every `full` to depend on `full` from the lower-level
    crates.
  - Makes every feature listed _directly_ in `experimental` depend
    on `__is_experimental`.
2023-05-15 09:07:21 -04:00
Nick Mathewson bfda3082d4 Use non-deprecated *Secret::random_from_rng.
The `new` function is deprecated in x25519-dalek 2.0.0-rc.2
2023-05-13 16:52:23 -04:00
Nick Mathewson 7ce808b75b Change CircTarget::linkspecs() to return an encoded list.
If we didn't do this, we would need to transfrom
`EncodedLinkSpec`s into a `LinkSpec::Unrecognized`, which is not
semantically right.  What's more, every user of this API wants to
consume encoded link specifiers, so encoding them early saves a
little effort.
2023-05-10 12:30:32 -04:00
Nick Mathewson e845a553f3 Upgrade tracing to 0.1.36.
This is the first version to impl Value for String.

With luck, this will get minimal_versions CI passing.
2023-05-03 11:09:21 -04:00
Nick Mathewson 1904cfc8b9 Increment crate versions.
Because of the errorkind bumps, we're calling this a breaking change
in everything lower-level than `arti`.

Generated with:
```
cargo set-version -p tor-basic-utils --bump minor
cargo set-version -p tor-async-utils --bump minor
cargo set-version -p caret --bump minor
cargo set-version -p fs-mistrust --bump minor
cargo set-version -p safelog --bump minor
cargo set-version -p retry-error --bump minor
cargo set-version -p tor-error --bump minor
cargo set-version -p tor-config --bump minor
cargo set-version -p tor-events --bump minor
cargo set-version -p tor-units --bump minor
cargo set-version -p tor-rtcompat --bump minor
cargo set-version -p tor-rtmock --bump minor
cargo set-version -p tor-rpcbase --bump minor
cargo set-version -p tor-llcrypto --bump minor
cargo set-version -p tor-protover --bump minor
cargo set-version -p tor-bytes --bump minor
cargo set-version -p tor-hscrypto --bump minor
cargo set-version -p tor-socksproto --bump minor
cargo set-version -p tor-checkable --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-proto --bump minor
cargo set-version -p tor-netdoc --bump minor
cargo set-version -p tor-consdiff --bump minor
cargo set-version -p tor-netdir --bump minor
cargo set-version -p tor-congestion --bump minor
cargo set-version -p tor-persist --bump minor
cargo set-version -p tor-chanmgr --bump minor
cargo set-version -p tor-ptmgr --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 tor-hsclient --bump minor
cargo set-version -p tor-hsservice --bump minor
cargo set-version -p arti-client --bump minor
cargo set-version -p arti-rpcserver --bump minor
cargo set-version -p arti-config --bump minor
cargo set-version -p arti-hyper --bump minor

cargo set-version -p arti --bump patch
cargo set-version -p arti-bench --bump patch
cargo set-version -p arti-testing --bump patch
```
2023-05-03 08:31:11 -04:00
Nick Mathewson 5cd5e6a3f8 async-utils: rename SinkExt to SinkPrepareExt 2023-04-19 12:38:26 -04:00
Nick Mathewson 4efb423947 Upgrade our hex-literal dependency 2023-04-13 07:51:26 -04:00
Nick Mathewson 3f269449cb tor-proto: Be explicit about an into().
This is a workaround for an issue that I'm about to encounter
somewhere in our pile of dependencies as I add arti-rpcserver, and
somehow make serde_json visible in this test code thereby, making
the PartialEq method resolution ambiguous.
2023-04-12 07:34:57 -04:00
Nick Mathewson 104d64589d Increment MSRV to 1.65 in every crate. 2023-04-11 15:31:12 -04:00
Nick Mathewson 2ab5348ab2 Remove semver.md files. 2023-03-31 09:24:41 -04:00
Nick Mathewson 9ef115a7fb Patchlevel bumps for crates whose dependencies just changed.
These crates had no changes until just a moment ago. But since
we updated the versions on some of their dependents, they have now
changed themselves.  Thus they get patchlevel bumps.

```
tor-rtmock
tor-protover
tor-socksproto
tor-consdiff
tor-chanmgr
tor-dirclient
tor-hsservice
```
2023-03-31 08:30:14 -04:00
Nick Mathewson e208fb15ad Bump crate versions that have breaking changes
These crates have had breaking changes.  They are pre-1.0, so they get
a minor bump.

```
tor-basic-utils
tor-config
```
2023-03-31 08:28:06 -04:00
Nick Mathewson a81ab391ae Bump patchlevel on crates with non-breaking changes
For these crates, the changes are nontrivial, so we
_do_ bump the versions on which their dependent crates depend.

Fortunately, since they are all pre-1.0, we don't need to
distinguish semver-additions from other changes.  (Except for arti,
which _is_ post-1.0, but gets a patchlevel bump anyway.)

These are unstable crates with breaking changes:

```
tor-hscrypto
tor-hsclient
```

These have new or extended APIs:

```
safelog
tor-bytes
tor-cell
tor-linkspec
tor-llcrypto
tor-proto
tor-cert
arti-client
```

These have new unstable APIs or features:
```
tor-netdoc
tor-circmgr (also broke some unstable APIs)
arti (is post-1.0)
```

These have bugfixes only:
```
caret
tor-dirmgr
```
2023-03-31 08:24:39 -04:00
Nick Mathewson a62affd66e Move functionality from tor_basic_utils to tor_async_utils
This commit is mostly code movement; I'd recommend reviewing it
with git's `--color-moved` option.
2023-03-29 13:57:11 -04:00
Ian Jackson 00e522a91a Add some missing imports
Now
  nailing-cargo +stable clippy -p tor-hsclient --all-features --all-targets
actually works.

squash! Add some missing imports
2023-03-28 15:49:45 +01:00
Nick Mathewson a7b238483e Add an experimental circuit accessor to DataStream.
Closes #784.
2023-03-23 09:18:42 -04:00
Ian Jackson b834535347 tor-proto: Feature-conditionalise some enum variants
This avoids some dead code warnings when building without send-control-msg.
2023-03-23 11:50:18 +00:00
Ian Jackson 93809cc594 tor-proto: Split off send-control-msg feature 2023-03-23 11:50:18 +00:00
Nick Mathewson 0521aa855e tor-proto: document deep-copy in ClientCirc::path() 2023-03-22 12:35:41 -04:00
Nick Mathewson bb47d42315 proto: Stabilize ClientCirc::n_hops. 2023-03-22 11:52:17 -04:00
Nick Mathewson 552acbf07f Fix a bunch of needless-conversion warnings.
Apparently 1.68 now warns when you call into_iter() on something
that's already an iterator.  Fair enough.  Let's stop doing that.
2023-03-10 07:09:50 -05:00
Nick Mathewson f3b8f4f73f tor-proto: Document limitation on send_control_message 2023-03-08 14:21:33 -05:00
Nick Mathewson c1b45e1be4 tor-proto: Say "control message" a little more consistently
(I found "user request" in one place, and fixed that.  I am not
currently going to try to unify "control message" and "meta message"
since both terms are misleading and we already have TODOs to try to
merge them into a third better term.)
2023-03-08 14:21:33 -05:00
Nick Mathewson 9c4bdb8d8d tor-proto: Make send_control_message wait for the reactor.
This way we don't need to worry about race conditions that happen if
the caller thinks that the handler is installed before it really is.
2023-03-08 14:21:33 -05:00
Nick Mathewson fc31bf4e25 tor-proto: Have send_control_message install a handler, not return a stream 2023-03-08 14:21:33 -05:00
Nick Mathewson bc83d1e1de tor-proto: Implement functionality to send a message and accept replies
This new function combines "sending a message" and "accepting
replies in a stream" into a single call, so that there is no gap
between when the message is sent and the replies are available.

There are a number of compromises here, in order to avoid API
proliferation. I've tried to contain them as best I can.

See comments for additional design discussion.
2023-03-08 14:21:33 -05:00
Nick Mathewson 094fdc0d8d tor-proto: Change semantics of MetaCellHandler
Now, the MetaCellHandler is responsible for consuming the messages
it gets, and reporting status to whatever task is waiting for a
status message.

Additionally, the MetaCellHandler can decide to remain installed or
shut down the circuit after a successful message.  (Previously, it
could only uninstall itself on success and kill the circuit on
failure.)

These changes will enable MetaCellHandlers to be used as the basis
for handling more kinds of message.

(There is some moved and reformatted code here; you may want to
review it with `git {diff or show} --color-moved -b`.)
2023-03-08 14:21:33 -05:00
Nick Mathewson 7108f923e0 tor-proto: Give Path a method to access final hop num. 2023-03-08 14:21:33 -05:00
Nick Mathewson 5586a29f62 tor-proto: Give circ Reactor a constructor, and make its fields private. 2023-03-08 14:21:33 -05:00
Nick Mathewson f41449d0bd Patchlevel bumps for remaining changed crates.
These crates have had small code changes, but no API additions:

tor-config
tor-socksproto
tor-cert
tor-chanmgr
tor-ptmgr
tor-guardmgr
tor-circmgr
tor-dirclient
tor-dirmgr
arti
tor-hsservice
tor-congestion

These crates have had API extensions:

fs-mistrust
tor-llcrypto
tor-bytes
tor-checkable
tor-linkspec
tor-netdoc
tor-persist
arti-client
2023-02-28 07:13:27 -05:00
Nick Mathewson 3e1ae65212 Bump tor-units version for breaking change.
(The breaking change was removing `as_days()` from IntegerMinutes.)

We are _not_ calling this a downstream-api breaking change, per
discussion at
https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1012?commit_id=bb2ab7c2a3e0994bb438188511688b5b039cae29#note_2876819
2023-02-28 07:10:00 -05:00
Nick Mathewson 3e257a7cb5 Bump minor versions for significant breaking changes.
This includes tor-cell, tor-proto, and tor-netdir.
2023-02-28 07:05:15 -05:00
Ian Jackson f63c7c48af Rename onion-* cargo features to hs-* in tor-* crates
Fixes #756
2023-02-28 11:10:17 +00:00
Nick Mathewson 07473ed1fc proto: Tweak documentation and names around CmdChecker. 2023-02-27 08:14:15 -05:00
Nick Mathewson 814563dfd6 tor-proto: Rename end_received.
It can now indicate _any_ cell that means we can forget about a stream.
2023-02-17 11:56:53 -05:00
Nick Mathewson d81a9c9aad Use CmdChecker in our stream handling code.
This change makes sure that open streams and half-closed streams
have the same stream-type-dependent state machines with respect to
which cells are acceptable.

Fixes #774.

Fixes #769.
2023-02-17 11:52:09 -05:00
Nick Mathewson c5be3c089e tor-proto: Introduce CmdChecker, and define it for our streams.
The role of CmdChecker is to verify that messages are arriving at
the appropriate sequence on a stream, with respect to the other
messages that have been received.  Once the stream becomes
half-closed, the CmdChecker is also in charge of consuming incoming
messages on the stream and making sure that they are well-formed.
2023-02-17 11:50:27 -05:00
Nick Mathewson 19c0dd153a tor-proto: Add a TODO about simplifying a common pattern. 2023-02-15 10:51:03 -05:00
Nick Mathewson 1ee6bfa59c tor-proto: note implications for future HS work 2023-02-15 10:48:19 -05:00
Nick Mathewson 41b50b6c56 tor-proto: Push stream message parsing into the stream objects.
This closes #525, and ensures, at last, that we don't parse any
message that we wouldn't accept.
2023-02-15 10:48:19 -05:00
Nick Mathewson 58c3b8276c tor-proto: Defer parsing of messages send to half-closed streams
This includes a partial solution for #769, but also turned up
another bug (#774) while I was working on it.  I'll close them both
once I have a real solution.
2023-02-15 10:48:19 -05:00
Nick Mathewson bd0f6f5adf tor-proto: stop reactor (and kill circuit) if meta handler fails
If the meta handler reports an error, then the circuit has violated
its protocol, and needs to be shut down.

Fixes #773.
2023-02-15 10:48:19 -05:00
Nick Mathewson 2e483124cb tor-proto: defer meta-cell parsing to the last moment. 2023-02-15 10:48:19 -05:00
Nick Mathewson 0765243f5e tor-proto: Use UnparsedRelayCell to start deferring cell processing.
In general, we want to avoid parsing these cells until we are
fairly sure that they are something we would accept.
2023-02-15 10:48:19 -05:00
Nick Mathewson ca3b33a1af tor-cell: Refactor relay cells to copy much less
We now manipulate raw relay cell bodies as (an alias for)
`Box<[u8;509]>` rather than as (an alias for) `[u8;509]`.  This
enables us to do much less copying.  It will become more important
soon, as we defer parsing relay cell bodies even longer.

Related to #7.

We also use SliceWriter to avoid allocating a Vec<> for every relay
message we want to encode, and instead encode directly into the
cell.
2023-02-15 10:48:19 -05:00
Nick Mathewson 0d772e5bed Rename OpenClientChan{Msg,Cell} => OpenChan{Msg,Cell}S2C 2023-02-09 10:20:31 -05:00
Nick Mathewson b7490ce374 tor-proto: Do not parse forbidden commands on inbound cells.
Unlike C tor, we treat unrecognized commands as reason to kill off
the connection entirely.  That's fine; if we need to add an
unrecognized command in the future, we can use VERSIONS to negotiate
it.

Also, if someday we want this code to support relay channels as
well, we can use some type trickery to have that work too.
2023-02-09 10:20:31 -05:00
Nick Mathewson b49bd3b121 tor-proto: only parse allowed ChanMsg types during handshake. 2023-02-09 10:20:31 -05:00
Nick Mathewson 16b9d23a7c tor-cell: Make RelayEarly a separate type.
This allows us to remove a shenanigan from `restricted_msg!{}`.
2023-02-09 10:20:28 -05:00
Nick Mathewson e832cbd29c tor-cell: Have restrict_msg add conversion functions.
Every FooMsg type now implements Into<AnyFooMsg>, and
TryFrom<FooMsg>.

Additionally, it now implements From<X> for every distinct type that
it supports.  This last part lets us discard a bunch of code.

Unfortunately, I needed some downright hackish trickery in order to
get these macros to avoid generating `From<AnyFooMsg> for AnyFooMsg`
and conflicting with the blanket implementation.

The trickery to deal with RelayEarly and Relay being the same type
was not necessarily worth it; I will be separating them and removing
said trickery in the next commit.
2023-02-09 10:20:11 -05:00
Nick Mathewson d63d7926bd tor-cell: Rename RelayMsg and RelayCell-related types.
Thanks to rust-analyzer for making this simple.
2023-02-07 16:03:14 -05:00
Nick Mathewson d99c130679 tor-cell: Rename ChanMsg and ChanCell-related types. 2023-02-07 16:03:14 -05:00
Nick Mathewson c529bb9c30 tor-cell: Remove RelayMsg methods that are duplicated in RelayMsgClass. 2023-02-07 16:03:14 -05:00
Nick Mathewson 3c7aea723b tor-cell: Remove ChanMsg methods that are duplicated in ChanMsgClass. 2023-02-07 16:03:14 -05:00
Nick Mathewson 71445f7ace tor-cell: Use macro to generate ChanMsg too. 2023-02-07 16:03:14 -05:00
Nick Mathewson ffb443709b tor-cell: Change all variants of RelayMsg to have a body.
Previously, there were some unit variants, but that makes things
quite awkward for #525.
2023-02-07 16:03:14 -05:00
Nick Mathewson a2b1f20216 Bump minor version of tor-cell.
In !948 we renamed a couple of accessor functions, which is a
breaking change in `tor-cell`'s API.

In retrospect, perhaps we should have deprecated the old names and
added the new ones, so we wouldn't have to break the API.  (This is
the only API break AFAICT since 1.1.0.)
2023-02-01 10:42:58 -05:00
Nick Mathewson 7c1b6a5a81 Bump the patch version of every crate that had API additions
These crates had API or behavior changes that may affect downstream
crates. Fortunately, they're all version 0.x, and don't need minor
bumps for this.
2023-02-01 10:36:29 -05:00
Nick Mathewson 66f594a4b6 Bump the patch-level version of crates with _minor_ changes.
These changes influence behavior, but not effect compatibility.
(If I messed up, and any crate except for `arti` has non-breaking
API changes, that's still fine, since they are all version
0.x.)
2023-02-01 10:23:58 -05:00
Nick Mathewson c42350c6bf Move tor-proto/semver.md to tor-cell
It was erroneously created in the wrong place.
2023-02-01 09:50:02 -05:00
Nick Mathewson a6dd92843e Allow clippy::unchecked_duration_subtraction in tests
This panics on error, and we're fine with a panic on misbehavior in
tests.
2023-01-27 08:28:02 -05:00
Nick Mathewson bf04641c68 Disable clippy::unlinlined-format-args
This warning kind of snuck up on us! (See #748)  For now, let's
disable it.  (I've cleaned it up in a couple of examples, since
those are meant to be more idiomatic and user-facing.)

Closes #748.
2023-01-27 08:27:47 -05:00
eta cd7059f5c7 Merge branch 'sensitive' into 'main'
tor-proto: Mark stream ids in errors as sensitive

See merge request tpo/core/arti!986
2023-01-26 11:31:46 +00:00
Ian Jackson 590c139af9 tor-proto: Mark stream ids in errors as sensitive
Pursuant to #556
2023-01-24 18:08:40 +00:00
Nick Mathewson ce293e4ce4 tor-proto: comment fixes and more TODO hs 2023-01-24 11:50:10 -05:00
Nick Mathewson 12845d6e1e tor-proto: Draft API to handle incoming BEGIN requests.
Onion services (and later, exits and caches) will need this.
2023-01-17 15:20:03 -05:00
Nick Mathewson e8ed46006e tor-proto: Expose support for doing onion service handshakes
This is a little tricky, but I think that we're not actually
exposing too much here.  I expect we'll need to tweak this stuff
between now and our final version.
2023-01-17 15:20:03 -05:00
Nick Mathewson 99fdaa7c2e tor-proto: Draft APIs for handling control messages
We will need these for onion services, to send and receive messages
of types not handled directly by the tor-proto crate.
2023-01-17 15:20:03 -05:00
Nick Mathewson 4fedd301cf tor-proto: Rename "hs" experimental feature to "onion-common"
(For consistency with other crates)
2023-01-17 15:20:03 -05:00
Dimitris Apostolou 892c6eaadf
Fix typos 2023-01-07 20:35:54 +02:00
Ian Jackson 98acafe9d1 tor-proto: rustfmt
Not sure why the tree didn't have this newline already.  "Whatever".
2023-01-06 17:26:54 +00:00
Ian Jackson 0639b105c5 tor-proto: CreateFastWrap::decode_chanmsg: Do not report handshake
The debug impl prints the handshake challenge, which we should
probably treat as sensitive.
2023-01-06 17:26:54 +00:00
Ian Jackson df2124e28f tor-proto: impl Display for CreateResponse
Don't print the handshake value, but do print the display reason.
2023-01-06 17:26:54 +00:00