Commit Graph

5814 Commits

Author SHA1 Message Date
Nick Mathewson 8cda5a1a3e Clarify which netdir index is meant 2023-02-09 14:56:30 +00:00
Ian Jackson 34dcb6004e Merge branch 'hs_descencnonce' into 'main'
Rename DescEncNonce => HsDescEncNonce

See merge request tpo/core/arti!1014
2023-02-09 14:54:49 +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 5851ccb566 Merge branch 'key_renaming' into 'main'
Rename hs-related identifiers to mirror those in the spec

Closes #746

See merge request tpo/core/arti!1011
2023-02-09 12:54:32 +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
Nick Mathewson 9046ef90d0 Merge branch 'typos' into 'main'
Fix typo

See merge request tpo/core/arti!1010
2023-02-07 22:36:49 +00:00
Dimitris Apostolou d1eeffbf42
Fix typo 2023-02-08 00:04:25 +02:00
Nick Mathewson 447312e2fe Merge branch 'ticket_525' into 'main'
Create a macro to generate restricted variations on RelayMsg, ChanMsg.

Closes #525

See merge request tpo/core/arti!1008
2023-02-07 21:37:59 +00: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