Commit Graph

277 Commits

Author SHA1 Message Date
Nick Mathewson 104d64589d Increment MSRV to 1.65 in every crate. 2023-04-11 15:31:12 -04:00
Nick Mathewson 2ab5348ab2 Remove semver.md files. 2023-03-31 09:24:41 -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 d6bb8fee0b Upgrade to bitflags 2.0
This version of bitflags now requires us to explicitly list the
traits that we want to derive for our bit-flags structs.
2023-03-13 08:47:14 -04:00
Nick Mathewson 7da5d7a8d7 Serval rustdoc link fixes. 2023-03-08 14:21:33 -05:00
Nick Mathewson 2b9506ae67 intro_payload: various doc fixes and TODOs from review. 2023-03-08 12:27:05 -05:00
Nick Mathewson 5d5e8d8337 tor-cell: Be a little more pedantic about INTRODUCE cell types. 2023-03-08 09:50:11 -05:00
Nick Mathewson 028bf6d2bc tor-cell: Better describe the parts of intro payload. 2023-03-08 09:41:22 -05:00
Nick Mathewson 1254a8b86e tor-cell: Add code for the payload of an hs-ntor handshake.
(This is the encrypted information inside the INTRODUCE2 cell; it's
used by the client to tell the service where to find its rendezvous
point.)
2023-03-06 08:46:40 -05:00
Nick Mathewson ee666fb0b7 Merge branch 'rename_rend_message' into 'main'
tor-cell: Rename Rendezvous*::message to handshake_info.

See merge request tpo/core/arti!1045
2023-03-01 18:04:00 +00:00
Nick Mathewson 07b1c3a505 tor-cell: Rename Rendezvous*::message to handshake_info.
Follow-up from !1038
2023-03-01 12:38:27 -05:00
Nick Mathewson 93a0b72105 tor-cell: Use a match when checking auth_key_type 2023-03-01 11:34:49 -05:00
Nick Mathewson dbecdb53aa tor_cell: Use nested readers and writers for EstablishIntro 2023-03-01 11:32:56 -05:00
Nick Mathewson c8cc4a80c3 tor-cell: tweak comments on EstablishIntro members. 2023-03-01 11:27:45 -05:00
Nick Mathewson 5131703c22 Introduce a constant for the length of the output of hs_mac() 2023-03-01 11:26:35 -05:00
Nick Mathewson 03df452f7b tor-cell: Rename EstablishIntro{Body => Details} 2023-03-01 11:18:50 -05:00
Nick Mathewson 53e44b58f5 tor-cell: Fix compilation for fuzzers
(I also ran them a couple billion iterations, and didn't hit
any bugs.)
2023-03-01 07:39:17 -05:00
Nick Mathewson 8c9a1a6fad tor-cell: Make EstablishIntro do signatures
The old code parsed and encoded a signature and a mac... but there
was no way to actually set them properly.  Now EstablishIntro is
built around an EstablishIntroBody, and has the ability to check
signatures and macs.

Because there is no way to handle one of these messages if we can't
check the signature, we no longer accept unrecognized `auth_key` types
in this message.

I've added a test to make sure that we can validate a message from the
C tor implementation, and a test to make sure we can validate our
own cells.  I also had to modify the previous tests so that their
keys were well-formed.
2023-03-01 07:38:56 -05:00
Nick Mathewson 09d601d050 Change several cfgs to refer to new feature names. 2023-02-28 11:15:39 -05:00
Nick Mathewson 0c000a1713 Mark new tests as onion-service-only 2023-02-28 11:15:39 -05:00
Nick Mathewson ca055d4cb5 tor-cell: Support extensions in INTRODUCE{1,2} 2023-02-28 11:15:39 -05:00
Nick Mathewson 7af2efdb82 tor-cell: Implement IntroduceAck and IntroEstablished
These are fairly simple, since the bulk of them is just an extension
list with no supported extensions.
2023-02-28 11:15:39 -05:00
Nick Mathewson c302246e57 tor-cell: Implement rendezvous1 and rendezvous2. 2023-02-28 11:15:39 -05:00
Nick Mathewson 886faa96b3 Remove semver.md files now that 1.1.2 is out. 2023-02-28 10:06:41 -05:00
Nick Mathewson f41449d0bd Patchlevel bumps for remaining changed crates.
These crates have had small code changes, but no API additions:

tor-config
tor-socksproto
tor-cert
tor-chanmgr
tor-ptmgr
tor-guardmgr
tor-circmgr
tor-dirclient
tor-dirmgr
arti
tor-hsservice
tor-congestion

These crates have had API extensions:

fs-mistrust
tor-llcrypto
tor-bytes
tor-checkable
tor-linkspec
tor-netdoc
tor-persist
arti-client
2023-02-28 07:13:27 -05:00
Nick Mathewson 3e1ae65212 Bump tor-units version for breaking change.
(The breaking change was removing `as_days()` from IntegerMinutes.)

We are _not_ calling this a downstream-api breaking change, per
discussion at
https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1012?commit_id=bb2ab7c2a3e0994bb438188511688b5b039cae29#note_2876819
2023-02-28 07:10:00 -05:00
Nick Mathewson 4479d52a88 Bump patch-versions for breaking changes in tor-hs{crypto,client}
These are API breaks, but the crates themselves are currently
100% experimental, so there's no need to bump the minor versions
according to our semver rules.
2023-02-28 07:06:15 -05:00
Nick Mathewson 3e257a7cb5 Bump minor versions for significant breaking changes.
This includes tor-cell, tor-proto, and tor-netdir.
2023-02-28 07:05:15 -05:00
Ian Jackson f63c7c48af Rename onion-* cargo features to hs-* in tor-* crates
Fixes #756
2023-02-28 11:10:17 +00:00
Nick Mathewson c1fbcb34f6 Rearrange cfg_attr in relaycell::msg
docsrs wants to find its `cfg_attr(docsrs...)` line after the
`cfg()` line.
2023-02-21 15:18:46 +00:00
Nick Mathewson 878531af90 Merge branch 'hs-cells-1' into 'main'
Start refactoring hs cell implementations

See merge request tpo/core/arti!1020
2023-02-16 15:36:31 +00:00
Nick Mathewson c4b451ffa6 Mark a quoted block as text, so doctest ignores it. 2023-02-16 09:00:07 -05:00
Nick Mathewson 14417dc098 Add a TODO about combining several macros and patterns 2023-02-16 08:25:12 -05:00
Ian Jackson b4e48b0695 Make a comment more accurate 2023-02-16 13:19:04 +00:00
Nick Mathewson 21db73f182 tor-cell: add a TODO comment about simplifying Body away. 2023-02-15 10:48:19 -05:00
Nick Mathewson fce1c83f2e tor-cell: Add another debug_assert to relay cell encoding 2023-02-15 10:48:19 -05:00
Nick Mathewson 5d28e9e7d0 slicewriter: rename a local variable. 2023-02-15 10:48:19 -05:00
Nick Mathewson 19c9593acf Move slicewriter to tor-cell and make it private.
Also, add some comments about how it is likely to change.
2023-02-15 10:48:19 -05:00
Nick Mathewson e4bc7ef57b tor-cell: Add RelayCell::into_msg. 2023-02-15 10:48:19 -05:00
Nick Mathewson 3f1457ea04 tor-cell: Implement {Relay,Chan}Msg for every body type
This will make it ergonomic to decode a single body type without
having to declare a variant that accepts only a single message.
2023-02-15 10:48:19 -05:00
Nick Mathewson 65cc7d0974 tor-cell: Note an opportunity for future optimization 2023-02-15 10:48:19 -05:00
Nick Mathewson a809a809ba tor-cell: Add a new UnparsedRelayCell
We'll use this to router relay messages on a circuit to the
appropriate stream, and hand them to that stream, without parsing
the message until the stream has been determined.
2023-02-15 10:48:19 -05:00
Nick Mathewson ca3b33a1af tor-cell: Refactor relay cells to copy much less
We now manipulate raw relay cell bodies as (an alias for)
`Box<[u8;509]>` rather than as (an alias for) `[u8;509]`.  This
enables us to do much less copying.  It will become more important
soon, as we defer parsing relay cell bodies even longer.

Related to #7.

We also use SliceWriter to avoid allocating a Vec<> for every relay
message we want to encode, and instead encode directly into the
cell.
2023-02-15 10:48:19 -05:00
Nick Mathewson 5521df0909 tor-cell: Use a more generic mechanism for managing extensions
Several HS message types have an extension list type.  They all use
the same framing for extensions, but each of them has separate
extension types and separate extension namespaces.

This commit simplifies establish_intro a little, and adds support
for maintaining unrecognized extension types--at the expense of some
new internal code.
2023-02-15 08:44:43 -05:00
Nick Mathewson 37fcb0ca7c tor-cell: Extract establish-intro into its own module.
Some of the HS message types have a lot of dependent types, like
extensions and options for those extensions, and so on.  Except when
those extensions are portable across cell types, it makes sense
to put them in their own modules.
2023-02-15 07:46:36 -05:00
Nick Mathewson 5c85397bb7 tor-cell: rename onion_service module to hs 2023-02-15 07:38:19 -05:00
Nick Mathewson 1c1dec0948 tor-cell: Return a useful error when restrist_msg rejects a command. 2023-02-09 10:20:31 -05:00
Nick Mathewson 48ab7b0463 Change tor_bytes::Error::BadMessage to a Cow.
Actually, to avoid making a breaking change, I'm deprecating
BadMessage and creating a new InvalidMessage variant that takes a
Cow.  This way I don't need to track every crate that re-exposes
tor_bytes::Error and call this a breaking change in those.

Making this change will allow tor_bytes errors to be much more
helpful.
2023-02-09 10:20:31 -05:00
Nick Mathewson 037d1658b2 tor-cell: Re-export paste so restrict_msg can work outside the crate. 2023-02-09 10:20:31 -05:00
Nick Mathewson 0633f17131 tor-cell: Remove chancell::msg::Body::into_message.
It's now redundant, since `restricted_msg!` defines From and Into
for us.
2023-02-09 10:20:31 -05:00
Nick Mathewson 16b9d23a7c tor-cell: Make RelayEarly a separate type.
This allows us to remove a shenanigan from `restricted_msg!{}`.
2023-02-09 10:20:28 -05:00
Nick Mathewson e832cbd29c tor-cell: Have restrict_msg add conversion functions.
Every FooMsg type now implements Into<AnyFooMsg>, and
TryFrom<FooMsg>.

Additionally, it now implements From<X> for every distinct type that
it supports.  This last part lets us discard a bunch of code.

Unfortunately, I needed some downright hackish trickery in order to
get these macros to avoid generating `From<AnyFooMsg> for AnyFooMsg`
and conflicting with the blanket implementation.

The trickery to deal with RelayEarly and Relay being the same type
was not necessarily worth it; I will be separating them and removing
said trickery in the next commit.
2023-02-09 10:20:11 -05:00
Nick Mathewson b6f6fa4d4b cell: Parameterize ChannelCodec::decode and encode.
This change lets us use ChannelCodec to encode and decode any
restricted channel message type we want.  (Later on, we'll turn the
related Codec class in tor-proto into a more type-restricted version
of this.)
2023-02-09 08:26:09 -05:00
Nick Mathewson 7feda22444 tor-cell: documentation cleanups related to restricted_msg 2023-02-07 16:03:14 -05:00
Nick Mathewson 77cccdfd6e tor-cell: correct handling of optional msg types.
We need to make sure any `#[cfg(feature=...)]` attributes are
applied not only to our variant declarations, but also to the
branches in the match statements that deal with them.
2023-02-07 16:03:14 -05:00
Nick Mathewson d63d7926bd tor-cell: Rename RelayMsg and RelayCell-related types.
Thanks to rust-analyzer for making this simple.
2023-02-07 16:03:14 -05:00
Nick Mathewson d99c130679 tor-cell: Rename ChanMsg and ChanCell-related types. 2023-02-07 16:03:14 -05:00
Nick Mathewson c529bb9c30 tor-cell: Remove RelayMsg methods that are duplicated in RelayMsgClass. 2023-02-07 16:03:14 -05:00
Nick Mathewson 3c7aea723b tor-cell: Remove ChanMsg methods that are duplicated in ChanMsgClass. 2023-02-07 16:03:14 -05:00
Nick Mathewson 71445f7ace tor-cell: Use macro to generate ChanMsg too. 2023-02-07 16:03:14 -05:00
Nick Mathewson 706a39a870 tor-cell: Use macro to define RelayMsg type too. 2023-02-07 16:03:14 -05:00
Nick Mathewson f5f8402d50 tor-cell: Macro to generate restricted RelayMsg and ChanMsg.
This is the main implementation part of #525.
2023-02-07 16:03:14 -05:00
Nick Mathewson ffb443709b tor-cell: Change all variants of RelayMsg to have a body.
Previously, there were some unit variants, but that makes things
quite awkward for #525.
2023-02-07 16:03:14 -05:00
Nick Mathewson afd5232430 tor-cell: Make Body and MsgClass traits more uniform.
Doing this will make it much easier to implement a macro that
generates restricted instances of the Msg types (for #525).

The Body change is a breaking change.  I don't think anybody else
implements Body, but in theory they could.
2023-02-07 16:03:14 -05:00
Nick Mathewson e099cc7ef8 tor-cell: Generic "Restricted{Relay,Chan}Cell" types.
These are generalizations of RelayCell and ChanCell respectively,
that allow using an arbitrary message type in place of the fully
general RelayMsg and ChanMsg types.  Doing this is a prerequisite
for usefully implementing arti#525.
2023-02-07 16:03:14 -05:00
Nick Mathewson 04628ca5ab Remove semver.md files now that 1.1.1 is tagged. 2023-02-01 12:46:01 -05:00
Nick Mathewson a2b1f20216 Bump minor version of tor-cell.
In !948 we renamed a couple of accessor functions, which is a
breaking change in `tor-cell`'s API.

In retrospect, perhaps we should have deprecated the old names and
added the new ones, so we wouldn't have to break the API.  (This is
the only API break AFAICT since 1.1.0.)
2023-02-01 10:42:58 -05:00
Nick Mathewson 7c1b6a5a81 Bump the patch version of every crate that had API additions
These crates had API or behavior changes that may affect downstream
crates. Fortunately, they're all version 0.x, and don't need minor
bumps for this.
2023-02-01 10:36:29 -05:00
Nick Mathewson 66f594a4b6 Bump the patch-level version of crates with _minor_ changes.
These changes influence behavior, but not effect compatibility.
(If I messed up, and any crate except for `arti` has non-breaking
API changes, that's still fine, since they are all version
0.x.)
2023-02-01 10:23:58 -05:00
Nick Mathewson c42350c6bf Move tor-proto/semver.md to tor-cell
It was erroneously created in the wrong place.
2023-02-01 09:50:02 -05:00
Nick Mathewson a6dd92843e Allow clippy::unchecked_duration_subtraction in tests
This panics on error, and we're fine with a panic on misbehavior in
tests.
2023-01-27 08:28:02 -05:00
Nick Mathewson bf04641c68 Disable clippy::unlinlined-format-args
This warning kind of snuck up on us! (See #748)  For now, let's
disable it.  (I've cleaned it up in a couple of examples, since
those are meant to be more idiomatic and user-facing.)

Closes #748.
2023-01-27 08:27:47 -05:00
Ian Jackson 4e6f5b7ff3 Do not .gitignore crates/*/fuzz/corpus
These are symlinks which are actually checked in.  They should not be
ignored.  (This caused trouble for some of my privsep tooling...)
2023-01-20 17:29:00 +00:00
Dimitris Apostolou 892c6eaadf
Fix typos 2023-01-07 20:35:54 +02:00
Nick Mathewson 7f6e3e19a3 Sketch a solution for arti#525 2023-01-06 13:03:50 -05:00
Nick Mathewson 91d9ffe0b6 Sketch out new required APIs in tor-cell 2023-01-06 13:03:50 -05:00
eta 118050e54c Merge branch 'test-lints' into 'main'
Add test lint blocks to all "mod test"

See merge request tpo/core/arti!937
2023-01-06 17:16:09 +00:00
Neel Chauhan b649a1d86f msg::{CreateFast/CreatedFast}: Rename accessor to (into_)body() 2022-12-18 21:00:24 -08:00
Ian Jackson 125a455bdc test lint blocks: Add many many automatically
This is precisely the result of running the rune in
maint/adhoc-add-lint-blocks.
2022-12-12 18:00:30 +00:00
Nick Mathewson e0aeda3071 Remove semver.md files now that 1.1.0 is released. 2022-11-30 17:10:29 -05:00
Nick Mathewson 38bef96b99 Bump the minor version of every crate.
We made this job easy this time around: by incrementing our MSRV, we
have forced ourselves to do at least a minor bump everywhere.
2022-11-30 15:10:16 -05:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Dimitris Apostolou 9c7d1802f5
Fix typos 2022-11-06 06:51:58 +02:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
trinity-1686a d29f38603d set all crate edition to 2021 2022-11-01 00:17:33 +01:00
Nick Mathewson 9f73ddd440 Merge branch 'assert_maxlen' into 'main'
tor-cell: Assert data length in Data cells

See merge request tpo/core/arti!800
2022-10-27 01:46:21 +00:00
Nick Mathewson 49ffb1cf4b Merge branch 'safe_u16_conversion' into 'main'
tor-cell: Consistent and secure conversion to u16

See merge request tpo/core/arti!803
2022-10-25 13:17:55 +00:00
Nick Mathewson 49f0521904 Merge branch 'rename_for_to_from' into 'main'
tor-cell: Rename for_client and for_relay

See merge request tpo/core/arti!793
2022-10-25 11:53:57 +00:00
Nick Mathewson 303727081b Merge branch 'feat/add-semvermd-tor-cell' into 'main'
Add semver.md in tor-cell for MR#793

See merge request tpo/core/arti!798
2022-10-25 11:53:48 +00:00
breezykermo f177f8a02b Add semver.md in tor-cell for MR#793 2022-10-25 11:53:48 +00:00
eta 378a4999ad Merge branch 'fix_typos' into 'main'
tor-cell: Fix typos in msg.rs

See merge request tpo/core/arti!802
2022-10-25 10:36:07 +00:00
Emil Engler 05cad9f6d7
tor-cell: Add comment explaing Data::MAXLEN
This commit adds a comment explaining composition of the magic number
"11" found in the assignment of the Data::MAXLEN constant.
2022-10-24 14:46:32 +02:00
Emil Engler cc8b9e446f
tor-cell: Fix typos in msg.rs 2022-10-24 14:45:48 +02:00
Emil Engler c42a55d515
tor-cell: Consistent and secure conversion to u16
This commit improves the overflow protection of one call to
Vec::write_u16(), by replacing the cast conversion from self.sig.len()
with a call to u16::try_from(), like it is already done in the rest of
the accompanying function.
2022-10-24 14:40:51 +02:00
Emil Engler fb2195b0cf
tor-cell: Assert data length in Data cells
This commit adds a `debug_assert!` macro into the `new_unchecked()`
function of the Data cell. Beside this, it also fixes a misleading
comment regarding that limit.
2022-10-24 13:33:24 +02:00
eta b031616b5f Merge branch 'fix_typos' into 'main'
tor-cell: Fix typos in msg.rs

See merge request tpo/core/arti!788
2022-10-21 20:21:28 +00:00
eta 533ff7bda2 Merge branch 'remove_redundant' into 'main'
tor-cell: Remove redundant match clauses

See merge request tpo/core/arti!792
2022-10-21 20:17:37 +00:00
eta 81525c345a Merge branch 'concrete_comments' into 'main'
tor-cell: Make historical comments more concrete

See merge request tpo/core/arti!787
2022-10-21 20:16:27 +00:00
Ian Jackson a4e65d38e1 Merge branch 'no_redundant_copy' into 'main'
tor-cell: Avoid redundant pointer copy

See merge request tpo/core/arti!791
2022-10-21 17:51:25 +00:00