Commit Graph

321 Commits

Author SHA1 Message Date
Ian Jackson 76a1c45202 Introduce ChannelConfig
This commit is just the necessary plumbing.  The config is currently
empty.  We'll add something to it, for padding control, later.
2022-08-16 18:39:57 +01:00
Ian Jackson 2fbc196f8e tor-config: Introduce PaddingLevel
This will be used for controlling channel padding, for now.
2022-08-16 18:38:53 +01:00
Ian Jackson 806828c01c tor-proto: padding::Parameters: use impl_standard_builder
This is more standard.  It also provides the ::build() method.

This isn't a config type, and build failures ought not to happen,
so we use Bug for the error.
2022-08-16 18:37:06 +01:00
Nick Mathewson 3c1bfb4916 arti: Add support for process hardening
This is a compile-time feature with an associated configuration
flag, both enabled by default.

When it's turned on, hardening prevents the arti process from
dumping core or being attached to by low-privileged processes.
(This is a defense-in-depth measure, not an absolute way to prevent
attacks.  For more information, see
[`secmem_proc`](https://docs.rs/secmem-proc/0.1.1/secmem_proc/).)

Closes #364.
2022-08-15 12:59:56 -04:00
Nick Mathewson e74612456f Merge branch 'less_arti_surface' into 'main'
Reduce the arti crate's API surface; improve semver documentation.

Closes #522, #530, and #532

See merge request tpo/core/arti!664
2022-08-11 20:09:53 +00:00
Nick Mathewson f548a6ac55 arti: Move most public APIs behind `experimental-api`.
The remaining unconditionally public APIs are those related to our
configuration objects, and the main_main() API.

The rationale for making main_main() public is to have an actual
entry point.

The rationale for making the config APIs public is:

  1. We really do intend for others to be able to read our
     configuration files using this API.
  2. The structure of our configuration files is already part of our
     interface.

Closes #530.
2022-08-11 15:35:32 -04:00
eta 0775b6d42d tor-congestion: implement the RTT estimation algorithm from prop#324
This commit implements the round-trip-time estimation algorithm from Tor
proposal 324, validating the implementation against the test vectors
found in C tor. (Note that at the time of writing, the new test vectors
may not be committed to C tor yet, but they will be soon.)

This also adds the necessary consensus parameters to `NetParameters`.
Some of them have been renamed in order to (hopefully) make them more
understandable.
2022-08-11 15:33:50 +01:00
Nick Mathewson 36a28a8587 Merge branch 'main' into 'linkspec_refactor_v3'
# Conflicts:
#   crates/tor-netdir/semver.md
2022-08-10 14:48:57 +00:00
Nick Mathewson 19079c5a7d tor-proto: Unify the check_match code in channel and handshake
This had to become a new internal function, since at the point that
the handshake needs this code, it does not yet have a Channel to use.

This change made the error messages in the handshake code more
informative: and now they require a regex to check.  Later, we might
want to defer formatting these strings, but I don't think we need
to do it now.
2022-08-10 10:39:47 -04:00
Nick Mathewson 9b91edcb19 tor-netdir: Add a static assertion about RelayIdType::COUNT
Doing this will make sure that we fix a correctness issue in netdir that
will be caused if we add more IDs.

(Also add RelayIdType::COUNT in tor-linkspec.)
2022-08-10 10:39:47 -04:00
Nick Mathewson d60d875749 Parsing, encoding, and serde for RelayId.
The formats used here are backward-compatible with those used by C
tor and those used elsewhere in our code.  We need a way to encode
_both_ current kinds of identities as a string that tells you what
kind of ID they are.  Traditionally we have used hexadecimal,
sometimes with a $, for RSA ids, and we have used base64 for Ed25519
IDs.

We also introduce a new forward-compatible format for new identity
keys in the future.  (The new format is the key identity type, a
colon, and the id encoded as base64.)  We will use this new format
_only_ when we need to encode identities in a way where it would be
otherwise unclear what kind of key we are dealing with.
2022-08-10 10:39:36 -04:00
Nick Mathewson 9d4729a072 Add a set of Identity-related types and accessors.
I wonder if these types are correct.  I think it makes sense to have
a Ref type like this, rather than just using `&RelayId`, but it
doesn't seems that I can make `RelayId` and `RelayIdRef` implement
Borrow and ToOwned for one another, so maybe I've messed up.
2022-08-10 10:39:36 -04:00
Ian Jackson 33e0d67018 Update shellexpand, and switch to non-fork
Now we have bus>1 ownership of the crate name `shellexpand`.  I have
made a release, and retired `shellexpand-fork`.

The new shellexpand release switches to a (quite similarly) unforked
version of `dirs`.
2022-08-05 15:36:47 +01:00
Nick Mathewson be7cf7a24b Implement serde traits on RelayIds.
This will allow RelayIds to replace IdPair in tor-guardmgr.  (The
fields are named accordingly with `serde(rename)`.)
2022-08-02 12:40:55 -04:00
Nick Mathewson f1c6447403 New SecretBuf type in tor-bytes
This Writer is a simple wrapper around `Vec<u8>` that makes sure
that its contents are cleared whenever they are dropped _or
reallocated_.

The reallocation is the important part here: without that, we risk
not zeroizing the first allocation of the buffer.
2022-08-01 15:41:22 -04:00
Nick Mathewson 514c3a8e62 Use the `zeroize` feature in several crates
Using `zeroize` here tells these crates that they should make
various structures zeroize-on-drop.

(This is not yet implemented in `aes` 0.8.1, but support has been
merged in the repository for `aes`, so it should go out in the next
release.)

No corresponding feature flag is needed to enable zeroize-on-drop
for `rsa` and `*25519-dalek` private keys.
2022-08-01 12:13:05 -04:00
Nick Mathewson 6d5af26f95 Update Cargo.lock based on version bumps. 2022-08-01 10:17:04 -04:00
Nick Mathewson a0b2795e5e Run "cargo update" in preparation for next week's release. 2022-07-27 09:27:30 -04:00
Nick Mathewson 1f79e1c49b Update arti-client to new NetDirProvider API.
This allows us to give better errors in the case where bootstrapping
succeeds at first, but fails thereafter for long enough to make our
directory expire.
2022-07-26 10:41:38 +01:00
Nick Mathewson cf02d9990c Also downgrade serde_with: Version 2.0 requires Rust 1.60 2022-07-20 11:45:19 -04:00
Nick Mathewson 3ad312320e Downgrade phf back to 0.10
It turns out that phf 0.11 depends on Rust 1.60, which is above our
MSRV.
2022-07-20 10:48:28 -04:00
Nick Mathewson 393147e55e Run "cargo update" in preparation for next week's releases. 2022-07-20 08:37:13 -04:00
Nick Mathewson 131d880c7f Upgrade to latest phf, serde_with, serial_test. 2022-07-19 16:49:44 -04:00
Nick Mathewson 052f3089ca Bump to rusqlite 0.28. 2022-07-19 16:49:44 -04:00
Ian Jackson 7acdd21750 Provide maybe_send on postage::Sender, via extension trait
We need to replace the AtomicBool for dormant mode with something that
can wake up tasks.  postage::watch is the right shape.

But we want to be able to update it but suppress no-op updates.
(There is going to be a call site where no-op updates can occur.)

In the absence of a suitable upstream method as requested here
  https://github.com/austinjones/postage-rs/issues/56
we introduce this facility via an extension trait.
2022-07-18 18:13:13 +01:00
Nick Mathewson 9d3beb34a3 Bump tor-dirmgr to version 0.5.1.
This does not require a change in any other crate, since
the change here does not affect tor-dirmgr's APIs.
2022-07-14 12:00:42 -04:00
Nick Mathewson 033a05a9af Merge branch 'generate_cert' into 'main'
Implement functionality to construct signed Ed25519 certs.

Closes #511

See merge request tpo/core/arti!611
2022-07-08 13:25:29 +00:00
eta 0537e88d80 Merge branch 'persist-error-cleanup' into 'main'
tor-persist: Big refactoring on Error type.

See merge request tpo/core/arti!614
2022-07-06 17:20:43 +00:00
Nick Mathewson 853aed6859 tor-persist: Big refactoring on Error type.
Every error now has an action (what we were trying to do), a
resource (what we were trying to do it to), and a source (what
problem we encountered).

Initially I tried to add "action" and "resource" fields to error
variants individually, but that led to a combinatorial explosion.

Part of #323.
2022-07-06 11:47:17 -04:00
Nick Mathewson 48e44b0140 Implement functionality to construct signed Ed25519 certs.
This is behind a feature flag, since it isn't needed for pure
clients: only onion services and relays need this.

I've named the object that constructs these certs
`Ed25519CertConstructor` because it doesn't follow the builder
pattern exactly: mainly because you can't get an Ed25519Cert out of
it.  _That_ part is necessary because we require that an Ed25519Cert
should only exist if the certificate was found to be well-signed
with the right public key.

Closes #511.
2022-07-06 11:11:04 -04:00
Ian Jackson 6878e3a2d4 Merge branch 'update-rsa-v2' into 'main'
Update `rsa` dependency (and use `x25519-dalek` prerelease)

Closes #448

See merge request tpo/core/arti!612
2022-07-06 14:42:26 +00:00
eta c2e2da5dc3 Update `rsa` dependency (and use `x25519-dalek` prerelease)
- arti#448 and arti!607 highlight an issue with upgrading `rsa`: namely,
  the `x25519-dalek` version previously used has a hard dependency on
  `zeroize` 1.3, which creates a dependency conflict.
- However, `x25519-dalek` version `2.0.0-pre.1` relaxes this dependency.
  Reviewing the changelogs, it doesn't look like that version is
  substantially different from the current one at all, so it should be
  safe to use despite the "prerelease" tag.
- The new `x25519-dalek` version also bumps `rand_core`, which means we
  don't have to use the RNG compat wrapper in `tor-llcrypto` as much.

closes arti#448
2022-07-06 14:57:45 +01:00
Ian Jackson 8f63c07b5f tor-netdoc: b64 tests: add exhaustive roundtrip test 2022-07-06 12:04:23 +01:00
Ian Jackson a032137cad cargo update
This fixes a complaint from cargo audit about
  https://rustsec.org/advisories/RUSTSEC-2022-0032
in openssl.
2022-07-05 17:52:28 +01:00
Arturo Marquez af4970ec1f
Bump `base64ct` crate `1.5.0` -> `1.5.1`
This new release checks for invalid symbols in non-padded inputs
for decoding. Therefore, we can get rid of the logic implemented
in `https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/600`
2022-06-27 23:10:58 -05:00
Nick Mathewson 20435aea75 Bump crate and dependency versions.
These were done with the following commands:

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-error         --bump patch
cargo set-version -p tor-config        --bump patch
cargo set-version -p tor-units         --bump patch
cargo set-version -p tor-rtcompat      --bump minor
cargo set-version -p tor-llcrypto      --bump patch
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --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 patch
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump patch
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump patch
cargo set-version -p tor-dirclient     --bump patch
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump patch
cargo set-version -p arti              --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
```
2022-06-24 12:00:22 -04:00
Nick Mathewson d5170d5318 Increment versions of crates with trivial changes only.
"Trivial" here includes stuff like cargo reformatting, comment
edits, error message string changes, and clippy warning changes.
Crates that depend on these do not need to increment.
2022-06-24 11:43:02 -04:00
eta ec3e1f2ada Merge branch 'error_cleanup_2' into 'main'
Error refactoring: bytes, cert, proto.

See merge request tpo/core/arti!604
2022-06-24 13:01:42 +00:00
Nick Mathewson da0e199bd3 Run cargo upgrade in preparation for release. 2022-06-24 07:55:26 -04:00
Nick Mathewson 38004a4f4d tor-proto: split and elaborate tor_bytes::Error instances
Some of these were for decoding particular objects (we now say
what kind of objects), and some were unrelated tor_cert errors that
for some reason we had shoved into a tor_bytes::Error.

There is now a separate tor_cert::CertError type, independent from
tor_cert's use of `tor_bytes::Error` for parsing errors.
2022-06-23 15:42:45 -04:00
Ian Jackson b1aab512ff Merge branch 'tor-netdoc/use-base64ct' into 'main'
Replace `base64` crate with `base64ct` crate in `tor-netdoc`

See merge request tpo/core/arti!600
2022-06-23 18:52:14 +00:00
Nick Mathewson 210f3f1587 Merge branch 'error_cleanup' into 'main'
Error cleanup, part 1

See merge request tpo/core/arti!601
2022-06-22 19:43:50 +00:00
Nick Mathewson e3e922d03f Improve error messages in tor-checkable. 2022-06-22 09:48:42 -04:00
Nick Mathewson 326ab1a7ae Editorial improvements on fs-mistrust errors
These changes make sure that the errors conform to our preferred
style, and include a description of what exactly we were doing when
something went wrong.
2022-06-22 08:03:15 -04:00
Arturo Marquez 2d92e9e218
Remove unused `base64` crate 2022-06-21 20:28:58 -05:00
Arturo Marquez 6536ca0f61
Replace `base64` crate with `base64ct` crate
Note: the `base64ct` crate rejects invalid characters when the
decoding is done on padded strings. However, the `FromStr` impl
for `B64` can have both padded **and** unpadded inputs, so all
inputs are now padded first, before decoding.
2022-06-21 20:02:33 -05:00
Ian Jackson da2e53bf76 tor-chanmgr: Change to use unwrap_void
As per discussion in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/586#note_2813573
2022-06-21 19:19:28 +01:00
Ian Jackson 9779e5a2e2 channel padding: Use IntegerMilliseconds in padding::Parameters 2022-06-21 19:19:28 +01:00
Ian Jackson 7f3f426738 channel padding: Plumb settings from chanmgr 2022-06-21 19:19:22 +01:00
Ian Jackson 7135b7c4c7 channel padding: Make Parameters a pub struct with builder
chanmgr is going to want to make one of these from a NetDir.
2022-06-21 19:19:22 +01:00