Commit Graph

6102 Commits

Author SHA1 Message Date
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
Ian Jackson 7aab916f31 Merge branch 'fix-blockage-accessors' into 'main'
arti-client: add accessors for `Blockage`

Closes #800

See merge request tpo/core/arti!1088
2023-03-29 09:42:19 +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
Nick Mathewson d952467870 Merge branch 'hsdesc-encoder-generic-rng' into 'main'
Make the HS encoder randomness source injectable.

See merge request tpo/core/arti!1084
2023-03-27 22:54:09 +00: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
gabi-250 a282e1f300 Merge branch 'idx' into 'main'
tor-netdir: Try to abolish unqualified uses of idx

See merge request tpo/core/arti!1083
2023-03-27 17:38:31 +00: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
Nick Mathewson f52b30d4ff Merge branch 'encode-hsdesc-blinded-keys' into 'main'
Use the type system to enforce use of blinded keys.

See merge request tpo/core/arti!1081
2023-03-27 13:15:04 +00: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
Ian Jackson 054f2d0be7 Merge branch 'typos' into 'main'
Fix typo

See merge request tpo/core/arti!1080
2023-03-27 10:05:21 +00:00
Nick Mathewson 9b0a988d1f Merge branch 'pt_config_build' into 'main'
Example code for BridgeConfigBuilder

Closes #791

See merge request tpo/core/arti!1074
2023-03-25 12:16:35 +00: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
Dimitris Apostolou 94ba102a3b
Fix typo 2023-03-24 21:43:32 +02:00
Ian Jackson aba78a3eda Merge branch 'encode_hsdesc' into 'main'
Add builder for encoding hidden service descriptors.

See merge request tpo/core/arti!1070
2023-03-24 19:27:47 +00: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 ad5946fcac Merge branch 'rpc-meta-draft' into 'main'
Start drafting a dev note about a JSON-based OO RPC design.

See merge request tpo/core/arti!1061
2023-03-24 17:57:27 +00:00
Nick Mathewson 102a2ab540 rpc-meta-draft: Sketch an even-lower-level API. 2023-03-24 17:28:19 +00:00
Nick Mathewson a3de60bd86 rpc-draft: Sketch out more commands to add, start sketching APIs 2023-03-24 17:28:19 +00:00
Nick Mathewson d67dddcc8d rpc-meta: clarify when "object" means "JSON object". 2023-03-24 17:28:19 +00:00
Nick Mathewson 67ee3b225f rpc-meta: expand on handle/reference semantics. 2023-03-24 17:28:19 +00:00
Nick Mathewson 273b565b32 rpc-meta: Use "will" for what Arti does, "must" for what client does. 2023-03-24 17:28:19 +00:00
Nick Mathewson b06d853e12 rpc-meta: Rename intermediate response to "update". 2023-03-24 17:28:19 +00:00
Nick Mathewson eee5d847be rpc-meta-draft: consistently say "request" or "method", not "command". 2023-03-24 17:28:19 +00:00
Nick Mathewson 5f9a28d227 rpc-meta-draft: make a number of localized changes from the review. 2023-03-24 17:28:19 +00:00
Nick Mathewson 906b4bb631 Start drafting a dev note about a JSON-based OO RPC design. 2023-03-24 17:28:19 +00:00