Commit Graph

212 Commits

Author SHA1 Message Date
Nick Mathewson 7af214b594 When storing consensuses, index them by the sha3 of the whole file. 2020-11-23 11:11:17 -05:00
Nick Mathewson 9f4230fb1b Initial pass on directory-manager code.
This code can now bootstrap from the network, cache the results, and
reload from cache.

There's lots more work to do here, including a big pile of tidying
and refactoring and testing and documentation.
2020-11-19 19:11:10 -05:00
Nick Mathewson 87fe434875 Refactor AuthCertKeyIds::cmp(). 2020-11-19 11:38:06 -05:00
Nick Mathewson 02bac5f04e Add support for using fallback directories in path construction
This is mainly a refactoring commit, with a little new code.

It also adds #[derive(Copy,Clone)] for a few types.
2020-11-19 10:06:48 -05:00
Nick Mathewson 168def3c28 Make AuthCertKeyIds sortable. 2020-11-16 15:08:12 -05:00
Nick Mathewson 29afe2869f Type and functions for key ID inspection of AuthCert. 2020-11-16 08:55:31 -05:00
Nick Mathewson 4512d7e9ed Have the consensus-parsing code expose the signed piece of the consensus. 2020-11-16 08:55:31 -05:00
Nick Mathewson cc59658fea Add accessors for consensus lifetimes. 2020-11-14 10:32:17 -05:00
Nick Mathewson 0d1489be4e Remember the position of authcert and microdescs
We'll need this to save them to disk after parsing them from an
upstream source.
2020-11-14 10:32:17 -05:00
Nick Mathewson 38070d6ec9 netdoc: Add a bogus "Extent()" facility to remember where things were.
Also add the missing str.rs file (oops)
2020-11-14 10:32:17 -05:00
Nick Mathewson 8569af82dd netdoc: split off string utils 2020-11-14 10:32:17 -05:00
Nick Mathewson e417a9dc13 Use Infallible in tor-netdoc. 2020-11-11 10:09:16 -05:00
Nick Mathewson 136c536123 Mark tor_netdoc::err::Pos as Send and Sync
I am about 99% sure this is safe: the pointer that this type
contains is never dereferenced, and is only compared to the bounds
of a string later on.
2020-11-11 10:00:48 -05:00
Nick Mathewson c440f4d476 Use bitflags crate to represent RouterFlags. 2020-11-11 09:33:53 -05:00
Nick Mathewson 4d24fff9c0 Upgrade dependencies 2020-11-10 12:27:10 -05:00
Nick Mathewson d9dafa0a28 Add a new circuit-manager crate and move path selection there. 2020-11-02 10:44:31 -05:00
Nick Mathewson b93e4b76c8 Remove a bunch of dbg! calls. 2020-10-26 14:33:14 -04:00
Nick Mathewson d3b71bc177 More documentation in tor-netdoc. 2020-10-26 11:51:53 -04:00
Nick Mathewson 8c09981427 Use from_bytes name for Ed25519Identity 2020-10-25 20:32:47 -04:00
Nick Mathewson f3e1fafca2 Validate master-key-ed25519 field in routerdescs 2020-10-19 09:44:38 -04:00
Nick Mathewson 57637f3644 netdir: don't use relays with NoEdConsensus flag set. 2020-10-19 09:31:36 -04:00
Nick Mathewson 295a791a82 Improvements to Relay type in tor-netdir.
Now, a Relay is always valid.  This required some changes to the
API: all_relays() has to return a new UncheckedRelay type that might
or might not be valid, and the functions on Relay and ChanTarget
that return ed25519 identities need to return an Ed25519Identity,
not an ed25519::PublicKey.

This change required some new encoding/decoding/conversion functions
on Ed25519Identity.
2020-10-19 09:22:49 -04:00
Nick Mathewson 3798891b36 Calculate digest correctly when microdesc ends with base64 object. 2020-10-19 08:42:35 -04:00
Nick Mathewson df406f5319 Netdoc: validate objects even on unrecognized items. 2020-10-19 08:09:20 -04:00
Nick Mathewson 6f3d5d061d portpolicy: note a spec issue 2020-10-19 08:08:38 -04:00
Nick Mathewson 5523134607 Mark must-resolve XXXX issues with "XXXXM3".
"M3" is for "milestone 3" -- my target to fix the technical debt
that I think will be bad if we ship even a pre-alpha with it.

These aren't necessarily _all_ must-resolve, but they're all
must-look-at.

Closes #15
2020-10-18 17:38:59 -04:00
Nick Mathewson 32bfeb84eb Update microdesc parsing: ed25519 keys are no longer optional. 2020-10-18 17:12:47 -04:00
Nick Mathewson 353a4bfb87 Cleanup from prop315 implementation.
Most of the fixes here are just removing comments that said "this
isn't technically required but I'm going to pretend it is".

I also made the "protocols" field in microdescs out of its Option<>,
since we're now requiring that.
2020-10-16 16:36:51 -04:00
Nick Mathewson 7a4c1e87ea Implement proposal 315: make various directory fields required 2020-10-16 16:30:40 -04:00
Nick Mathewson 3408c9ad26 Run "cargo upgrade". 2020-10-15 13:32:02 -04:00
Nick Mathewson 6f75b82ef3 Use Ed25519Identity in microdescriptors. 2020-10-15 12:42:09 -04:00
Nick Mathewson 6b2ba9a16c Document remaining private members of tor-netdoc. 2020-10-10 16:41:43 -04:00
Nick Mathewson f8fde02c0b Document most private items in tor-netdoc. 2020-10-09 18:02:02 -04:00
Nick Mathewson b845d37b3b Add routerdesc examples 2020-10-07 13:48:31 -04:00
Nick Mathewson b3e2086c7b netdoc: more tests for routerdesc parsing 2020-10-07 13:19:17 -04:00
Nick Mathewson 30f8aead6c A few more tests in tor-netdoc 2020-10-07 11:34:12 -04:00
Nick Mathewson 0ba8ab9b9a netdoc: test for signature/key checking func 2020-10-07 10:58:32 -04:00
Nick Mathewson b371a84a26 mdconsensus: add tests for a few accessors 2020-10-06 15:02:55 -04:00
Nick Mathewson 02e5380a73 tests for some failing cases in mdconsensus 2020-10-06 14:12:43 -04:00
Nick Mathewson 580c1ac567 Tokenize: report accurate positions for more parsing errors 2020-10-02 15:25:28 -04:00
Nick Mathewson f89283eaa6 microdesc parsing: tests for bad microdescs 2020-10-02 15:24:00 -04:00
Nick Mathewson ff852df70e tests and fixes for md content parsing 2020-10-02 14:04:03 -04:00
Nick Mathewson 8c2aae10f7 netdoc: remove some outdated/unused stuff. 2020-10-02 11:21:59 -04:00
Nick Mathewson 1adc6c40fb authcert: test error recovery. 2020-10-02 10:59:55 -04:00
Nick Mathewson 38685d3cc1 Netdoc: use a more bulletproof pattern to prevent infinite loops
Previously our "read a bunch of this kind of document" functions had
a common problem, where they could get into an infinite loop if the
underlying "read this kind of document" function failed without
consuming any tokens.

I _think_ that this error case was unreachable (or else fuzzing
would have found it, right?), but proving that it was unreachable
was a bit fiddly, and I couldn't follow my own arguments about it.

Instead, we just store the position of the reader before we start
reading, and make sure that it has consumed at least some data.  If
it hasn't, then we consume and drop a token before advancing to the
next document.
2020-10-02 10:15:14 -04:00
Nick Mathewson 4a1f319ffe authcert: add tests for several ways certs can fail. 2020-10-02 09:50:47 -04:00
Nick Mathewson 17e82a50c2 authcert: fix an error, and detect mismatched fingerprints 2020-10-02 09:49:27 -04:00
Nick Mathewson e6ba2ac8ed netdoc: rename BadVersion to BadTorVersion for clarity 2020-10-01 10:23:22 -04:00
Nick Mathewson 5ff859b89d improve errors in authcert.rs 2020-10-01 10:21:25 -04:00
Nick Mathewson a5f382aa61 Remove redundant signature check in authcert parsing. 2020-09-30 18:50:31 -04:00
Nick Mathewson d4d3e1c3db More tests on parsing, plus remove dead code. 2020-09-30 18:46:27 -04:00
Nick Mathewson c4d0ffa859 Start on some parser backend tests 2020-09-30 14:20:01 -04:00
Nick Mathewson 035e0422d9 tokenize: accept base64 with funny linewraps. 2020-09-30 14:19:07 -04:00
Nick Mathewson 9cab4e0f14 More tests for tokenize.rs, with some bugfixes 2020-09-30 09:39:52 -04:00
Nick Mathewson 59c46ec27b Start on some tests for parse::tokenize.rs 2020-09-29 17:30:48 -04:00
Nick Mathewson aafef113b3 Add tests for macros module in tor-netdoc.
Also improve output for multi-keyword tokens.
2020-09-29 17:02:56 -04:00
Nick Mathewson 91b7c7b874 Tests and minor debugging in tor_netdoc::types::policy 2020-09-29 11:34:07 -04:00
Nick Mathewson e02cccdf00 More tests for tor_netdoc::types 2020-09-29 10:15:08 -04:00
Nick Mathewson 788e0347cb Move around the modules inside tor-netdoc.
This change just gives them a more logical breakdown into parsing,
documents, and misc other types.
2020-09-29 09:05:17 -04:00
Nick Mathewson 98ab84e774 Rename remaining get_ accessors 2020-09-28 16:13:14 -04:00
Nick Mathewson 9b276e6a5a tor_cert: rename accessors 2020-09-28 16:01:33 -04:00
Nick Mathewson 05da5a7f73 Rename some identifiers in tor-linkspec.
By convention, rust accessor functions don't start with 'get'.
2020-09-28 15:29:39 -04:00
Nick Mathewson 397d753e4e Fix a few clippy issues 2020-09-27 03:30:09 -04:00
Nick Mathewson a3143ab960 Run cargo upgrade. 2020-09-26 14:20:28 -04:00
Nick Mathewson 5f54be2234 Give up on suppressing that nightly-only clippy warning 2020-09-18 19:28:55 -04:00
Nick Mathewson 5e1e77a363 Make consensus documents valid DistDelay seconds earlier.
This will prevent arti from hitting the same issue as
https://gitlab.torproject.org/tpo/core/tor/-/issues/25756
2020-09-18 19:24:06 -04:00
Nick Mathewson 6a2c803f98 Resolve some nightly-only clippy warnings 2020-09-17 19:13:56 -04:00
Nick Mathewson eb24b6f019 Fix a panic bug in microdesc parsing.
Found by fuzzing!  The issue was that we were relying on the
arguments slice being within the input string, but we were sometimes
using a different _empty_ slice when there were no arguments.

I've noted a better solution in a comment.
2020-09-17 19:07:38 -04:00
Nick Mathewson 91db8ab6fb Add fuzzers for certs, netdoc, and proto.
This was remarkably simple.
2020-09-17 19:06:56 -04:00
Nick Mathewson ba546a798d use more correct expiration times 2020-09-17 15:19:12 -04:00
Nick Mathewson ee71abe560 Pare down and sort dependencies 2020-09-09 19:17:49 -04:00
Nick Mathewson 875e932898 New "linkspec" module to encapsulate info needed to connect/extend. 2020-09-08 20:43:15 -04:00
Nick Mathewson 8768222acb Start on accessors for relay weight. 2020-09-08 17:20:46 -04:00
Nick Mathewson 8ef0098716 Refactor timerangebound to unwrap bounds earlier.
This will make them easier to adjust
2020-09-08 13:54:01 -04:00
Nick Mathewson e31652afe1 Bugfix: parse ed25519 ids right in mds 2020-09-08 13:30:16 -04:00
Nick Mathewson b5ad25e0d4 Netdir: a few more accessors 2020-09-08 12:56:45 -04:00
Nick Mathewson 17217a7dfa netdoc: add a few accessors 2020-09-07 18:07:34 -04:00
Nick Mathewson a4f1b27334 Fix clippy warnings; improve key type for consensus. 2020-09-07 17:27:29 -04:00
Nick Mathewson b6a3642903 netdoc: ignore bad entries in families.
Some of these are nicknames, which we can safely ignore.
2020-09-07 16:57:57 -04:00
Nick Mathewson 919a7c5970 Start on a 'netdir' crate to wrap netdoc.
For now, this assumes an existing Tor cache directory.
2020-09-07 16:53:06 -04:00
Nick Mathewson b679ab216c Make MDConsensus also follow the checkable pattern. 2020-09-03 16:06:45 -04:00
Nick Mathewson fbb35dc72a Port authcert to use tor_checkable. 2020-09-03 15:02:36 -04:00
Nick Mathewson b3358673b5 Migrate certificate and routerdesc checking to tor-checkable
Now these types are parsed and returned wrapped inside a checkable
object.
2020-09-03 14:45:46 -04:00
Nick Mathewson 4b75c51882 Run cargo-upgrade. 2020-08-28 18:14:17 -04:00
Nick Mathewson 6fabb54033 netdoc: Parser for microdesc consensus documents
There's more to do here, and things to refactor, but this ought to
be enough to get a rudimentary client working.
2020-08-27 14:30:24 -04:00
Nick Mathewson 86f6f30b6d netdoc: parse multiple authcerts from a string. 2020-08-27 12:54:07 -04:00
Nick Mathewson 696e7ad334 netdoc: add a check_len method for B64 2020-08-26 10:57:07 -04:00
Nick Mathewson d4af6a163f Add a B16 argument type, to mirror B64. 2020-07-20 20:55:47 -04:00
Nick Mathewson bbb8fea39b More parsing for fingerprints, including non-spaced fingerprints. 2020-07-20 20:55:47 -04:00
Nick Mathewson 8c0bbfef2c tor-netdoc: Make SectionRules derive Clone.
This is going to come in handy for the networkstatus stuff, where I
need to define different variants of SectionRules for votes and
consensuses.
2020-07-20 20:55:47 -04:00
Nick Mathewson 173bec26a5 Update to latest packages; ed25519 now needs signature crate traits. 2020-07-20 20:55:03 -04:00
Nick Mathewson 7bd7e7ec7d Run cargo fix --edition-idioms 2020-06-26 13:17:14 -04:00
Nick Mathewson e1bbc2fdb0 Run "cargo update". 2020-06-21 11:14:56 -04:00
Nick Mathewson c602883881 Use "cargo upgrade" from cargo-edit to list current versions 2020-06-12 21:06:07 -04:00
Nick Mathewson d36f52eea9 Mark a variable unused 2020-06-12 20:04:55 -04:00
Nick Mathewson c7285c9449 Add documentation for authcert parsing. 2020-06-11 17:08:59 -04:00
Nick Mathewson 6264041b77 update to use latest rust-crypto traits and modules 2020-06-10 14:16:07 -04:00
Nick Mathewson c13728eaa2 Add a couple of commits missing from previous. 2020-06-09 18:46:56 -04:00
Nick Mathewson 3b4c828cb7 netdoc: initial implementation of authority certs. 2020-06-09 17:23:45 -04:00
Nick Mathewson 2d8021420f netdoc: note a forward-compatibility issue with RSA signatures. 2020-06-09 17:22:49 -04:00