Commit Graph

3792 Commits

Author SHA1 Message Date
Gabriela Moldovan 3d0bf0d6ab
Generate a new KP_hss_desc_enc keypair for each new descriptor.
Previously, to build descriptors for hidden services with client auth
enabled, in addition to the list of authorized clients, users of
`HsDescBuilder` were required to also provide a descriptor encryption
keypair and a descriptor cookie. This was potentially dangerous and/or
error-prone, because the ephemeral encryption key and the descriptor
cookie are expected to be randomly generated and unique for each
descriptor.

This change makes `ClientAuth` private to the `hsdesc::build` module and
updates `HsDescBuilder` to build `ClientAuth`s internally. Users now
only need to provide the list of authorized client public keys.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:30 +01:00
Gabriela Moldovan 94a4d2ea43
Remove unnecessary test constant.
It's not really needed, it can just be generated at (test) runtime.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:26 +01:00
Gabriela Moldovan cd66781577
Add an encode-decode test for descriptors with client auth.
This adds a test for an `encode -> decode -> encode` flow for a hidden
service descriptor with client authorization enabled.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:23 +01:00
Gabriela Moldovan 8aa930a645
Use constants instead of magic numbers.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:19 +01:00
Gabriela Moldovan 2d9d16aabc
Stop requiring the caller to supply `AuthClient`s.
`AuthClient`s were originally meant to represent parsed `auth-client`
lines. In !1070, this struct was repurposed for representing individual
authorized clients in the HS descriptor encoder. However, hidden
services will likely use a list of public keys to represent the
authorized clients rather than a list of `AuthClient`s, as the
information from an `AuthClient` (`client_id`, `iv`, `encrypted_cookie`)
likely won't be immediately available to the hidden service.

This change updates the HS descriptor encoder to represent authorized
clients as a list of `curve25519::PublicKey`s. As such, it is now the
responsibility of the encoder to create the `client_id`, `iv`, and
`encrypted_cookie` using the available keys, the unencrypted descriptor
cookie, and HS subcredential.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:15 +01:00
Nick Mathewson 2ab5348ab2 Remove semver.md files. 2023-03-31 09:24:41 -04:00
Nick Mathewson d3a727a5a1 Remove "publish = false" from tor-hsclient.
It is now a (conditional, experimental) dependency of arti-client.
2023-03-31 09:14:35 -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 622c79aaa6 Bump patchlevel on crates with semver-irrelevant changes.
Their dependents are _not_ updated to a more recent version.

These bumped the version of a dependency that they don't expose
```
tor-rtcompat
fs-mistrust
```

This one had internal refactoring:
```
tor-netdir
```

These had trivial changes only:
```
tor-checkable
tor-ptmgr
tor-guardmgr
arti-hyper
arti-bench
arti-testing
```
2023-03-31 08:20:58 -04:00
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
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
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 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