Commit Graph

3842 Commits

Author SHA1 Message Date
Nick Mathewson f245fc12bb tor-hsclient: Fix a doc link. 2023-03-30 15:12:57 -04:00
Nick Mathewson 626f47a5cc Merge branch 'fix-broken-doc-links' into 'main'
Fix broken doc link.

See merge request tpo/core/arti!1082
2023-03-30 19:12:01 +00:00
Alexander Færøy bcb051fea4 Merge branch 'plumb' into 'main'
More plumbing for hs connections

See merge request tpo/core/arti!1098
2023-03-30 16:20:54 +00:00
Ian Jackson 2eed641fb6 tor-netdir: iter_filter_secondary: Make it less of a mess
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1094#note_2891857
2023-03-30 17:02:47 +01:00
gabi-250 c7f924ff35 tor-netdir: Expand on comment for HsRingRings::iter 2023-03-30 16:02:27 +00:00
Alexander Færøy c8a8aeae50 Merge branch 'send' into 'main'
tor-circmgr: Make take_or_launch_stub_circuit future Send

See merge request tpo/core/arti!1096
2023-03-30 15:58:32 +00:00
gabi-250 2cd36a4c44 Merge branch 'ring' into 'main'
tor-netdir: Implement `HsDirRing::find_pos`

See merge request tpo/core/arti!1095
2023-03-30 15:37:42 +00:00
gabi-250 e7e305f9cd tor-netdir: Minor docs fixes 2023-03-30 15:37:07 +00:00
Ian Jackson 23c7bd9174 Run rustfmt
Apply this churn, which I deferred for ease of review.
2023-03-30 15:58:47 +01:00
Ian Jackson a14d18d295 arti-client: Call HsCircPool::launch_background_tasks
I found that I had the bug where I forgot to call this function, and
reached
   bad_api_usage!("The circuit launcher wasn't initialized")

The possibility of such a bug is a hazard of this API pattern.
2023-03-30 15:58:09 +01:00
Ian Jackson 577940853f tor-netdir: Implmeent HsDirRing::find_pos 2023-03-30 15:53:51 +01:00
Ian Jackson 3ed9dca842 tor-hsconn: Rename ConnError (from HsClientConnError)
The old name was unwieldy and other crates can just as well name it by
the crate scope.
2023-03-30 15:49:07 +01:00
Ian Jackson 255b9cac96 arti-client: When making hs conn, wait for bootstrap
Not doing this was a bug.  The bug was possible because of some code
duplication between the exit and hs paths.  Add a comment about that.
2023-03-30 15:49:07 +01:00
Ian Jackson 926abf3ade tor-client: Pass a netdir for each request
This will be more convenient inside tor-hsclient.  In arti-client,
this mirrors the way TorClient::get_or_launch_exit_circ works.
2023-03-30 15:49:07 +01:00
Ian Jackson 9b831933ef tor-netdir: Provide accessor for params field of HsDirParams 2023-03-30 15:47:06 +01:00
Ian Jackson 544d0e6d18 tor-netdir: Implement hs_dirs accessor 2023-03-30 15:47:06 +01:00
Ian Jackson 3c39c2f544 tor-netdir: hs_dirs accessor: change semantics, type, and name
Don't have it take the TP, so that the caller must call it multiple
times.  Instead, have it return all the relevant relays.
2023-03-30 15:47:06 +01:00
Ian Jackson e15f3c5348 tor-netdir: Provide hs_all_time_periods instead of ..._secondary_...
I don't think the server-side support will want to explicitly call
current and then secondary.  Rather, it will want to iterate over all
the relevant ones.

And fix the name, and add another comment about whether we need this.
2023-03-30 15:47:06 +01:00
Ian Jackson 4cf3cd00ef tor-netdir: Rename hs_time_period
Change its name to hs_* like we do with things at this layer.

But, it turns out, that at least for hs client connections to fetch
the descriptor, I don't seem to need to call it yet ?  Maybe it's not
needed.
2023-03-30 15:47:06 +01:00
Ian Jackson db028a6d34 tor-netdir: Sort out HsDirOp
* Change its name to Hs* like we do with things at this layer
* Make the Upload variant cfg-conditional
2023-03-30 15:47:06 +01:00
Ian Jackson 4d3d79a511 tor-netdir: Reorganise iteration over hsdir rings
Provide iter_for_op, by changing iter into iter_filter_secondary and
having a new entrypoint iter.
2023-03-30 15:47:06 +01:00
Ian Jackson 7924e995f1 tor-netdir: Provide relay_by_rs_idx 2023-03-30 15:47:06 +01:00
Ian Jackson dd493307f9 tor-circmgr: Make take_or_launch_stub_circuit future Send
thread_rng() isn't Send.  We can fix this by not holding it over an
await point.
2023-03-30 15:46:15 +01:00
Ian Jackson db968033cf tor-netdir: Make the hsdir ring be a TiVec
This eliminates an untyped `usize` index.
2023-03-30 15:43:48 +01:00
Nick Mathewson 26ee1feeb1 Upgrade dependency to latest rusqlite. 2023-03-30 08:33:44 -04:00
Nick Mathewson 289c30c5f0 Upgrade dependency to latest async-native-tls. 2023-03-30 08:32:18 -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
Nick Mathewson 1ee4a98a27 Make a new empty tor-async-utils crate. 2023-03-29 09:02:20 -04:00
Ian Jackson 13edaf68de Merge branch 'blind' into 'main'
key blinding: Use consistent terminology

See merge request tpo/core/arti!1085
2023-03-29 09:44:50 +00:00
Ian Jackson edb3ac26f3 Merge branch 'hspre' into 'main'
Miscellanious tidying up (pursuant to HS client work)

See merge request tpo/core/arti!1086
2023-03-29 09:44:48 +00:00
eta a6fe3803a0 arti-client: add accessors for `Blockage`
Fixes #800.
2023-03-28 19:27:04 +01:00
Ian Jackson b982ee678d Tidy up an unused import warning
Now
  cargo +stable clippy --locked --offline --workspace --all-targets
is clean.
2023-03-28 15:49:45 +01:00
Ian Jackson 5ff24c9f84 Pass HS identity to hsclient connection function
Obviously it will need this!
2023-03-28 15:49:45 +01:00
Ian Jackson df8e4dd497 Pass HsCircPool to hsclient connect function, not CircMgr (fmt) 2023-03-28 15:49:45 +01:00
Ian Jackson 9b6be7eaa7 Pass HsCircPool to hsclient connect function, not CircMgr
We separated this out in the circmgr API.  This is what the HS client
needs.  It doesn't want to participate in the general circuit pool.
2023-03-28 15:49:45 +01: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
Ian Jackson 4c2a9332db tor-hscrypto: key blinding: Use consistent terminology
* Don't ever use the words "parameter" or "param".
  These doesn't appear in the spec anywhere.

* Use `h` as the variable name for the unclamped blinding factor,
  and `blinding_factor` in function names.
2023-03-28 12:47:14 +01:00
Ian Jackson def291dcb5 tor-llcrypto: key blinding: Use consistent terminology
Unhelpfully, the spec uses the variable name `h` and the phrase
"blinding factor" for both the unclamped and clamped value.  The
clamped value is internal to the algorithm.

In our code:

* Don't ever use the word "parameter" or variable name `param`.
  This doesn't appear in the spec anywhere.

* Use `h` for the unclamped blinding factor, and `blinding_factor` for the
  clamped blinding factor.

* Rename `blinding_factor` function to `clamp_blinding_factor`, since
  in the spec's terminology it takes an (unclamped) "blinding factor"
  and returns a (clamped) "blinding factor".

* State explicitly what thing in the spec the `h` parameters are.
2023-03-28 12:47:12 +01:00
Gabriela Moldovan ef72e927ac
Remove hard-coded test certs.
We can use a deterministic rng to generate predictable keypairs instead.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-27 19:44:49 +01:00
Gabriela Moldovan 70d247e59c
Make the HS encoder randomness source injectable.
This makes it possible to plug in a deterministic randomness source for
testing.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-27 19:07:41 +01:00
Ian Jackson 9940bd1eb4 tor-netdir: Use `pos` not `idx` in test network constructors
There are too many things called "index" here.  `idx` could be read to
mean the table index `RouterStatusIdx`, the hsdir hash `HsDirIndex`,
or an entry in some other one of these tables.

Here's, it's just the sequence number of the index in the test netdir.
Use `pos` for that.  (`seq` would have been another possibility.)
2023-03-27 17:32:16 +01:00
Ian Jackson 4da12a26a9 tor-netdir: Use `hsdir_index` for hidden service directory hashval (fmt) 2023-03-27 17:32:16 +01:00
Ian Jackson 325526a903 tor-netdir: Use `hsdir_index` for hidden service directory hashval
The hidden services directory hashring is a ring of hsdir relays,
sorted by a hash that the spec calls the "index".  That's `HsDirIndex`.

This was a bad idea because the word "index" is seriously overused,
but in Arti we must use the same terminology.

At least, qualify it everywhere.  Now one of these hsdir sort position
hashes is always, in our code, an `hsdir_index`.

I think this is necessary even inside modules called `hsdir_*`,
because those can deal with other kind of "index" too.
2023-03-27 17:31:23 +01:00
Ian Jackson a746e17c8e tor-netdir: eliminate ref to abolished MdEntry
This was removed in c3e74973b4
  netdir: Use an even smaller rep for list of microdescs
2023-03-27 17:26:51 +01:00
Ian Jackson 99ffb89b48 tor-netdir: Use `rsidx` consistent for `RouterStatusIdx`
This is an `IndexVec` key type.  Some places used `idx`, some `rsi`,
some `rs_idx`.

Use `rsidx` for it everywhere, including in locals, function names,
and fields.  `rsidx` is a compromise.  `rsi` might be a bit opaque,
but we want a one-"word" name since it appears inside other names.
2023-03-27 17:25:52 +01:00
Gabriela Moldovan a14d95a8a0
Fix broken doc link.
This fixes a broken doc link I introduced in !1070:

```
error: unresolved link to `crate::doc::hsdesc::build::inner::HsDescInnerBuilder`
  --> crates/tor-netdoc/src/doc/hsdesc/build/middle.rs:34:11
   |
34 |     /// [`crate::doc::hsdesc::build::inner::HsDescInnerBuilder`] as described in sections
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `HsDescInnerBuilder` in module `inner`
   |
   = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`

error: could not document `tor-netdoc`
```

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-27 13:29:24 +01:00
Gabriela Moldovan 1d4069cc7f
Use the type system to enforce use of blinded keys.
Hidden services use blinded singing keys derived from the identity key
to sign descriptor signing keys.

Before this patch, the hidden descriptor builder represented its blinded
signing keys (`blinded_id`) as plain `ed25519::Keypair`s. This was not
ideal, as there was nothing preventing the caller from accidentally
initializing `blinded_id` with an unblinded keypair.

This introduces a new `HsBlindKeypair` type to represent blinded
keypairs.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-27 11:45:51 +01:00
Nick Mathewson 4af2c2ec33 tor_client: Add some example code for BridgeConfig.
Closes #791
2023-03-24 16:25:10 -04:00
Nick Mathewson 455a7a7109 arti-client: Make TransportConfigListBuilder public.
Without this there's no convenient way to add a transport without
messing with serde/toml.

Found while working on #791
2023-03-24 16:25:10 -04:00
Gabriela Moldovan 71686a9c49 Use transparent structs instead of builders.
The consensus seems to be the builders don't add much value, see [this comment].

[this comment]: https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1070#note_2889488

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:58:34 +00:00
Gabriela Moldovan 6da39c0093 Refactor the inner doc tests to be more DRY.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:58:34 +00:00
Gabriela Moldovan 2fda37f5ea Remove `NetdocText` and replace its uses with `String`.
`NetdocText` is a wrapper around a `String` and a type marker. The type
annotation proved of limited use, and made the netdoc builder API
somewhat awkward to use.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:58:34 +00:00
Gabriela Moldovan 8d0d52f193 Remove some unnecessary visibility restrictions.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:58:34 +00:00
Gabriela Moldovan c166c878fe Create a new `IntroPointDesc` type.
Unlike `hsdesc::IntroPointDesc`, `hsdesc::build::IntroPointDesc`
represents link specifiers as `LinkSpec`s rather than
`UnparsedLinkSpec`s.

Since this is a general-purpose representation of an introduction point
and not merely an intermediate representation for decoding/encoding, it
will probably need to be factored out of `tor-netdoc` at some point.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:58:33 +00:00
Gabriela Moldovan 1e3214a8bd Use the less ambiguous inner/middle/outer terminology. 2023-03-24 18:57:53 +00:00
Gabi Moldovan a1074c0027 Add builder for encoding hidden service descriptors.
This introduces the `NetdocBuilder` trait described in
`netdoc-builder.md` and a new `tor-netdoc::doc::hsdesc::build` module,
which exports the `HsDescBuilder`. Hidden services will use
`HsDescBuilder` to build and encode hidden service descriptors.

There are several TODOs in the code that I'm planning to address
separately.

Partially addresses #745.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:57:49 +00:00
Gabriela Moldovan 89ca965d2a Define constants for `AuthClient` field lengths.
These are used in multiple places (and will also be used by the HS
descriptor encoder later on), so let's make them named constants.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:54:35 +00:00
Gabriela Moldovan 1394a81142 Implement `ItemArgument` for `String`.
This makes some code a bit more concise, as it allows us to make
`Strings` into `ItemArgument`s without calling `.as_str()`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-24 18:54:35 +00:00
Ian Jackson ba88761520 Merge branch 'openssl_update' into 'main'
Update required openssl version

See merge request tpo/core/arti!1077
2023-03-24 12:32:00 +00:00
Nick Mathewson 3459d39906 Update required openssl version
cargo-audit is complaining about 0.10.45.
2023-03-24 08:02:59 -04:00
Dimitris Apostolou 629fa80674
Fix typos 2023-03-24 09:56:08 +02:00
Alexander Færøy f923e403f0 Merge branch 'paths' into 'main'
Do minimal $ and ~ handling even without expand-paths and fix build

Closes #790

See merge request tpo/core/arti!1069
2023-03-23 17:31:04 +00:00
Alexander Færøy 6fae5cc7e9 Merge branch 'upgrade_dirs' into 'main'
Bump to the lastest versions of dirs and directories.

See merge request tpo/core/arti!1072
2023-03-23 16:00:50 +00:00
Nick Mathewson a7b238483e Add an experimental circuit accessor to DataStream.
Closes #784.
2023-03-23 09:18:42 -04:00
Ian Jackson b6f5c066b4 Apply deferred rustfmt churn 2023-03-23 11:50:18 +00:00
Ian Jackson 9d7983a6ea arti-client: Include redacted HsId in ObtainHsCircuit error
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1071/diffs?commit_id=580fe1118dbbbfa086d11b28e3e26d7c91afe21c#fbd7ab2d6d0a5b515697d4f9f99a42ebd508aa4b_153_165
2023-03-23 11:50:18 +00:00
Ian Jackson 1f2728caab safelog: impl From<T> for Redacted<T>
I think this is uncontroversial; we already have it for Sensitive.
2023-03-23 11:50:18 +00:00
Ian Jackson 58311571d9 arti-client: Fix wording of docs for TorClient::isolation 2023-03-23 11:50:18 +00:00
Nick Mathewson 8a11e0f6ad arti-client: Strengthen an HS todo 2023-03-23 11:50:18 +00: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
Ian Jackson 14e5219f55 arti: Provide onion-service-client feature
Here I use the name I propose in !1039.
2023-03-23 11:50:18 +00:00
Ian Jackson cb93d1bee7 arti-client: Call tor-hsclient to create HS connections
Obviously this still doesn't work because the actual impl in hsclient
is just a todo!().
2023-03-23 11:50:18 +00:00
Ian Jackson 3d33ad7fdf arti-client: Create an HsClientConnector 2023-03-23 11:50:18 +00:00
Ian Jackson a2aa701eb6 arti-client: Move client stream creation out of match, in connect
We want this part for HS too.
2023-03-23 11:50:14 +00:00
Ian Jackson ca73dcfb31 arti-client: Break out TorClient::isolation(prefs)
We're going to want to reuse this.

Also: rename StreamPrefs::isolation and update the docs, to better
reflect its rather limited functionality.  The new
TorClient::isolation is the only call site.
2023-03-23 11:50:14 +00:00
Ian Jackson c36177733d tor-hsclient: Have the public API take StreamIsolation 2023-03-23 11:50:14 +00:00
Ian Jackson adc180294a tor-hsclient: impl HasKind for errors 2023-03-23 11:50:14 +00:00
Ian Jackson 2edd71a4f0 tor-hsclient: Swap errors so Bug comes last
This seems more consistent with the way it's done elsewhere.
2023-03-23 11:50:14 +00:00
Ian Jackson a2f4260666 tor-hsclient: Document clone-nature of HsClientConnector 2023-03-23 11:50:14 +00:00
Nick Mathewson 19cdb239bf Bump to the lastest versions of dirs and directories. 2023-03-22 15:15:42 -04:00
Nick Mathewson dffaf60e4a hspool: simplify loop and add a maximum 2023-03-22 12:35:41 -04:00
Nick Mathewson bd80125d73 hspool: Clarify/document more TODO HS items. 2023-03-22 12:35:41 -04:00
Nick Mathewson 19a229155c circmgr: Make a separate SupportedCircUsage for HS stuff
This uncovered a bug: NoUsage wasn't correct for Hs circuits because
of its behavior with channel_usage().
2023-03-22 12:35:41 -04:00
Nick Mathewson 0521aa855e tor-proto: document deep-copy in ClientCirc::path() 2023-03-22 12:35:41 -04:00
Nick Mathewson 35967ca38d circmgr: Declare builder() unconditionally.
(Still, only expose it when experimental-api is enabled.)
2023-03-22 12:35:41 -04:00
Nick Mathewson 5b3c6b6bb3 hspool: Tweak comments and add more TODOs. 2023-03-22 12:35:41 -04:00
Nick Mathewson fcb4df8b5b circmgr: hspool now launches circuits in the background.
The prediction and scheduling logic here is quite primitive;
we should probably refactor it considerably.  This should be good
enough for now, though.
2023-03-22 12:35:41 -04:00
Nick Mathewson a14214fae6 circmgr: Add an actual pool to HsCircPool.
We now have support for a pool of pre-build circuits that we can use
for HS-related purposes, and we take circuits from this pool as
needed.

Nothing populates or cleans the circuit pool yet.
2023-03-22 12:35:41 -04:00
Nick Mathewson adafae8b3f circmgr: Begin an HS circuit pool structure
This is now enough to launch circuits on demand.  It still needs to
pre-build the first three hops, and to retry on failure.
2023-03-22 11:52:17 -04:00
Nick Mathewson bb47d42315 proto: Stabilize ClientCirc::n_hops. 2023-03-22 11:52:17 -04:00
Nick Mathewson dce4da55ae circmgr: Add a usage for building the beginning of an hs circ
This only builds the first 3 hops. It can be extended to a fourth
hop later -- or not, depending on the circuit kind.
2023-03-22 11:52:17 -04:00
Nick Mathewson ec8c7eec4e circmgr: Functions to launch an unmanaged circuit.
We'll use this to implement the circuits used by onion circuits.
2023-03-22 11:52:11 -04:00
Ian Jackson cc399c3a29 tor-config: Apply deferred rustfmt churn 2023-03-21 16:37:50 +00:00
Ian Jackson c18f5c35dc tor-config: Do minimal $ and ~ handling even without expand-paths
Fixes #790
2023-03-21 16:37:50 +00:00
Ian Jackson 92bc9ef790 tor-config: Make CfgPathError PartialEq but only when testing
So, this is not a semver addition.
2023-03-21 16:33:24 +00:00
Ian Jackson a0b78837ad tor-config: Fix build when expand-paths is disabled 2023-03-21 16:33:12 +00:00
Ian Jackson 42ad8d99aa tor-config: paths, unexpanded: use infallible conversion
str can always be made into a PathBuf.
2023-03-21 16:08:47 +00:00
Ian Jackson 70b099fd0f Turn two blocking TODOs in hsdesc into "TODO HS"
TODO HS is blocking for HS release, but not for CI.
2023-03-21 13:08:14 +00:00
Ian Jackson d24a47c1d9 Sort out some TODOs in bdtest.rs 2023-03-21 13:08:14 +00:00