Commit Graph

216 Commits

Author SHA1 Message Date
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
Nick Mathewson 6ff619aab3 netdoc: when parsing from a string, detect extra tokens 2020-06-09 14:06:17 -04:00
Nick Mathewson 4408fc7084 Netdoc: allow parsing multiple routerdescs from a string. 2020-06-09 13:58:43 -04:00
Nick Mathewson 4a5b31d6cd netdoc: report microdesc errors at correct offsets. 2020-06-09 13:13:34 -04:00
Nick Mathewson d4f58b0977 netdoc: fix microdesc digest calculation at last. 2020-06-09 13:07:44 -04:00
Nick Mathewson 47c3a11d2c Add a "first_item" entry for Section.
This will make it simpler to implement digests for sections.
2020-06-09 12:44:24 -04:00
Nick Mathewson 96f3d8c846 Add a "last_item" entry for Section.
This will make it simpler to implement digests for sections.
2020-06-09 12:39:07 -04:00
Nick Mathewson ad79778a39 netdoc: recover from microdesc parsing errors
On an error, advance to the start of the next microdesc.

There's a possible issue with this approach where if we aren't
careful, we might wind up in an infinite loop.  I've made a comment
about the fragility here, but it would probably be good to revisit
this design.
2020-06-08 11:52:26 -04:00
Nick Mathewson 624843668a netdoc: add an iterator that can parse annotated microdescs 2020-06-07 18:57:26 -04:00
Nick Mathewson 78aa76ab36 Implement parsing for microdescriptor annotations
This patch also updates the microdescriptor parsing so we can handle
a whole bunch of them in a row.
2020-06-06 20:51:22 -04:00
Nick Mathewson 1e8bde2c45 netdoc: fix behavior when using a fancy closure with PauseAt.
Previously, every call to peek() or next() would call self.pred().
But this would run us into trouble if we were using a closure that
had mutable state, since it would stop us from checking for things
like "the third occurrence of the foo token".

Now we store the value of self.pred(self.peek()).
2020-06-06 17:13:06 -04:00
Nick Mathewson fe93263d35 netdoc: add annotation fields for microdescriptors 2020-06-06 15:31:03 -04:00
Nick Mathewson b3f2e273c5 note that microdescriptor sha256 calculation is wrong 2020-06-03 17:26:18 -04:00
Nick Mathewson 5d0990658a Restore a pause_at() method, but for NetDocReader. 2020-06-03 17:24:14 -04:00
Nick Mathewson 81f67e240b Remove the Pausable trait as busted.
We need to have the Peekable be long-lived, so we can't consume it.
We _could_ create a second Peekable, which is apparently what we
have been doing, but that breaks down when we try to do it again.
2020-06-03 17:08:47 -04:00
Nick Mathewson bc6d1b2228 netdoc: Refactor iteration over tokens.
I want the "peekable iterator" type to be passed around a lot, and
it needs to have some way to get at the string that's used with it.
2020-06-03 12:45:17 -04:00
Nick Mathewson 9742f3ac42 Netdoc: tweak definition for keywords to accommodate annotations
The macro can now define annotations that don't count as regular
keywords.  Additionally, the Keyword trait is now tweaked to take
advantage of the fact that every Keyword is Copy.
2020-05-27 13:09:22 -04:00
Nick Mathewson 56b9e3fbc6 netdoc: exit an object if we encounter non-base64.
This way, an unterminated base64 object doesn't "eat" the whole rest
of something we're trying to parse.
2020-05-20 13:04:28 -04:00
Nick Mathewson 0e40748e4d netdoc: tokenizer should always consume bytes if they exist.
Also document that it always consumes a positive integer number of
lines.

This is part of an effort to improve error recovery.
2020-05-20 12:24:31 -04:00
Nick Mathewson 0f5915915b netdoc: Teach tokenizer about annotations.
I'm not sure that annotations are a feature I want to keep
long-term, but for now it would be useful if this code can also read
Tor's file formats for network directories.
2020-05-19 14:06:19 -04:00
Nick Mathewson c427b26fe7 netdoc: Add convenience methods for pausing iterators 2020-05-19 12:14:13 -04:00
Nick Mathewson 8468c8ec49 netdoc: move keyword into Item type.
This saves us from having to check specific strings in most cases.
2020-05-19 12:01:06 -04:00
Nick Mathewson e3d68d6db6 netdoc: Extract keyword into its own file. 2020-05-19 11:43:15 -04:00
Nick Mathewson 006efbffbc start a test for microdesc parsing. 2020-05-18 14:41:23 -04:00
Nick Mathewson 2adbcf1a79 tor-netdoc: add a peek() method to util::Pausable. 2020-05-16 10:46:06 -04:00
Nick Mathewson a8be828beb Implement microdescriptor parsing.
Additionally, move and refactor related types to reduce friction for
microdescriptor parsing implementation.
2020-05-15 19:25:40 -04:00
Nick Mathewson fa064717b3 tor-netdoc: Move RelayFamily into its own module. 2020-05-15 16:50:32 -04:00
Nick Mathewson 085a8250e7 tor_cert: use caret_int!() to make real types for cert elements 2020-05-15 16:07:02 -04:00
Nick Mathewson 8f20c273cf tor-netdoc: extract fingerprint logic from routerdesc.rs 2020-05-15 14:40:53 -04:00
Nick Mathewson 84fd65fb85 netdoc: Improve parsing implementation for RelayFamily. 2020-05-15 14:06:22 -04:00
Nick Mathewson c1d6a74756 netdoc: Relax error types that can be used when parsing. 2020-05-15 14:01:50 -04:00
Nick Mathewson 0427abcee2 netdoc: teach MaybeItem about parse_args_as_str().
This simplifies a couple of places in routerdesc parsing.
2020-05-15 13:44:53 -04:00
Nick Mathewson ebfeefeba8 tor-netdoc: Extract family parsing into its own function. 2020-05-15 13:34:45 -04:00
Nick Mathewson b19d480558 Extract RelayPlatform parsing. 2020-05-15 13:22:39 -04:00
Nick Mathewson c7d0d27754 netdoc: get positions right in version parsing. 2020-05-15 13:22:15 -04:00
Nick Mathewson 60adff1fd7 netdoc: use improved API for parsing ed25519 certificates. 2020-05-15 11:49:49 -04:00
Nick Mathewson 332b9de542 netdoc: use new router object parsing API for RSA public keys. 2020-05-15 11:20:57 -04:00
Nick Mathewson f6dd702316 Netdoc: better parsing for objects.
If I'm right this will let us simplify our code for parsing things
from directory objects by a lot.
2020-05-15 11:18:04 -04:00
Nick Mathewson 9b581588d6 Remove 'idx' field from BadArgument.
Having byte-level positions means we don't need to complain about
particular arguments.
2020-05-15 10:37:29 -04:00
Nick Mathewson d82cb7e5d1 netdoc: remove ArgError. 2020-05-15 08:47:32 -04:00
Nick Mathewson dea1530492 netdoc: Make args_as_vec() non-public.
It returns a Ref, and that's kinda implementation-dependent.
2020-05-13 17:25:11 -04:00
Nick Mathewson 4f4bc52e36 Improve reported positions of parsing errors. 2020-05-13 17:17:56 -04:00
Nick Mathewson b42f91b591 netdoc: remove the Item::off field as redundant
Now that we are okay with using slice offset pointer math, we can
remove the 'off' field from Item entirely.
2020-05-13 16:09:16 -04:00
Nick Mathewson 9443fc7690 netdoc: rename Position to Pos.
We use this type a lot, so let's give it a short name.
2020-05-13 13:52:53 -04:00
Nick Mathewson 9321e7acd9 netdoc: use a more flexible error-position type based on raw pointers
Astonishingly, this is safe, though I wish that it were impossible
to use mismatched strings.
2020-05-13 13:48:57 -04:00
Nick Mathewson 26079d66e4 netdoc: Add an "at()" method to replace an error's location. 2020-05-13 13:00:57 -04:00
Nick Mathewson 598ea96911 routerdesc: enforce position of identity-ed25519. 2020-05-12 08:14:17 -04:00
Nick Mathewson 84ac61b5d4 Note a type that should get moved some day 2020-05-09 13:35:58 -04:00
Nick Mathewson 7ec2254634 tor-netdoc: require documentation, and fill in final missing docs 2020-05-09 13:34:59 -04:00
Nick Mathewson 5d3f13e6e7 Netdoc: allow doc comments and visibility modifier in decl_keyword! 2020-05-09 13:31:29 -04:00
Nick Mathewson 73752fb647 netdoc: document routerdoc.rs 2020-05-09 13:29:49 -04:00
Nick Mathewson bf19811d22 Netdoc: remove dead code or annotate it as allowed. 2020-05-09 13:08:31 -04:00
Nick Mathewson 080667da37 netdoc: Document rules.rs, and refactor slightly. 2020-05-09 11:54:21 -04:00
Nick Mathewson c739c2e424 netdoc: Improved error type for Section::GetRequired. 2020-05-09 11:30:02 -04:00
Nick Mathewson abe9200eea Make the members of TokenFmt private, and simplify the API in the process. 2020-05-09 11:30:02 -04:00
Nick Mathewson 56694d4fc8 Move Item verification to be a method of TokenFmt. 2020-05-09 11:30:02 -04:00
Nick Mathewson d9513492fe Move MaybeItem into tokenize.rs 2020-05-09 11:30:02 -04:00
Nick Mathewson 624dca4056 Document parse.rs in tor-netdoc, and note things to move or fix 2020-05-09 11:30:02 -04:00
Nick Mathewson 07d6cd956a Fix a logic error when finding position of unexpected keyword.
This appears to be a bad copy-paste.
2020-05-09 11:30:02 -04:00
Nick Mathewson 07e41734ec Document more of 'netdoc', including errors. 2020-05-09 11:30:02 -04:00
Nick Mathewson c4d0f59e7d netdoc and version docs 2020-05-08 22:32:17 -04:00
Nick Mathewson 3c7f75302b Stop re-exporting traits from tor-llcrypto. It does not help. 2020-05-08 22:32:17 -04:00
Nick Mathewson bbcbf47902 Fresh git repository for work on "arti"
Arti is a rust tor implementation.  It's project I've been working
on for a few months now, in weekends and in spare time.  It doesn't
speak the tor protocol yet, and it doesn't connect to the network at
all.

It needs much more documentation and testing, but I'm just about
ready to show it to others.  See the README.md for a description of
what is there and what isn't.
2020-05-07 19:58:14 -04:00