Commit Graph

291 Commits

Author SHA1 Message Date
Nick Mathewson ad36e3acec Fix some comments that reflected a misunderstanding in SENDMEs
I had thought that the sendme authentication things used for
onion services were 32-byte; they're still only 20.
2020-09-26 19:25:51 -04:00
Nick Mathewson b710e5c770 Split the cell-handling parts of tor-proto into a new crate. 2020-09-26 12:49:03 -04:00
Nick Mathewson 653de035bc Make sendme authentication optional.
This code deviates from current tor in that it allows missing
sendme authentications only when we know we're talking to an old
relay, or when we don't know the version of the relay we're talking
to.
2020-09-25 19:20:32 -04:00
Nick Mathewson adf5ef3f5c Lower our "#[allow(dead_code)]" decl in tor_proto." 2020-09-25 18:57:21 -04:00
Nick Mathewson 343af46715 Improve documentation and lightly refactor SENDME code 2020-09-25 18:49:23 -04:00
Nick Mathewson ba1600371b Implement authenticated sendme output for circuit-level sendmes.
This patch has a XXXXX kludge note in it.
2020-09-25 18:49:23 -04:00
Nick Mathewson c0ee910413 Add a bad workaround for a deadlock: we should look for a better one. 2020-09-25 17:06:33 -04:00
Nick Mathewson 6071b0e903 Fix encoding/decoding of authenticated sendme. 2020-09-25 17:06:33 -04:00
Nick Mathewson 08cfb40350 Try to get sendme crypto working
There's a problem, though: this code assumes that tags are 20 bytes
long whereas actually the tag type is part of the crypto layer info.

So maybe in the long term we need to move the queue of tags from the
send window into being part of the crypto layers.
2020-09-25 17:06:33 -04:00
Nick Mathewson bc4c05d6a7 Incomplete implementation of circuit SENDME handling.
This is incomplete because the cell crypto code doesn't actually
expose tags yet, and because it demands tags unconditionally,
without caring about the linkspec protocol version.
2020-09-25 17:06:33 -04:00
Nick Mathewson 06ede86f7f Attempted implementation of stream sendme cells 2020-09-25 17:06:33 -04:00
Nick Mathewson 92463dc03e Initial work on a sendme backend.
Parameterized for authenticated/unauthenticated operation, and
operation on circuits and streams.
2020-09-25 09:47:55 -04:00
Nick Mathewson 60ff67113f Initial error cleanup on streams/circuits 2020-09-25 08:35:48 -04:00
Nick Mathewson 18b13e8cae Migrate ClientMain to byte-oriented API. 2020-09-24 18:56:54 -04:00
Nick Mathewson 50848b8fa0 Try to make a send/receive style API for streams. 2020-09-24 18:03:03 -04:00
Nick Mathewson da3a8fdd50 Add support for RELAY_END cells.
This was a hard one.  I need to make sure that we send an END cell
when the stream is dropped.  But we can't call an .await from inside
the drop() function, since drop() isn't async, and we don't have an
executor.

Fortunately, you can call send() on a oneshot::Sender without having
to await on it, so that's the obvious thing to put in drop().  But
we need some way to make sure that the oneshot::Receiver is given to
the reactor, and is .awaited.  For that, we needed a control
channel.  And the reactor needs to treat the control channel and the
close messages as equally important.

So that's how I wound up with a
  Fuse<Select<mpsc::Receiver<Result<Foo>>,
              SelectAll<Once<oneshot::Receiver<Foo>>>>>.

I doubt that this is actually the best way to handle any of this!
2020-09-24 15:33:54 -04:00
Nick Mathewson 9e8350aea0 as Tor does, skip to random initial stream member. 2020-09-23 19:50:15 -04:00
Nick Mathewson c35477bb3d Fuse input streams on creation. 2020-09-23 19:21:49 -04:00
Nick Mathewson 6492334aff Turn IdMap into an extension trait.
Also, use the "right" (cyclic, potentially expensive) algorithm for
stream IDs.
2020-09-23 17:53:58 -04:00
Nick Mathewson 0c131dc080 Run cargo upgrade 2020-09-21 13:45:36 -04:00
Nick Mathewson 3eb087bf16 turn hopnum into a first-class type 2020-09-21 12:56:30 -04:00
Nick Mathewson c276cfcb73 Add is_zero for ID types. 2020-09-21 12:27:45 -04:00
Nick Mathewson fb7703f7e9 Fix some errors; document some places where error handling is bogus 2020-09-21 12:22:35 -04:00
Nick Mathewson 68fc1b0f4d More documentation for channel, circuit, stream. 2020-09-21 12:10:51 -04:00
Nick Mathewson bc00417f01 Start implementing streams and circuit-level reactors.
Also, revise nearly all of the circuit/channel interaction to
actually send relay cells to the right place and do sensible things
with them.
2020-09-21 10:42:36 -04:00
Nick Mathewson 296bfbe57b Add RelayCmd::accepts_streamid_val 2020-09-20 14:09:10 -04:00
Nick Mathewson 9567689a30 Refactor accetps_circid_val to be less wonky. 2020-09-20 14:09:10 -04:00
Nick Mathewson a3384bc126 Move is_recognized function into caret. 2020-09-20 14:09:10 -04:00
Nick Mathewson a547cda19f Rename StreamCmd to RelayCmd 2020-09-20 14:09:10 -04:00
Nick Mathewson c6d403472f Improve shutdown support for channel. No idea if it works. 2020-09-20 14:09:10 -04:00
Nick Mathewson 9c4685968c rename a field in RelayCell 2020-09-20 14:09:10 -04:00
Nick Mathewson 988556dbef Create a StreamID->Stream map type.
Also extract the shared part of CircMap and StreamMap into a new
IdMap type.
2020-09-20 14:09:10 -04:00
Nick Mathewson 0075b784a1 De-parameterize channel and circuit
By putting the cell-sink in a box, we can get rid of the need for
having everything that uses a channel or a circuit know what kind
of underlying TLS implementation it has.
2020-09-19 22:29:18 -04:00
Nick Mathewson 56d8bc1756 Add tests for CREATE_FAST handshake 2020-09-19 13:06:40 -04:00
Nick Mathewson 80d1d27810 Add tests for failing ntor handshakes. 2020-09-19 12:37:17 -04:00
Nick Mathewson 389fc03e1e ntor: test the ClientHandshake/ServerHandshake impl 2020-09-18 21:20:22 -04:00
Nick Mathewson 3907e4a0c9 tests for kdf functions in tor_proto 2020-09-18 20:57:56 -04:00
Nick Mathewson 69e1c91ba1 Add tests for tor_proto::util::ct 2020-09-18 20:00:06 -04:00
Nick Mathewson 5f54be2234 Give up on suppressing that nightly-only clippy warning 2020-09-18 19:28:55 -04:00
Nick Mathewson 6a2c803f98 Resolve some nightly-only clippy warnings 2020-09-17 19:13:56 -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 f256847f82 Sort linkspecs in the same order as tor does 2020-09-17 15:33:18 -04:00
Nick Mathewson ee9b871bc5 Make client-demo launch a request to www.torproject.org:80 2020-09-12 21:32:00 -04:00
Nick Mathewson 02fc8b2528 Implement extend2/extended2 handshake.
This is not a production-ready implementation: it will break if a
circuit is used for anything while an extend is pending.

Client-demo can now build 3-hop circuits.
2020-09-12 20:48:07 -04:00
Nick Mathewson df0ebf857f Make more types implement Debug. 2020-09-12 20:45:59 -04:00
Nick Mathewson a9181131d2 Fix a bug in encoding extend2 cells. 2020-09-12 20:44:25 -04:00
Nick Mathewson dc287d4457 WIP: extend. 2020-09-12 17:01:15 -04:00
Nick Mathewson d1039dda9b Simple functions to send and receive relay cells. 2020-09-12 16:25:10 -04:00
Nick Mathewson 3e342a69ae Add a function to pad relay cells. 2020-09-12 15:55:04 -04:00
Nick Mathewson 2fb71d2b13 Refactoring around our 509-byte array type. 2020-09-12 15:47:12 -04:00
Nick Mathewson 74798337dd Ntor handshake (first hop) is go. 2020-09-11 20:00:26 -04:00
Nick Mathewson e10fc436a9 Wrap ntor handshake in appropriate trait. 2020-09-11 19:45:15 -04:00
Nick Mathewson b2c2fb66c9 Parameterize the circuit create code. 2020-09-11 19:35:38 -04:00
Nick Mathewson b29f9f0772 Make create_fast implementation a little more generic. 2020-09-11 19:15:27 -04:00
Nick Mathewson a4697e4528 For circuits: Implement first hop create via create_fast. 2020-09-11 19:00:55 -04:00
Nick Mathewson a62717690b proto: add minimal (raw) circuit support.
This is about enough to make a circuit, send a create_fast cell, and
get a created_fast cell back.
2020-09-11 15:10:34 -04:00
Nick Mathewson f20eb2f43f proto::channel: add piping to move cells around.
There's a "reactor" task to move cells to the appropriate circuit,
and a "send_cell" to send a cell directly.

This is client-only for now.
2020-09-11 13:58:05 -04:00
Nick Mathewson 49bbb4baa6 Turn channel into a handle-to-inner type.
I think I'll likely be refactoring this a _bunch_ before I actually
get to use this.
2020-09-10 13:19:39 -04:00
Nick Mathewson 812056d663 Move channel handshake into its own module. 2020-09-10 12:43:55 -04:00
Nick Mathewson ee71abe560 Pare down and sort dependencies 2020-09-09 19:17:49 -04:00
Nick Mathewson 9f30b47cb7 Run cargo upgrade, except for stream-cipher. 2020-09-09 19:06:00 -04:00
Nick Mathewson e95dec2437 cargo fix --edition-idioms 2020-09-09 18:59:04 -04:00
Nick Mathewson 34843f1fde Add some missing documentation 2020-09-09 18:58:33 -04:00
Nick Mathewson e02255ec00 Also RSA identities on channel handshakes
This took a good bit of hacking, including a kludge to extract an
RSA subject key from an x509 cert, since we didn't have a good way
to do that.
2020-09-09 18:08:33 -04:00
Nick Mathewson 8d01a0a808 Implement most of client-side channel cert validation. 2020-09-09 16:19:42 -04:00
Nick Mathewson e395ad5801 Declare Into<ChanCell> for channel messages without circids 2020-09-09 14:38:16 -04:00
Nick Mathewson e45e6f5954 Work on client channel handshake: mostly done, except for verification 2020-09-09 14:32:41 -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 541b6fa55f relaycell: slight error cleanup 2020-09-07 12:25:41 -04:00
Nick Mathewson 6456653941 relaycell: move cmd into Unrecognized. 2020-09-07 12:19:19 -04:00
Nick Mathewson 010d93f453 proto::relaycell: documentation and light refactoring 2020-09-07 12:14:23 -04:00
Nick Mathewson b91f6b2cbd rename relaycell stuff to its own module; rename a bit 2020-09-06 22:01:15 -04:00
Nick Mathewson 4266aa7d12 proto: Finish documenting chancell 2020-09-06 21:49:30 -04:00
Nick Mathewson 7095192063 proto: small err cleanups 2020-09-06 17:50:06 -04:00
Nick Mathewson b54a960f3d proto: make write_body_onto destructive. That might help down the road 2020-09-06 17:20:02 -04:00
Nick Mathewson ae1c813a70 Reinstate ChanCell as a meaningful type. 2020-09-06 17:15:07 -04:00
Nick Mathewson e749e2bc27 proto: major refactor to channel cells
The protocol is now based around a message-oriented scheme intended
to use futures_codec, which in turn uses BytesMut.  The transition
to BytesMut is incomplete, and we're not nearly so zero-copy as
intended.  We should think about that.
2020-09-06 16:00:14 -04:00
Nick Mathewson 4b75c51882 Run cargo-upgrade. 2020-08-28 18:14:17 -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 c602883881 Use "cargo upgrade" from cargo-edit to list current versions 2020-06-12 21:06:07 -04:00
Nick Mathewson 6264041b77 update to use latest rust-crypto traits and modules 2020-06-10 14:16:07 -04:00
Nick Mathewson 86894926aa tor-proto: use caret_int!() for cell and relay commands. 2020-05-15 16:27:03 -04:00
Nick Mathewson 9c62d15846 tor-proto: Simplify ct::lookup API. 2020-05-10 12:10:16 -04:00
Nick Mathewson 240badb20b Document most of tor-proto
(except for the worst parts that need refactoring the most)
2020-05-09 16:25:17 -04:00
Nick Mathewson 11abdcbf3e tor-proto: Fix a logic error in KDF-TOR implementation. 2020-05-09 14:01:48 -04:00
Nick Mathewson 641576aa44 Use links for traits in llcrypto docs 2020-05-08 22:32:17 -04:00
Nick Mathewson f24ddf0682 Upgrade to a modern version of "sha-1".
Apparently the "sha1" crate doesn't implement the RustCrypto
API, but the "sha-1" crate does.
2020-05-08 22:32:17 -04:00
Nick Mathewson 75a1269429 make id field in RSAIdentity private 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