Commit Graph

4104 Commits

Author SHA1 Message Date
Ian Jackson 5ba7f31c1d tor-hsclient: Mockable: Do concrete calls with UFCS
Method dispatch rules mean that if the receiver type of the actual
function changes, `self.call()` can turn into a purely-recursive call
which overflows the stack.

Async Rust doesn't have the usual warning for this situation :-(.

UFCS is clumsier but doesn't have that problem because it involves
much less magical dispatch.  Instead of generating a recursive call
which overflows the stack, it fails to compile.
2023-05-23 12:47:33 +01:00
Ian Jackson 79b9a26df0 tor-hsclient: Fix MockableClientCirc for ClientCirc changes
ClientCirc::begin_dir_stream now takes Arc<Self>.  Method resolution
rules mean that this code would just recurse, leading to a stack
overflow.
2023-05-23 12:47:33 +01:00
Ian Jackson 1fc1c269c3 Fix a docs reference to refer to HsClientIntroAuthKeypair
Fixes warning from
  cargo -o doc --document-private-items --all-features --workspace

This was evidentlhy overlooked during recent replacement of unescorted
private keys in the code.
2023-05-22 14:30:16 +01:00
Nick Mathewson 9848155f59 Upgrade notify dependency to 6.0 2023-05-22 07:54:10 -04:00
Nick Mathewson a179d10ad4 Upgrade async-compression dependency to 0.4.0. 2023-05-22 07:52:18 -04:00
Nick Mathewson 16c992ecd3 Upgrade memmap2 dependency to 0.6.1. 2023-05-22 07:51:22 -04:00
Nick Mathewson 512455da96 Upgrade serde_with dependency to 3.0.0 2023-05-22 07:49:58 -04:00
Nick Mathewson df9ff46b80 tor-rtcompat: Say default-features with a dash, not an underscore.
(`cargo-upgrade` warns about this.)
2023-05-22 07:49:28 -04:00
Ian Jackson 26af92ca10 Merge branch 'clippy-nightly' into 'main'
Fix a few warnings from clippy nightly

See merge request tpo/core/arti!1193
2023-05-22 10:49:10 +00:00
Nick Mathewson 4b9d6b255e Merge branch 'escorted_25519_secrets' into 'main'
Refactor code not to use unescorted ed25519 secrets

Closes #798

See merge request tpo/core/arti!1192
2023-05-18 18:48:05 +00:00
Nick Mathewson 9773633a84 hscrypto: Remove an incorrect comment.
(It said that we want to deprecate all unescorted secret keys; in
fact, only unescorted EdDSA secrets are bad.)
2023-05-18 14:18:53 -04:00
Nick Mathewson 82801d9963 netdoc, hsclient: Update remaining ed25519::SecretKey users
Fortunately, these are all in experimental code.

Closes #798
2023-05-18 14:18:53 -04:00
Nick Mathewson 66c06ecc9c hscrypto: Replace ed25519 secret keys with keypairs
Part of #798: We no longer use unescorted ed25519 secret keys.
2023-05-18 14:18:53 -04:00
Nick Mathewson f333c9029a Merge branch 'virtual_hop' into 'main'
tor-proto: Add support for extending circuits through virtual hops.

Closes #726

See merge request tpo/core/arti!1191
2023-05-18 17:14:01 +00:00
Nick Mathewson e8e40e66f6 chanmgr: fix a unit-default warning from clippy nightly.
I could also have stopped using `::default()` to construct this
(testing-only) object, but I think it makes more sense to turn it
into a non-unit object.
2023-05-18 12:57:57 -04:00
Nick Mathewson 41863bd622 guardmgr, netdir: fix some needless-mut warnings
Found by clippy nightly
2023-05-18 12:54:55 -04:00
Nick Mathewson 45571b3ec7 guardmgr: suppress a clippy-nightly warning.
I don't love this change, but apparently we are trying for
"consistency".
2023-05-18 12:52:19 -04:00
Nick Mathewson 6f80caed9d proto: Explain "virtual" hops better.
Based on text from @diziet
2023-05-18 12:40:02 -04:00
Nick Mathewson 0230e7bccc proto: Try to improve the documentation in crypto/cell.rs 2023-05-18 12:40:02 -04:00
Nick Mathewson 3b7a20ef4c proto: Allow circuit Paths to represent virtual hops.
Sadly, this adds a few more `TODO HS` entries, but I think we can
clean them up later after a bit of discussion.
2023-05-18 12:40:02 -04:00
Nick Mathewson 663f25d44c proto: Implement Circuit::extend_virtual.
There are a few new TODO hs comments, though, and an XXXX I'll need
to fix up in the next commit.

Implements #726.
2023-05-18 12:40:02 -04:00
Nick Mathewson b9a848a7ac tor-proto: Code to construct crypto layers for virtual hops.
This is fairly straightforward, thanks to our existing design work
on this code.
2023-05-18 12:40:02 -04:00
eta 4665835ee8 tor-guardmgr, tor-proto: minor logging tweaks
- We make the tor-guardmgr "We have found that {} is usable" line
  include the word "guard", otherwise it doesn't appear very useful to a
  user in safe logging mode, since the guard gets replaced with
  [scrubbed].
- The "Actually got an end cell..." message is downgraded to DEBUG.
2023-05-18 16:04:11 +01:00
Nick Mathewson dcec7ca2dc llcrypto: Don't take or return "unescorted" ed25519 keys.
Per #798, we want to make sure that we never pass around an
`ed25519::SecretKey`; only an `ed25519::Keypair` (or
`ExpandedKeypair`).  This is because, when you're computing an
ed25519 signature, you have to use the public key as one of your
inputs, and if you ever use a mismatched public key you are
vulnerable to a nonce reuse attack.

(For more info see
https://moderncrypto.org/mail-archive/curves/2020/001012.html )
2023-05-18 11:00:43 -04:00
Nick Mathewson 2ffb200a77 llcrypto: Add an `ed25519::ExpandedKeypair` type.
This is like an `ed25519::Keypair`, except that instead of a
`SecretKey` it contains an `ExpandedSecretKey`.

We'll be using this to implement #798, where we impose a rule that
there must be no "unescorted" ed25519 secret keys.
2023-05-18 10:56:43 -04:00
Nick Mathewson a8b6f19552 Merge branch 'hs_handshake' into 'main'
Clean up hs_ntor.rs, add test vectors generated by C tor, and fix some bugs

Closes #865

See merge request tpo/core/arti!1189
2023-05-18 13:25:07 +00:00
Nick Mathewson 07e2ed0e5c cell: Make Introduce2::new testing-only.
We never want to create one of these from its parts except when we
are testing it; we only want to forward an Introduce1 message with a
new command on it.
2023-05-17 16:22:35 -04:00
Nick Mathewson c3c44cea67 cell: Record the text of an INTRODUCE2 header
We'll need to store this so that it can later on be used to complete
the hs_ntor handshake.
2023-05-17 16:22:35 -04:00
Nick Mathewson d008c385d5 hs_ntor: several documentation cleanups. 2023-05-17 16:18:55 -04:00
Nick Mathewson 954b41dcf1 hs_ntor: make encrypt_and_mac take a typed public key
This is still not the most beautiful interface, but it'll do for now.
2023-05-17 16:18:55 -04:00
Nick Mathewson 50ce084d64 hs_ntor: remove the last lingering AsRef<[u8]> 2023-05-17 16:18:55 -04:00
Nick Mathewson a6fd8fb347 hs_ntor: Add a test vector case extracted from C tor. 2023-05-17 16:18:55 -04:00
Nick Mathewson 20d6c4b247 hs_ntor: Calculate MAC on introduce1 message correctly.
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.
2023-05-17 16:18:55 -04:00
Nick Mathewson 1f665d1144 hs_ntor: Make internal no-rng variants of the handshake functions.
We'll want these so we can implement some test vectors.
2023-05-17 16:18:55 -04:00
Nick Mathewson ceaeb61168 hs_ntor: Move extra data outside of the "input" fields.
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.
2023-05-17 16:18:55 -04:00
Nick Mathewson 54665c2b65 hs_ntor: Use MAC implementation from tor-hscrypto
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.
2023-05-17 16:18:55 -04:00
Nick Mathewson c8ad9450c2 hs_ntor: Use correct PK types from tor_hscrypto. 2023-05-17 16:18:55 -04:00
Nick Mathewson 9d5dd813c0 hs_ntor: Use Subcredential type from tor-hscrypto 2023-05-17 16:18:55 -04:00
Nick Mathewson a6ad49b22b cell: extract introduce headers into a new type.
We'll want this because our hs_ntor handshake requires access to an
encoded version of the header independent from the actual encrypted
message.

part of #866.
2023-05-17 11:06:28 -04:00
gabi-250 ac0eb05a07 Merge branch 'info-to-warn' into 'main'
Change log levels of messages from INFO to others

Closes #854

See merge request tpo/core/arti!1172
2023-05-17 12:41:26 +00:00
Saksham Mittal e9dff1c0d7
Change log level to debug and warn for certain appropriate situations
This commit changes certain log messages to debug for recoverable errors
and a warn if all such attempts fail, in order to not clutter up the
info messages that end users get to see.
2023-05-17 17:28:22 +05:30
gabi-250 fb8bc19b9b Merge branch 'arc_circ' into 'main'
Refactor ClientCirc APIs to use Arc<ClientCirc>.

Closes #846

See merge request tpo/core/arti!1187
2023-05-17 09:47:19 +00:00
Nick Mathewson b84f122aab Merge branch 'ticket_759' into 'main'
tor-cert: Replace the KeyUnknownCert::check_key API

Closes #759

See merge request tpo/core/arti!1184
2023-05-16 22:23:17 +00:00
Nick Mathewson dfa19998e2 Merge branch 'resolve_relay' into 'main'
netdir: New function to check consistency of a HasRelayIds

Closes #855

See merge request tpo/core/arti!1186
2023-05-16 22:12:29 +00:00
Nick Mathewson 9d54c7973b Deprecate check_key, and refactor its logic into the new functions.
Closes #759
2023-05-16 17:53:15 -04:00
Nick Mathewson 56c6e4345b Replace usage of KeyUnknownCert::check_key. 2023-05-16 17:53:15 -04:00
Nick Mathewson eb356323bd tor-cert: Add new functions to replace KeyUnknownCert::check_key.
These should have a cleaner API than check_key, and be easier to
understand.

Part of #759
2023-05-16 17:53:15 -04:00
Nick Mathewson 4a779807e8 netdir: New function to check consistency of a HasRelayIds
This function will be used to look up a relay by a set of LinkSpecs
given from an incoming HsDesc or INTRODUCE2 message.  It differs
from other "lookup relay by IDs" functions in that it needs to be
able to return "here's a relay", "couldn't found a relay", or
"learned that this relay is impossible."

Closes #855: This is the only new API needed for ChanTarget
validation, I think.
2023-05-16 17:45:21 -04:00
Nick Mathewson ef3c049064 Merge branch 'rpc-objectmap' into 'main'
RPC: revise semantics for weak references and object IDs

Closes #848

See merge request tpo/core/arti!1183
2023-05-16 13:30:42 +00:00
Nick Mathewson 1ed2da523a rpc: Split the generational index into two.
This lets us simplify our logic a bit for strong references.
2023-05-16 09:08:25 -04:00