Commit Graph

97 Commits

Author SHA1 Message Date
Ian Jackson 42df88d6bf Run maint/add_warning to add lint block everywhere 2023-08-23 10:34:00 +01:00
Nick Mathewson 0759fdf681 hscrypto: Expose hs_mac as a SimpleMac. 2023-08-14 13:15:00 -04:00
Nick Mathewson 4047236bd9 Wrap a long line in hscrypto/Cargo.toml. 2023-08-14 13:15:00 -04:00
Nick Mathewson cec6d0ce33 Run add_warnings on all files. 2023-08-04 07:45:04 -04:00
Nick Mathewson 5cc3fe1629 Bump patchlevel versions of crates with trivial changes
These crates have had trivial changes only: typically,
changes to documentation or to clippy warnings.  There's no
good reason to update which version of them other crates depend on,
so we only bump _their_ patchlevels.

```
tor-async-utils
caret
safelog
tor-events
tor-units
tor-rtcompat
tor-rpcbase
tor-llcrypto
tor-protover
tor-bytes
tor-hscrypto
tor-socksproto
tor-cert
tor-cell
tor-consdiff
tor-congestion
arti-rpcserver
arti-testing
arti-bench
arti-config
arti-hyper
```
2023-08-01 11:03:56 -04:00
Nick Mathewson 3acdf102c7 Increment patchlevel versions of crates with minor changes
These crates are at version 0.x.y, so we don't need to distinguish
new-feature changes from other changes:

```
tor-basic-utils
fs-mistrust
tor-error
tor-geoip
tor-checkable
tor-linkspec
tor-netdoc
tor-netdir
tor-persist
tor-ptmgr
tor-hsservice
```

This crate has a breaking change, but only when the semver-breaking
feature `experimental-api` is enabled:

```
tor-config
```

This crate is at version 1.x.y, but has no new public APIs, and
therefore does not need a minor version bump:

```
arti
```
2023-08-01 10:57:55 -04:00
Ian Jackson 473447a82e Run maint/add_warning to actually apply new lint allows 2023-07-10 13:49:51 +01:00
Nick Mathewson 03f9f9987a Run add_warning to remove `missing_panics_doc` deny.
Closes #950.
2023-07-06 14:32:23 -04:00
Nick Mathewson 27bd990a79 Remove semver.md files for 1.1.6 2023-06-30 10:28:53 -04:00
Nick Mathewson de13a7319b Bump patchlevel versions on crates with smaller changes
Done with the commands below.

The following crates have had various changes, and should get a
patchlevel bump. Since they are pre-1.0, we do not need to
distinguish new APIs from other changes.

```
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-circmgr
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p tor-linkspec
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-netdoc
cargo set-version --bump patch -p tor-proto
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-socksproto
```

This crate has new features, but no new non-experimental Rust APIs.
So even though it is post-1.0, it gets a patchlevel bump.

```
cargo set-version --bump patch -p arti
```
2023-06-30 08:42:21 -04:00
Nick Mathewson 65e81bf0ca Bump minor versions on crates with breaking changes
Done with:
```
cargo set-version --bump minor -p tor-hsclient
cargo set-version --bump minor -p arti-rpcserver
cargo set-version --bump minor -p tor-hscrypto
cargo set-version --bump minor -p tor-cell
```
2023-06-30 08:38:16 -04:00
Nick Mathewson 23c67d92e6 Run "fixup-features". 2023-06-29 17:09:52 -04:00
Ian Jackson c95595227a tor-hscrypto: Provide values for NUM_INTRO_POINT
These are in the spec and tor-hsclient is about to want them.
2023-06-28 14:49:49 +01: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 7510f52eea hscrypto: remove "tor-error/experimental-api" dependency
The ErrorKinds that we use here are now non-experimental.
2023-06-23 12:49:46 -04:00
Nick Mathewson 8ecb4107d4 hscrypto: downgrade a comment to HSS 2023-06-22 15:37:34 -04:00
Nick Mathewson 610ed2d457 Merge branch 'socks_errorkinds' into 'main'
Generate correct-ish socks5 errors for onion service errors.

Closes #736

See merge request tpo/core/arti!1279
2023-06-22 16:15:55 +00:00
Nick Mathewson 967cae6ced New ErrorKind for invalid onion addresses
Use this to emit HS_BAD_ADDRESS as appropriate.
2023-06-22 10:57:08 -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 0add7df458 hscrypto: fix TODOs in time-period code.
* Return a more informative error type (instead of Option)
* Check that time periods are an integer number of seconds
* Decide not to change the semantics of an argument.
2023-06-13 12:39:52 -04:00
Nick Mathewson 0a4dac0fa0 hscrypto: remove compatibility note about time periods.
We updated and clarified the spec in arti!107, and noted the
remaining infelicities in proposal 342.
2023-06-13 12:20:12 -04:00
Nick Mathewson 44ced7dbd3 hscrypto: write a README 2023-06-13 12:15:04 -04:00
Nick Mathewson 848793da5a hscrypto: note that hs_mac is not a good choice for new protocols 2023-06-13 12:11:38 -04:00
Nick Mathewson 7a82285984 hscrypto: comment out an unused key type.
(I'm not removing it entirely since maybe we _should_ use it, and
maybe we _will_ as we do services.  I've added a TODO HS for
removing it or using it, and removed the TODO HS at the head of
pk.rs about making sure that all the key types in the module really
belong there.)
2023-06-13 12:01:12 -04:00
Nick Mathewson 9888c4422d hscrypto: Remove a TODO about extending an internal macro. 2023-06-13 11:53:29 -04:00
Nick Mathewson 670c73a159 hscrypto: Remove a TODO about implementing ErrorKind.
I think it isn't actually a great idea for HsIdParseError to
implement ErrorKind, since the actual ErrorKind would depend
entirely on where the problematic ID came from.
2023-06-13 11:50:53 -04:00
Nick Mathewson 9311a8da5b hscrypto: clarify and downgrade TODOs about blinding secrets 2023-06-13 11:48:54 -04:00
Ian Jackson a50016b3da tor-hscrypto: implement Rng.gen() for RendCookie 2023-06-09 12:24:24 +01:00
Ian Jackson dc95c7874a tor-hscrypto: Break out REND_COOKIE_LEN
We need to reuse this.
2023-06-09 12:24:19 +01: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 9773633a84 hscrypto: Remove an incorrect comment.
(It said that we want to deprecate all unescorted secret keys; in
fact, only unescorted EdDSA secrets are bad.)
2023-05-18 14:18:53 -04:00
Nick Mathewson 66c06ecc9c hscrypto: Replace ed25519 secret keys with keypairs
Part of #798: We no longer use unescorted ed25519 secret keys.
2023-05-18 14:18:53 -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
Gabriela Moldovan b168fd36de
hscrypto: Add comment about impl that will be removed after we address #798.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:32 +01:00
Gabriela Moldovan 18cb1671c4
hscrypto: Add From impl for deriving KP_hsc_desc_enc out of KS_hsc_desc_enc.
The `HsClientSecretKeys` stored in the HS client connection context only
have the secret keys. Certain APIs (such as `HsDesc::parse`) expect a
keypair (both `HsClientDescEncKey` and `HsClientDescEncSecretKey`). This
`From` impl makes it possible to get a `HsClientDescEncKey` out of
`HsClientDescEncSecretKey`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:17 +01: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 4efb423947 Upgrade our hex-literal dependency 2023-04-13 07:51:26 -04:00
Nick Mathewson 104d64589d Increment MSRV to 1.65 in every crate. 2023-04-11 15:31:12 -04:00
Ian Jackson aafdf755c0 Debug as hex strings for HsBlindId and HsDirIndex 2023-03-31 19:10:17 +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 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
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
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
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
Ian Jackson 654f6689cf Improve error from HsId parse of "www.B32.onion"
And add some clarity and todos about address errors.
2023-03-09 18:09:08 +00:00
Ian Jackson 2957719c86 Test HsId parse of subdomain
This error is not great.
2023-03-09 13:41:12 +00:00
Ian Jackson 8d031a7147 Use strip_suffix_ignore_ascii_case to quickly reject non-.onion HsId (fmt) 2023-03-08 17:26:47 +00:00
Ian Jackson 80b69b9900 Use strip_suffix_ignore_ascii_case to quickly reject non-.onion HsId 2023-03-08 17:26:47 +00:00