aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/crypto/handshake
Commit message (Collapse)AuthorAgeFilesLines
...
* proto: Remove now-unused hs_ntor APIsNick Mathewson2023-06-121-43/+21
|
* proto: refactor hs_ntor to reuse state.Nick Mathewson2023-06-121-14/+49
| | | | | | | | | | We want the ability to send the same handshake request in parallel on multiple introduce circuits. This implies encoding the client handshake more than once. (Sadly we can't _actually_ do this in the protocol as it stands, since the onion service can use a separate KP_hss_ntor for each introduction point; I'll add a comment to that effect later.)
* hs_ntor: several documentation cleanups.Nick Mathewson2023-05-171-6/+14
|
* hs_ntor: make encrypt_and_mac take a typed public keyNick Mathewson2023-05-171-10/+6
| | | | This is still not the most beautiful interface, but it'll do for now.
* hs_ntor: remove the last lingering AsRef<[u8]>Nick Mathewson2023-05-171-7/+7
|
* hs_ntor: Add a test vector case extracted from C tor.Nick Mathewson2023-05-171-0/+104
|
* hs_ntor: Calculate MAC on introduce1 message correctly.Nick Mathewson2023-05-171-3/+12
| | | | | | There were two bugs here that made the behavior unlike that of C tor: we had swapped the MAC inputs, and we had forgotten to include the public key X in the input.
* hs_ntor: Make internal no-rng variants of the handshake functions.Nick Mathewson2023-05-171-2/+25
| | | | We'll want these so we can implement some test vectors.
* hs_ntor: Move extra data outside of the "input" fields.Nick Mathewson2023-05-171-59/+33
| | | | | | | I think that these Input structs had been defined so that we could use hs_ntor interchangeably with other handshakes. The trouble is, though, that it doesn't really work like any other handshakes we have.
* hs_ntor: Use MAC implementation from tor-hscryptoNick Mathewson2023-05-171-35/+16
| | | | | | Note that some of the invocations for this function seem to put the key and the message in a questionable order. But that's a thing to figure out later, while debugging.
* hs_ntor: Use correct PK types from tor_hscrypto.Nick Mathewson2023-05-171-20/+24
|
* hs_ntor: Use Subcredential type from tor-hscryptoNick Mathewson2023-05-171-4/+3
|
* Use non-deprecated *Secret::random_from_rng.Nick Mathewson2023-05-133-13/+13
| | | | The `new` function is deprecated in x25519-dalek 2.0.0-rc.2
* Rename onion-* cargo features to hs-* in tor-* cratesIan Jackson2023-02-281-1/+1
| | | | Fixes #756
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-273-0/+3
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* tor-proto: Expose support for doing onion service handshakesNick Mathewson2023-01-171-15/+15
| | | | | | This is a little tricky, but I think that we're not actually exposing too much here. I expect we'll need to tweak this stuff between now and our final version.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-122-0/+17
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* test lint blocks: Do some semi-manuallyIan Jackson2022-12-121-1/+9
| | | | | | | This is the hunks from running the rune in maint/adhoc-add-lint-blocks but which require some subsequent manual fixup: usually, deleting now-superfluous outer allows, but in some cases manually putting back lints that the adhoc script deleted.
* Fix a bunch of "needless borrow" warnings on nightlyNick Mathewson2022-11-181-2/+2
| | | | | It looks like, despite a few false starts, they've got this warning right; there weren't any false positives.
* tor-proto: Use correct SecretBuf in handshakes.Nick Mathewson2022-08-014-17/+27
| | | | | | | | Everything that is a secret encryption key, or an input that is used to produce a secret encryption key, has to get zeroized. And that's all! Closes #254.
* tor-proto: Replace SecretBytes with SecretBuf.Nick Mathewson2022-08-014-31/+34
| | | | | | | | | | This does not yet make sure that `SecretBuf` is used where it _should_ be, but at least it ensures that most uses of `SecretBytes` will indeed act as intended, and make sure that whatever they contain is zeroized. It requires some corresponding changes to method calls for correctness and type conformance.
* tor-proto: Stop using write_infallible in handshake code.Nick Mathewson2022-07-113-138/+174
| | | | | | | | This change was a bit annoying, since most of this code _can't_ fail, and so the only reasonable response is to wrap the input in an internal error... except for one case where we're actually encoding a caller-provided message, so we _do_ want to wrap the EncodeError from tor_bytes.
* Remove "write_and_consume_infallible".Nick Mathewson2022-07-111-7/+12
| | | | | | There were only a few of these. Removing it required porting everything to use `write_and_consume` instead, and handling its (potential) errors.
* Rename "write" methods on tor-bytes to "write_infallible".Nick Mathewson2022-07-113-112/+112
| | | | | | | | | | | | | | | This comprises four renames: ``` write_onto -> write_onto_infallible write_into -> write_into_infallible write -> write_infallible writer_and_consume -> write_and_consume_infallible. ``` The rest of this branch will be concerned with replacing these `_infallible` methods with ones that return a `Result`. This is part of #513.
* Implement a higher-level API for the ntor v3 handshakeeta2022-07-081-23/+162
| | | | | | | | | | | | | | | | | | | This implements a higher-level API for the ntor v3 handshake, in line with that exposed by the ntor handshake. It does not, however, use the existing `ClientHandshake` trait, due to fundamental differences in the handshakes (namely, that the v3 handshake can include some additional extra extension data). Currently, the higher-level API assumes circuit extension, and copies the (undocumented!) magic verification string from c-tor that indicates this usage. A rudimentary set of functions for serializing and deserializing extensions to be sent with the handshake is also included, implementing the protocol in proposal 332 § A.2. Currently, it only implements the congestion control extensions specified in proposal 324 § 10.3. part of arti#88
* Update `rsa` dependency (and use `x25519-dalek` prerelease)eta2022-07-061-6/+5
| | | | | | | | | | | | | | - arti#448 and arti!607 highlight an issue with upgrading `rsa`: namely, the `x25519-dalek` version previously used has a hard dependency on `zeroize` 1.3, which creates a dependency conflict. - However, `x25519-dalek` version `2.0.0-pre.1` relaxes this dependency. Reviewing the changelogs, it doesn't look like that version is substantially different from the current one at all, so it should be safe to use despite the "prerelease" tag. - The new `x25519-dalek` version also bumps `rand_core`, which means we don't have to use the RNG compat wrapper in `tor-llcrypto` as much. closes arti#448
* tor-proto: split and elaborate tor_bytes::Error instancesNick Mathewson2022-06-233-9/+28
| | | | | | | | | Some of these were for decoding particular objects (we now say what kind of objects), and some were unrelated tor_cert errors that for some reason we had shoved into a tor_bytes::Error. There is now a separate tor_cert::CertError type, independent from tor_cert's use of `tor_bytes::Error` for parsing errors.
* tor-proto: clean up error names and messagesNick Mathewson2022-06-234-9/+9
| | | | | This avoids adding additional information for now; that will come on the next commits.
* Use testing_rng() in tests throughout our crates.Nick Mathewson2022-06-024-6/+10
| | | | | | This only affects uses of thread_rng(), and affects them all more or less indiscriminately. One test does not work with ARTI_TEST_PRNG=deterministic; the next commit will fix it.
* Upgrade to AES 0.8Nick Mathewson2022-04-262-2/+2
| | | | | | | | Now that we require Rust 1.56, we can upgrade to AES 0.8. This forces us to have some slight API changes. We require cipher 0.4.1, not cipher 0.4.0, since 0.4.0 has compatibility issues with Rust 1.56.
* squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+0
| | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* tor-proto: Rename BadHandshake to BadCircHandshakeNick Mathewson2022-02-234-6/+6
| | | | (We'll have a BadChanHandshake soon.)
* Eliminate RequestedResourceAbsent kind.Nick Mathewson2022-02-223-16/+22
| | | | | | | | There was only one use of this, and it was in as-yet-unused relay-only code. Removing this type required refactoring the relay onion handshake code to use its own error type, which is probably clever anyway.
* tor-proto: use InternalError for internal errors.Nick Mathewson2022-02-151-3/+7
|
* prefer 'unwrap_or_default' to manual constructorDaniel Eades2022-01-011-1/+1
|
* Upgrade to digest v0.10.0Nick Mathewson2021-12-071-2/+2
| | | | | We generally try to track the latest rust-crypto traits when we can: fortunately, this upgrade didn't break much, considering.
* Resolve roughly half of the XXXXs.Nick Mathewson2021-12-062-4/+6
| | | | | | | | We want to only use TODO in the codebase for non-blockers, and open tickets for anything that is a bigger blocker than a TODO. These XXXXs seem like definite non-blockers to me. Part of arti#231.
* add constructorsdagon2021-11-301-17/+53
|
* Completely overhaul the tor-proto circuit reactoreta2021-11-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather like e8e9699c3c239d6c30f9ad414f15d3bad6ec03fd ("Get rid of tor-proto's ChannelImpl, and use the reactor more instead"), this admittedly rather large commit refactors the way circuits in `tor-proto` work, centralising all of the logic in one large nonblocking reactor which other things send messages into and out of, instead of having a bunch of `-Impl` types that are protected by mutexes. Congestion control becomes a lot simpler with this refactor, since the reactor can manage both stream- and circuit-level congestion control unilaterally without having to share this information with consumers, meaning we can get rid of some locks. The way streams work also changes, in order to facilitate better handling of backpressure / fairness between streams: each stream now has a set of channels to send and receive messages over, instead of sending relay cells directly onto the channel (now, the reactor pulls messages off each stream in each map, and tries to avoid doing so if it won't be able to forward them yet). Additionally, a lot of "close this circuit / stream" messages aren't required any more, since that state is simply indicated by one end of a channel going away. This should make cleanup a lot less brittle. Getting all of this to work involved writing a fair deal of intricate nonblocking code in Reactor::run_once that tries very hard to be mindful of making backpressure work correctly (and congestion control); the old code could get away with having tasks .await on things, but the new reactor can't really do this (as it'd lock the reactor up), so has to do everything in a nonblocking manner.
* Remove some dbg!() calls in real code.Nick Mathewson2021-11-021-2/+0
|
* Update our disclaimers and limitations sections.Nick Mathewson2021-10-271-5/+0
|
* Use subtle and some refactoring to remove branches in ntorNick Mathewson2021-10-012-21/+46
| | | | Closes #163
* Typo fixesNick Mathewson2021-09-091-2/+2
|
* Fix clippy warnings in tests with --all-featuresNick Mathewson2021-09-082-10/+9
|
* fix/silence clippy lints in test modulesDaniel Eades2021-09-082-1/+3
|
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-274-0/+1795
This will cause some pain for now, but now is really the best time to do this kind of thing.