Commit Graph

3819 Commits

Author SHA1 Message Date
Ian Jackson 76a2e82205 tor-llcrypto: Add a TODO re impl Redactable for HsId 2023-03-01 16:39:03 +00:00
Ian Jackson 08ede75905 hsclient: Clarify period task handle TODO 2023-03-01 16:39:03 +00:00
Ian Jackson e6aa199da6 hsclient: Document sharing rules
Text largely from
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1034#note_2881638
2023-03-01 16:39:03 +00:00
Ian Jackson cfa33e53d5 hsclient state: rustfmt
Autogenerated with rustfmt; no code changes.

This tidies up the bizarre formatting.
2023-03-01 16:39:03 +00:00
Ian Jackson 597601e4a3 hsclient state: Lots more doc comments about barriers, structure, etc. 2023-03-01 16:39:03 +00:00
Ian Jackson 0b39a180b0 hsclient state: Break `obtain` out into a fn
This is getting rather confusing; simply reformtting it won't do, I
think.  Also there would be much rightward drift.

So move the meat out into the new function.
(And introduce a convenience alias for its captures.)

Docs and reformatting will follow in a moment.
2023-03-01 16:39:03 +00:00
Ian Jackson a93a7b4bab hsclient state: Demonstrate that our future is now Send 2023-03-01 16:39:03 +00:00
Ian Jackson 1f03e118ef hsclient state: Restructure using a scope to drop the mutex guard
Explicit drops don't work.  Instead, introduce a scope.

We need two scopes, actually: one where we do the initial table
wrangling, and one for the retries after relock.

So we must put the meat in a closure so we can reuse it.
And we must return the flow control as an enum.  Bah, etc.

Avoid reformatting this for the moment.  This makes the delta legible...
2023-03-01 16:39:03 +00: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
Ian Jackson d1863c3178 hsclient state: Break out ServiceState::blank
We're going to have another function which will want this.
Leave a convenience closure to capture the runtime.
2023-03-01 16:27:19 +00:00
Ian Jackson 4f5f378516 hsclient state: Move error inspection before guard re-lock.
This is still correct from a lock hierarchy pov.  It moves the guard
relock to the end, which is going to be necessary since it is going to
have to move right outside the loop.
2023-03-01 16:27:19 +00:00
Ian Jackson 1e905763e3 hsclient keys: Add a todo to remove spurious Option 2023-03-01 16:27:19 +00:00
Ian Jackson 7134ddd454 hsclient keys: Compare all empty sets of keys as equal
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1034#note_2881575
2023-03-01 16:27:19 +00:00
Ian Jackson 5da60ff72d hsclient keys: Fix non-equal keys test to provide a (dummy) key (fmt) 2023-03-01 16:27:19 +00:00
Ian Jackson ff55d7b133 hsclient keys: Fix non-equal keys test to provide a (dummy) key
We're about to fix the comparison to treat all empty key sets as
equal.
2023-03-01 16:27:19 +00:00
Ian Jackson e3e66793c4 hsclient keys: Provide :none() and Default and .is_empty() 2023-03-01 16:27:19 +00:00
Ian Jackson 896ea10b7f hsclient keys: Fix a missing full stop 2023-03-01 16:27:19 +00:00
Ian Jackson ab163cf81a hsclient state: Test most important code paths 2023-03-01 16:27:19 +00:00
Ian Jackson 8e088d72d5 hsclient: Provide some missing debug impls and trace messages 2023-03-01 16:27:19 +00:00
Ian Jackson 83b8eb7349 tor-hscrypto: Provide manual Debug impl for HsId
This is still not great, but it at least makes the output plausible to
read by eye.
2023-03-01 16:27:19 +00:00
Ian Jackson 288b7b6ad1 Apply rustfmt 2023-03-01 16:27:19 +00:00
Ian Jackson d384c3b475 hsclient state: Provide one test 2023-03-01 16:27:17 +00: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 b36082255b tor-bytes: Clarify that Cursor is not a good thing, and could be neater. 2023-03-01 11:21:52 -05:00
Ian Jackson d7602c5be4 hsclient: Use a generic to provide a mock for connect()
This will allow us to test state.rs.
2023-03-01 16:20:16 +00:00
Ian Jackson feab6faa9e tor-circmgr: Provide testing feature and TestConfig
Like the similar thing in tor-guardmgr.
2023-03-01 16:20:16 +00:00
Ian Jackson 9ebe22756e hsclient: Apply standard lint block 2023-03-01 16:20:16 +00:00
Ian Jackson ff1be04012 hsclient: Move dead code allows to specific locations 2023-03-01 16:20:16 +00:00
Ian Jackson b430c65ddb hsclient: Add vacuous comments as demanded by clippy 2023-03-01 16:20:16 +00:00
Ian Jackson bac3c4a9a4 hsclient state: Bind a variable to stop rustfmt doing a terrible thing 2023-03-01 16:20:16 +00:00
Ian Jackson 76a160d5a7 hsclient: Provide a constructor for HsClientConnector 2023-03-01 16:20:16 +00:00
Ian Jackson e8b5195281 hsclient: Implement connection attempt tracking state machine
This compiles, but it cannot work yet.  Nor can it conveniently be tested.
2023-03-01 16:20:16 +00:00
Ian Jackson 4ec9ec92bc HS secret keys: Move aggregate/config to tor-hsclient
Provide a more cookied "secret keys for use to connecting to a
particular HS" type, with a builder.

This wants to use config stuff, so oughtn't to be in tor-*crypto.
The individual types remain there.
2023-03-01 16:19:31 +00:00
Nick Mathewson 03df452f7b tor-cell: Rename EstablishIntro{Body => Details} 2023-03-01 11:18:50 -05:00
Ian Jackson 891782122d hsclient API: Remove notion of ambient keys fromk this layer 2023-03-01 16:18:09 +00:00
Ian Jackson a45acb3905 HS API: Remove HS client keys from circmgr API
*If* we're going to retain any HS knowledge in circmgr, it definitely
doesn't need to know about per-operation client secrets.

(Maybe there might be ambient secrets, used for .onion diversion, but
they don't need to be in this API.)
2023-03-01 16:18:09 +00:00
Ian Jackson feeb38c750 HS planning: Discuss whether to remove all HS code from circmgr 2023-03-01 16:18:09 +00:00
Ian Jackson 06e6e11886 HS planning: Intend for HS connector to do all lifecycle mgmt
Otherwise there has to be a state entry in the circmgr *and* a state
entry in the hs connector, for every HS.  This division of
responsibilit will be confusing.

The HS code will then be more completely just a layer on top of circmgr.
2023-03-01 16:17:47 +00:00
Ian Jackson bab32c6038 clarify results of misusing cursors 2023-03-01 15:57:14 +00:00
Nick Mathewson 1251796039 Merge branch 'more_hs_msgs' into 'main'
Implement most remaining HS cell types

See merge request tpo/core/arti!1038
2023-03-01 14:50:35 +00:00
Nick Mathewson 87d9dd6423 tor-netdoc: Clarify that we must indeed check cert expiration. 2023-03-01 09:49:17 -05:00
Nick Mathewson a4a305c1cf tor-netdoc: Validate inner certs in HsDesc
This makes our implementation behave the same as the C tor
implementation, by validating all of the expiration and signatures
on the certificates in the inner document.

(It is still not semantically necessary to check these certs: the
document in which they appear is already signed by the key with
which they are allegedly signed.)

Closes #744
2023-03-01 09:48:51 -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
Ian Jackson 22bb5bacc0 Merge branch 'main' into 'main'
Use humantime in tor-checkable and tor-guardmgr

Closes #663

See merge request tpo/core/arti!1037
2023-02-28 19:22:53 +00:00
Nick Mathewson 0f88c5131f tor-bytes: impl Readable and Writeable for CtByteArray. 2023-02-28 11:23:44 -05:00
Nick Mathewson d658fcfc52 Expose a little new functionality from tor-llcrypto.
Expose ED25519 signature length; make ValidatableEd25519Signature
implement Debug and Clone.
2023-02-28 11:23:44 -05:00
Nick Mathewson 0bf1ae70ba tor-bytes: Add cursor functionality to Reader
We'll use this to implement signature and MAC checking for
EstablishIntro cells.
2023-02-28 11:23:44 -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 841905948f caret: work correctly when there are no defined variants. 2023-02-28 11:08:34 -05:00
Nick Mathewson d69ed3bc62 hscrypto: Make several types Readable+Writeable
Specifically, RendCookie, Subcredential, HsId, and HsBlindId.
2023-02-28 11:08:31 -05:00
Saksham Mittal e2c870ca1c
Remove unnecessary warning from arti-hyper/README
https://gitlab.torproject.org/tpo/core/arti/-/issues/715
has been fixed, so there is no need to display such a warning
2023-02-28 21:23:24 +05:30
Nick Mathewson 886faa96b3 Remove semver.md files now that 1.1.2 is out. 2023-02-28 10:06:41 -05:00
Nick Mathewson 2c9f8e3547 Follow-on patchlevel bumps for crates with changed dependencies
These crates didn't have any changes until now, when I bumped
the versions of some other crates they depend on:

tor-consdiff
arti-hyper
arti-bench
arti-testing
2023-02-28 07:18:37 -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 ddd323c6ff tor-hsservice: Fix an erroneous reference to an hs-client feature 2023-02-28 11:10:17 +00: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 fcbeceeb61 Merge branch 'cmd_checker' into 'main'
tor-proto: Introduce CmdChecker, and use it to enforce correctness for our streams.

Closes #774 and #769

See merge request tpo/core/arti!1026
2023-02-27 16:43:34 +00:00
Saksham Mittal dfb94f510d
Use humantime in tor-guardmgr 2023-02-27 21:24:29 +05:30
Saksham Mittal f5f526d1fc
Use humantime in tor-checkable
The four values of times taken in a particular test were changed to both
be human readable and have comments explaining their significance (they
are all important moments after the Unix Epoch for freedom)
2023-02-27 21:18:49 +05:30
Nick Mathewson 07473ed1fc proto: Tweak documentation and names around CmdChecker. 2023-02-27 08:14:15 -05:00
Nick Mathewson d09273a6e3 Apply a missing cfg_attr(docsrs...) in netdoc 2023-02-21 15:18:46 +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
Ian Jackson 750c512264 Merge branch 'unparsed_linkspec' into 'main'
HsDesc: Use a new UnparsedLinkSpecifier to avoid leaking which linkspec types we know

See merge request tpo/core/arti!1029
2023-02-21 15:16:45 +00:00
Ian Jackson 67234568bc Merge branch 'hsdir_remove_comment' into 'main'
netdoc: Remove a TODO hs comment.

See merge request tpo/core/arti!1028
2023-02-21 15:15:10 +00:00
Nick Mathewson 3233c25943 tor-netdoc: Use UnparsedLinkSpec in IntroPointDesc. 2023-02-17 15:29:37 -05:00
Nick Mathewson bc68974212 tor-linkspec: New UnparsedLinkspec type.
Unlike linkspec, this doesn't validate the actual contents of the
specifiers. We'll use this so we can handle the linkspec list for an
introduction point in an HsDesc, and just pass it on when
constructing our circuits.

I haven't added any accessor or constructor functions, because I
don't expect to need them.
2023-02-17 15:26:23 -05:00
Nick Mathewson 757c6d333f netdoc: Remove a TODO hs comment.
It said to check whether C enforces an absence of extraneous bytes
at the end of the link specifiers.  It does, in
`hs_desc.c:decode_link_specifiers()`, where it says:

```
  if (link_specifier_list_parse(&specs, decoded,
                                (size_t) decoded_len) < decoded_len) {
    goto err;
  }
```

The comparison with "decoded_len" checks whether all the bytes were
decoded.
2023-02-17 15:06:09 -05:00
Nick Mathewson 2b515c8d25 tor-dirmgr: Work around an apparent regression in `time`.
Some code in our tests that worked fine with time 0.3.17 no
longer works with 0.3.19, despite the semver.

See https://github.com/time-rs/time/issues/552 for the upstream bug.
2023-02-17 14:36:19 -05:00
Nick Mathewson 814563dfd6 tor-proto: Rename end_received.
It can now indicate _any_ cell that means we can forget about a stream.
2023-02-17 11:56:53 -05:00
Nick Mathewson d81a9c9aad Use CmdChecker in our stream handling code.
This change makes sure that open streams and half-closed streams
have the same stream-type-dependent state machines with respect to
which cells are acceptable.

Fixes #774.

Fixes #769.
2023-02-17 11:52:09 -05:00
Nick Mathewson c5be3c089e tor-proto: Introduce CmdChecker, and define it for our streams.
The role of CmdChecker is to verify that messages are arriving at
the appropriate sequence on a stream, with respect to the other
messages that have been received.  Once the stream becomes
half-closed, the CmdChecker is also in charge of consuming incoming
messages on the stream and making sure that they are well-formed.
2023-02-17 11:50:27 -05:00
Nick Mathewson 1297dfb5e3 Merge branch 'doc-iter' into 'main'
tor-netdoc: Abolish PauseAt in favour of using itertools

Closes #760

See merge request tpo/core/arti!1021
2023-02-17 12:34:32 +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
Ian Jackson 66beab6c9e tor-netdoc: Fix doc comment following removal of PauseAt 2023-02-16 11:53:32 +00:00
Ian Jackson ca127b013f Expire routerdescs as soon as any of their expiries expire
Fixes #772
2023-02-15 17:41:28 +00:00
Ian Jackson 676241c349 tor-netdoc: Run rustfmt (separately from the refactoring) 2023-02-15 17:17:01 +00:00
Ian Jackson 1993165f22 tor-netdoc: Abolish NetDocReader::iter and into_iter
Nothing uses these now; the NetDocReader is simply an iterator, itself.
2023-02-15 17:17:01 +00:00
Ian Jackson 4a91c732fe tor-netdoc: Remove many needless calls to .iter() and .into_iter() 2023-02-15 17:17:01 +00:00
Ian Jackson fa2e164939 tor-netdoc: Use impl Iterator for NetdocReader in .pause_at
This simplifies the return type!
2023-02-15 17:17:01 +00:00
Ian Jackson db79e3f369 tor-netdoc: impl Iterator etc. for NetdocReader
This will simplify things at many call sites.
2023-02-15 17:17:01 +00:00
Ian Jackson b58977b428 tor-netdoc: move PeekableIterator to util.rs
We're going to want this a bit more widely.
2023-02-15 17:17:01 +00:00
Ian Jackson 11660f84b0 tor-netdoc: Delete now-unused PauseAt type 2023-02-15 17:17:01 +00:00
Ian Jackson 15d93bd642 tor-netdoc: Use itertools to implement NetDocReader::pause_at
This is the last use of PauseAt.
2023-02-15 17:17:01 +00:00
Ian Jackson 089ebb7d11 tor-netdoc: Replace use of PauseAt::new_pred()
We can just make a new PauseAt, since it can take the inner peekable
iterator by mutable reference.

This seems to tidy the code up a bit too.
2023-02-15 17:16:57 +00:00
Ian Jackson 7491424ee9 tor-netdoc: Have sectionrules.parse take I, not &mut I
There's a blanket impl of Itertor for &mut impl Iterator, so this
isn't necessary, and it prevents us passing iterators by value
producing syntactic vinegar.
2023-02-15 17:16:57 +00:00
Ian Jackson 80d8d94c96 tor-netdoc: Import Peekable rather than referring to it by path
This makes things easier to read.  We're about to add another
site (albeit, temporarily).
2023-02-15 17:16:57 +00:00
Nick Mathewson 0f2218f4d3 Merge branch 'ticket_525_part3_take2' into 'main'
Finish #525 for relay messages: Only parse messages at the last instant.

Closes #773 and #525

See merge request tpo/core/arti!1017
2023-02-15 16:35:27 +00:00
Nick Mathewson 19c0dd153a tor-proto: Add a TODO about simplifying a common pattern. 2023-02-15 10:51:03 -05: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 1ee6bfa59c tor-proto: note implications for future HS work 2023-02-15 10:48:19 -05:00
Nick Mathewson 41b50b6c56 tor-proto: Push stream message parsing into the stream objects.
This closes #525, and ensures, at last, that we don't parse any
message that we wouldn't accept.
2023-02-15 10:48:19 -05:00
Nick Mathewson 58c3b8276c tor-proto: Defer parsing of messages send to half-closed streams
This includes a partial solution for #769, but also turned up
another bug (#774) while I was working on it.  I'll close them both
once I have a real solution.
2023-02-15 10:48:19 -05:00
Nick Mathewson bd0f6f5adf tor-proto: stop reactor (and kill circuit) if meta handler fails
If the meta handler reports an error, then the circuit has violated
its protocol, and needs to be shut down.

Fixes #773.
2023-02-15 10:48:19 -05:00
Nick Mathewson 2e483124cb tor-proto: defer meta-cell parsing to the last moment. 2023-02-15 10:48:19 -05:00
Nick Mathewson 0765243f5e tor-proto: Use UnparsedRelayCell to start deferring cell processing.
In general, we want to avoid parsing these cells until we are
fairly sure that they are something we would accept.
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 9e2b6f3aed tor-bytes: Add a new writer implementation for fixed-size objects
Because the API assumes that many writes are infallible, this writer
takes ownership of the backing object, and will only return it to
you if you didn't run over the end.

I'm going to use this to save some allocations in relay cell bodies
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
Ian Jackson dccb641354 Merge branch 'fuzz-hsdesc' into 'main'
Fuzzing for hsdesc parsers

See merge request tpo/core/arti!1018
2023-02-15 12:47:38 +00: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 f1ec64bfe5 Upgrade to latest toml crate.
(None of the breaking changes affect us this time.)
2023-02-14 11:06:00 -05:00
Nick Mathewson e00dfcf41e netdoc: Add a basic fuzzer for the hsdesc layers.
I've been running this for 5 minutes and haven't found any
crashes. I'll run it for an hour or two, then add the results to the
corpus repository.
2023-02-14 07:49:34 -05:00
Nick Mathewson 79dd2ef995 netdoc: Add a feature to expose hsdesc inner doc parsers
We want to fuzz these parsers, but there's no currently way to get
at the parsers for inner documents without going through a lot of
encryption.  (Coverage-guided fuzzers are powerful, but they
can't find SHA3 preimages.)
2023-02-14 07:44:18 -05:00
Nick Mathewson 74ef8de86f Merge branch 'doc-iter' into 'main'
Introduce new batching iterator and use it in two places

See merge request tpo/core/arti!1016
2023-02-13 18:59:42 +00:00
Ian Jackson 297019bb23 batching_split_before: Whitespace error fix 2023-02-13 17:34:04 +00:00
Ian Jackson b4d0b585c2 batching_split_before: Better xref for doc hidden
And another UNSTABLE warning.
2023-02-13 17:32:54 +00:00
Ian Jackson 1232bb6661 batching_split_before: Clarify API sequential restriction 2023-02-13 17:29:17 +00:00
Ian Jackson 5be6db006c batching_split_before: Fix and clarify Batches/LendingIterator doc 2023-02-13 17:28:39 +00:00
Ian Jackson 15f33ce13c batching_split_before: Introduce unit token types
And explain why we're not using booleans.
2023-02-13 17:19:13 +00:00
Ian Jackson 73a20cdc36 batching_split_before: Expand on the remaining use of "meta-iterator" 2023-02-13 17:13:55 +00:00
Ian Jackson 04e3a22b82 batching_split_before: Fix link to BatchesWithHeader::subsequent 2023-02-13 17:12:17 +00:00
Ian Jackson 53ef0d65ea batching_split_before: Provide description for BatchesWithHeader 2023-02-13 17:09:08 +00:00
Ian Jackson 6799fb6e3e batching_split_before: Document generics on our non-private types 2023-02-13 17:04:29 +00:00
Ian Jackson e44be77f52 batching_split_before: Rename "prefix" to "header"
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1016#note_2877759

"_prefixed" becomes "_with_header".  That mirrors the returned struct
which is nice.
2023-02-13 16:55:36 +00:00
Ian Jackson 72b1cb797d batching_split_before: Rename "start" to "batch-starting"
Roughly as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1016#note_2877822
2023-02-13 16:52:07 +00:00
Ian Jackson 09060b4748 batching_split_before: Remove false assertions about batch contents 2023-02-13 16:44:47 +00:00
Ian Jackson 4333a1ef1c batching_split_before: Clarify heading of BatchesWithPrefix 2023-02-13 16:37:13 +00:00
Nick Mathewson 5c1cbd5486 batching_split_before: docs improvements. 2023-02-13 16:12:26 +00:00
Nick Mathewson 7363bee6a4 netdoc: give hsdesc test info in its original form. 2023-02-13 10:30:27 -05:00
Ian Jackson 8703a969f4 tor-netdoc: Use batching iterator in authcert.rs
This gets rid of a lot of manual boolean state variable iterator
stuff.
2023-02-10 19:48:26 +00:00
Ian Jackson d35f7990e8 tor-netdoc: Use batching_split_before in HsDescInner 2023-02-10 19:47:45 +00:00
Ian Jackson fd35f05b26 tor-netdoc: Provide new batching_split_before
There will be two call sites to demonstrate it.

Eventually maybe this will want to be in tor-basic-utils, since it
doesn't depend on any of the tor-netdoc types.  But it would be
sensible to wait until the situation with PeekableIterator and
Itertools is improved.

For now we make this #[doc(hidden)] to avoid it becoming part of our
stable API.
2023-02-10 19:47:45 +00:00
Ian Jackson 1b5a5eb57a tor-netdoc: Provide NetDocReader::into_iter
This will avoids some hairy borrowck disasters when we try to use
iterator adapters.
2023-02-10 19:47:45 +00:00
Ian Jackson 5f0ff78c2d tor-netdoc: util: use super::* in tests
Not xure how my MR to try to do this everyone missed this one.
2023-02-10 19:47:45 +00:00
Ian Jackson a5be14ed5e tor-netdoc: util: Add standard lint block to tests
Not xure how my MR to try to do this everyone missed this one.
2023-02-10 12:47:02 +00:00
Nick Mathewson 3f5502c5bc netdoc: Add a test for HSDesc decryption. 2023-02-10 07:36:40 -05:00
Nick Mathewson ced33029f6 Add another test hsdesc to parse.
This one was generated (by dgoulet) using `ClientDescEncKey`
encryption.  Its information is:

```
Address: paozpdhgz2okvc6kgbxvh2bnfsmt4xergrtcl4obkhopyvwxkpjzvoad.onion

Time period: 19397

Client:

  paozpdhgz2okvc6kgbxvh2bnfsmt4xergrtcl4obkhopyvwxkpjzvoad:descriptor:x25519:SDZNMD4RP4SCH4EYTTUZPFRZINNFWAOPPKZ6BINZAC7LREV24RBQ

Service:

  descriptor:x25519:SACGOAEODFGCYY22NYZV45ZESFPFLDGLMBWFACKEO34XGHASSAMQ
```
2023-02-10 07:26:31 -05:00
Nick Mathewson b4cca45410 hscrypto: Use minutes, not seconds, in blinding parameter.
Fixes an instance of #768.

The problem with the test vectors is that I used a random time
period number (1234) and the default-in-tor period length (1440)
without checking whether 1440 _meant_ minutes or seconds.  I'll add
another test to Tor to make sure that the time period matches now.

With this change, I can test Tor-generated hsdescs with encryption,
so I'm fairly confident that the new behavior is correct.
2023-02-10 06:54:19 -05:00
Nick Mathewson 696b9bd2d5 Merge branch 'ticket_525_part2' into 'main'
Apply restricted_msg to ChanMsg parts of tor-proto

See merge request tpo/core/arti!1013
2023-02-09 18:06:39 +00:00
Ian Jackson 62fa652fcd Merge branch 'hsdir' into 'main'
Compute the HS directory hash ring

See merge request tpo/core/arti!1012
2023-02-09 16:35:42 +00:00
Ian Jackson 3d6e6fcf0d Fix minimal-versions (.then_some is too new) 2023-02-09 16:07:16 +00:00
Ian Jackson 4b7f2e84bf tor-netdir: Make is_hsdir_for_ring crate-local
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1012#note_2876824
2023-02-09 16:07:16 +00:00
Nick Mathewson 0d772e5bed Rename OpenClientChan{Msg,Cell} => OpenChan{Msg,Cell}S2C 2023-02-09 10:20:31 -05:00
Nick Mathewson b7490ce374 tor-proto: Do not parse forbidden commands on inbound cells.
Unlike C tor, we treat unrecognized commands as reason to kill off
the connection entirely.  That's fine; if we need to add an
unrecognized command in the future, we can use VERSIONS to negotiate
it.

Also, if someday we want this code to support relay channels as
well, we can use some type trickery to have that work too.
2023-02-09 10:20:31 -05:00
Nick Mathewson b49bd3b121 tor-proto: only parse allowed ChanMsg types during handshake. 2023-02-09 10:20:31 -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
Ian Jackson 4ca661a4dc tor-netdir: Document fill_from_previous_netdir semver 2023-02-09 14:57:29 +00:00
Nick Mathewson 8cda5a1a3e Clarify which netdir index is meant 2023-02-09 14:56:30 +00:00
Nick Mathewson 33b8ebd67e Fix typos 2023-02-09 14:48:56 +00:00
Ian Jackson 1f3f659536 Fix compilation with various feature combinations 2023-02-09 14:35:57 +00:00
Nick Mathewson 73ce68ac21 Rename DescEncNonce => HsDescEncNonce 2023-02-09 08:57:09 -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
Ian Jackson 335043658e hsdir: rustfmt
Deferred formatting changes which would have obscured the commits they
were prompted by.
2023-02-09 13:01:37 +00:00
Ian Jackson 3dd0d381d0 hsdir: Actually compute the hash ring 2023-02-09 13:01:37 +00:00
Ian Jackson f5c3c1f277 hsdir: Be able to enumerate the hidden service directories
* Provide an accessor for the HSDIR flag
* Provide a function for testing a relay for hsdir inclusion
* Provide an iterator on NetDir that returns the hsdirs
2023-02-09 13:01:37 +00:00
Ian Jackson f12277141b hsdir: Ring calculation plumbing
* Implement Netdir::compute_rings in terms of a new
  HsDirRing::compute, that currently does nothing.

* Actually call Netdir::compute_rings (since now it doesn't panic).

* Make Netdir::compute_rings not be pub.  We do this unconditionally,
  rather than exposing the distinction between a netdir-without-hsdir
  and a netdir-with-hsdir.
2023-02-09 13:01:37 +00:00
Ian Jackson fe1113bd6b hsdir representation: Introduce HsDirs generic type
This already allows us to get rid of some duplication, and will be
useful more widely in a moment.
2023-02-09 13:01:37 +00:00
Ian Jackson d63c44f96d hsdir: Implement HS hash ring index calculations 2023-02-09 13:01:37 +00:00
Ian Jackson a12df180b5 hsdir: Make HsDirIndex be AsRef<[u8; ]> 2023-02-09 12:56:47 +00:00
Ian Jackson 3f04e7f43e hsdir: impl Eq for HsDirParams
This will allow us to tell if we can reuse parts of a ring.
2023-02-09 12:56:18 +00:00
Ian Jackson 5fcae642d6 hsdir: Rename HsRingParams to HsDirParams
The file which contains this type is called hsdir_params.rs.  We have
a general problem with slight confusion about when to includen "dir"
and when to include "ring".

Resolve this in favour of the rule now added to the module-level doc
comment.
2023-02-09 12:56:18 +00:00
Ian Jackson 962c879005 hsdir_params: Rename some variables for consistency
These variables are going to be struct fields, which will sort of
enforce consistent naming.  The struct fields are going to appear in a
moment.  We'll call the fields "current" and "secondary" after the
naming in the test cases.

And import hsdir_params::HsRingParams, which we're going to make more
references to.
2023-02-09 12:56:18 +00:00
Ian Jackson 5f52015239 hsdir: Replace open-coded params fields and args with HsRingParams
This will enable us to pass these around more conveniently.

And make empty_from_params take an owned params, which it would like.
2023-02-09 12:56:18 +00:00
Ian Jackson 8d4552de8b hsdir: Remove a done TODO - this *is* now a TiSlice 2023-02-09 12:56:18 +00:00
Ian Jackson cd0c38ae6c tor-netdir: Provide Netdir::md_by_idx
We'll need this shortly.
2023-02-09 12:56:18 +00:00
Ian Jackson 6acf9cf5e8 tor-netdir: Store previous netdir (if required by features) 2023-02-09 12:56:18 +00:00
Ian Jackson f69d7f96ac tor-netdoc: Change fill_from_previous_netdir
* Remove the return value, which was not used anywhere.
  Also remove the code to calculate the return value.

* Take an Arc<NetDir> rather than a reference.  We are going to want
  this for HS support.  This has no overall effect on the lifetime of
  the4 Arc, which was owned at the one call site and then imediately
  dropped.

* Change the documentation to explain what the function's role is in
  the netdir API, rather than the fiddly details of what it actually
  does internally.  Relegate the latter to a code comment.
  (When we have HS, this will do more, or, at least, make further
  arrangements.)
2023-02-09 12:56:18 +00:00
Ian Jackson 81d4e6971b tor-netdoc: Discuss that relays are ordered by rsa id in Consensus 2023-02-09 12:56:18 +00:00
Ian Jackson 1e3d20bdba tor-netdir: Use typed-index-collections for router index (fix hsdir)
This was omitted in !1004.  (Because this code isn't actually wired up
yet, it typechecked anyway.  But we need to fix it.)
2023-02-09 12:56:18 +00:00
Ian Jackson 4626ccfcaa hs time handling: Make TimePeriod contain length as IntegerMinutes
Locally, the only functional effect is that now we refuse to handle
non-whole-number-of-minutes lengths - but since the consensus
parameter can't represent those, there's no overall functional change.
2023-02-09 12:56:18 +00:00
Ian Jackson bb2ab7c2a3 tor-units: Fix IntegerMinutes accessor (omg) 2023-02-09 12:56:18 +00:00
Nick Mathewson 0a80c468df hsdesc: Use an IntegerMinutes<u16> to hold lifetime. 2023-02-08 13:33:07 -05:00
Nick Mathewson 39f5f90f3f netdoc: Fix most "TODO HS rename" comments 2023-02-08 13:23:21 -05:00
Nick Mathewson 8c3bd3626b netdoc::hsdesc: Distinguish layer from document. 2023-02-08 13:16:44 -05:00
Nick Mathewson 966ddeb092 netdoc::hsdesc: Rename "layer" modules. 2023-02-08 13:08:57 -05:00
Nick Mathewson 964ca511c4 netdoc::hsdesc: Excise reference to "password" authentication
As far as we can tell, this never existed.
2023-02-08 12:57:52 -05:00
Nick Mathewson cce56c793b hscrypto,netdoc: Add and use a type for KP_hss_desc_enc. 2023-02-08 12:50:34 -05:00
Nick Mathewson 99ec1c9818 tor-hscrypto: Rename key types to correspond to new spec names. 2023-02-08 12:27:36 -05:00
Nick Mathewson d1ee5807ed Rename DescriptorCookie to DescEncNonce
(I think it's okay to omit the Hs here, since this type is not
visible outside the hsdesc parsing code. I'll rename if others
disagree.)
2023-02-08 12:10:24 -05:00
Nick Mathewson 39e1116ece Renaming cleanup for and around now-renamed "KP_hs_desc_ephem". 2023-02-08 12:06:42 -05:00
Nick Mathewson 18e8ac7cb6 Rename key identifiers that have changed in the spec
Generated with perl:

s/K([PS])_hs_intro_tid/K$1_hs_ipt_sid/g;
s/K([PS])_onion_ntor/K$1_ntor/g;
s/K([PS])_hs_intro_ntor/K$1_hss_ntor/g;
s/K([PS])_hs_desc_ephem/K$1_hss_desc_enc/g;
2023-02-08 11:57:51 -05:00
Dimitris Apostolou d1eeffbf42
Fix typo 2023-02-08 00:04:25 +02: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 f537a7ad48 Update hsdesc parser code to new sectionrules::builder code. 2023-02-07 15:28:10 -05:00
eta 85ca3e41b9 Merge branch 'shadykaty-error-hint-v2' into 'main'
Create and use an ErrorHint type to report how to fix a problem.

Closes #579 and #578

See merge request tpo/core/arti!994
2023-02-07 16:32:10 +00:00
eta c7c4fff66e Merge branch 'authcert_bug' into 'main'
Fix AuthCert behavior on unrecognized tokens, and prevent bug from recurring elsewhere.

Closes #752

See merge request tpo/core/arti!1006
2023-02-07 16:06:20 +00:00
Nick Mathewson a1c36b2087 netdoc: Add a comment about renaming layer to document. 2023-02-07 09:02:15 -05:00
Nick Mathewson 257aaf9e5b netdoc::hsdesc: rename Passwd to Password. 2023-02-07 09:02:15 -05:00
Nick Mathewson 2ba28aa289 netdoc: Rename/comment objects from hsdesc. 2023-02-07 09:02:15 -05:00
Nick Mathewson d10ccf0dc5 netdoc: Rename/comment objects from inner_layer. 2023-02-07 09:02:15 -05:00
Nick Mathewson 1cdd36f511 netdoc: Rename/comment objects from middle_layer. 2023-02-07 09:02:15 -05:00
Nick Mathewson 1a59005ae0 netdoc: Rename/comment objects from desc_enc 2023-02-07 09:02:15 -05:00
Nick Mathewson 7701e02aad netdoc: Renaming and comments in outer_layer. 2023-02-07 09:02:15 -05:00
Nick Mathewson 68d2ccf5fe netdoc: Use Itertools::exactly_once in hsdesc parsing 2023-02-07 09:02:15 -05:00
Nick Mathewson 3d53a30c94 netdoc: Remove useless should_be_exhausted calls. 2023-02-07 09:02:15 -05:00
Nick Mathewson cff2326f6f Remove a needless line. 2023-02-07 09:02:15 -05:00
Nick Mathewson fbffd3168c Even more clarifying comments. 2023-02-07 09:02:15 -05:00
Nick Mathewson 328535855a netdoc: Try to add a bunch of clarifying documentation.
In the process I found a couple of keys without identifiers in the
spec.
2023-02-07 09:02:15 -05:00
Nick Mathewson 6954c6b488 netdoc: Use Signature::from to construct ed25519 sigs. 2023-02-07 09:02:15 -05:00
Nick Mathewson 4c24f8e8a2 netdoc: Clear up a few typos in hsdesc comments and strings. 2023-02-07 09:02:15 -05:00
Nick Mathewson d699742400 netdoc: Implement onion service descriptor parsers. 2023-02-07 09:02:15 -05:00
Nick Mathewson 2b82011dfb tor-checkable: Add dangerously_map() functions.
These functions consume a checkable wrapper, and return a new
checkable wrapper with mapped contents but the same not-yet-checked
constraints.

As documented, They are "dangerous" because the provided function
gets access to the contents before they are checked; the caller has
to make sure that the provided function doesn't expose their
contents inappropriately.
2023-02-07 09:02:15 -05:00
Nick Mathewson 23757d90c1 netdoc: Parse the inner layer of an onion service descriptor.
There are some places where I note certificates which are not
currently validated, because there is no cryptographic point in
doing so.  We should either document that this is okay, or validate
the certificates anyway.

This code might benefit from refactoring to make it prettier.
2023-02-07 09:02:15 -05:00
Nick Mathewson 6817f61641 netdoc: Add a workaround for C Tor's lack of mid-layer NL
It turns out that C Tor doesn't add a newline at the end of the
middle layer of an onion service descriptor.  I've made a spec MR
(torspec!109) to document this: here, it's time to work around the
issue.
2023-02-07 09:02:15 -05:00
Nick Mathewson 4be4d178fa netdoc: Parse the middle layer of a hsdesc, and decrypt it. 2023-02-07 09:02:15 -05:00
Nick Mathewson 321c8582ce netdoc: Use correct size for descriptor encryption cookie 2023-02-07 09:02:15 -05:00
Nick Mathewson d8849f583e netdoc: move test descriptor to a higher level test module
We're going to make use of it in all of our tests, so we may as well
expose it to them from hsdesc::test.
2023-02-07 09:02:15 -05:00
Nick Mathewson 02fa682bc0 netdoc: implement onion service descryptor encryption
This is tested via a round-trip check, and via a successful
decryption of our example descriptor's outer layer.
2023-02-07 09:02:13 -05:00
Nick Mathewson 6c4e9c8f1d netdoc: Parser for outer layer of onion service descriptors. 2023-02-07 09:00:19 -05:00
Nick Mathewson d35e8a751d netdoc: Add an example onion service descriptor to test our parsing.
I generated this using C tor (latest main) and a Chutney network
about a week ago.

The subcredential is:
   78210A0D2C72BB7A0CAF606BCD938B9A3696894FDDDBC3B87D424753A7E3DF37
The HS_blind_id is:
   43CC0D62FC6252F578705CA645A46109E265290343B1137E90189744B20B3F2D
2023-02-07 09:00:19 -05:00
Nick Mathewson 0f1cfc308a netdoc: Derive Debug and Clone on HsDesc and its kin. 2023-02-07 09:00:19 -05:00
Nick Mathewson 4c0be7c568 hscrypto: Impl From<Ed25519Identity> for BlindedOnionId. 2023-02-07 09:00:19 -05:00
Nick Mathewson 3ce5ee1499 hscrypto: add From/Into between RevisionCounter and u64. 2023-02-07 09:00:19 -05:00
Nick Mathewson a751eacd5b tor-cert: document hs-related certificate types.
Also, explain why a few of these certificates aren't actually useful
as certificates.  (This issue is also documented in torspec!110)
2023-02-07 09:00:19 -05:00
Nick Mathewson 079002d283 tor-cert: Implement Timebound for Ed25519Cert
This allows us to run `is_valid_at` and friends on the certificate
itself, which we will use soon in hsdesc validity checks.
2023-02-07 09:00:19 -05:00
Nick Mathewson 59b981ea5e llcrypto: Implement `Into<[u8;32]>` for Ed25519Identity 2023-02-07 09:00:19 -05:00
Nick Mathewson 72448b704a llcrypto: Derive zeroize for CtByteArray. 2023-02-07 09:00:19 -05:00
Ian Jackson a0a740ffc1 tor-linkspec: LinkSpec parsing: use read_nested_u8len (fmt) 2023-02-06 16:08:32 +00:00
Ian Jackson 5997d99a7a tor-linkspec: LinkSpec parsing: use read_nested_u8len
This eliminates hardcoded length values.
2023-02-06 16:08:21 +00:00
Nick Mathewson 73199ebf68 netdoc: Require that unrecognized tokens be handled explicitly.
Now we require that, for all `SectionRules`, either the caller say
how to handle unrecognized tokens (using `.add(UNRECOGNIZED...)`),
or that they explicitly reject unrecognized tokens (using
`reject_unrecognized`()`.)

This solution uses an assert!() rather than an Error to indicate
failure.  I say that's fine, since
  1. This is a crate-internal API.
  2. We never dynamically construct SectionRules according to
     different behavior: they are always prefabricated in a fixed
     code block.  Thus, if we test a parser at all, we will make
     sure that its SectionRules are well-formed.

I considered and explicitly rejected a solution where the builder
had to be finalized with separate methods `build_strict()` or
`build_tolerant()`: It's too easy IMO for the caller to forget what
these call means.

Prevents further recurrences of #752.

Closes #752.
2023-02-03 11:33:30 -05:00
Nick Mathewson 13d5452e2e netdoc: Switch SectionRules building to use a Buidler pattern.
No new behavior yet.
2023-02-03 11:14:00 -05:00
Nick Mathewson 266c61f721 Add a rule to handle UNRECOGNIZED in AuthCert.
This fixes an instance of bug#752.  Previously, we would reject any
AuthCert that contained an unexpected keyword.  (Fortunately, this
data format does not change very often.)
2023-02-03 10:53:23 -05:00
Ian Jackson d469aef72a Tidy up docs about RouterStatusIdx
Always use "index" and not "position".

Remove wording which is otiose given the type name.
2023-02-01 19:40:17 +00:00