Commit Graph

6866 Commits

Author SHA1 Message Date
Nick Mathewson 1c470fd483 circmgr: Remove TODOS about retrying.
These functions' documentation already says that they don't retry,
and hsclient appears to be where we are concentrating our retry
efforts.
2023-06-16 11:40:00 -04:00
Nick Mathewson 672062113e cirmgr: remove a dead-code exception. 2023-06-16 08:45:49 -04:00
Nick Mathewson 5196363d36 Merge branch 'insert' into 'main'
rpc: Make CastTable::insert be more type-safe

See merge request tpo/core/arti!1253
2023-06-16 12:20:14 +00:00
gabi-250 642f3fc209 Merge branch 'arti-keystore' into 'main'
tor-keymgr: Initial implementation

See merge request tpo/core/arti!1223
2023-06-15 18:30:46 +00:00
Gabriela Moldovan 37e0837cea arti-client: rustfmt 2023-06-15 18:56:48 +01:00
Gabriela Moldovan 94b228a4c6 arti-client: Fix clippy lints.
We need to allow some lints in the dummy key manager because its
implementation needs to mirror that of `tor_keymgr::KeyMgr` (so we can't
apply the API changes suggested by clippy).
2023-06-15 18:43:24 +01:00
Gabriela Moldovan ec9200c50f keymgr: Add Diziet's notes about storing public keys in the key store. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan bed1ae6304 arti-client: Use a dummy key manager if the keymgr feature is disabled.
TorClient now only uses the tor_keymgr::KeyMgr implementation if the
keymgr experimental feature is enabled. If the feature is disabled, a
dummy key manager implementation is used.

The new `keymgr` feature depends on `onion-client`, because the key
manager is only used for HS client auth.
2023-06-15 18:16:34 +01:00
Gabriela Moldovan 35879a681f arti-client: Implement From<tor_keymgr::Error> for Error. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 21d93300eb keymgr, arti-client: KeyMgr should return Ok(None) if the key is not found.
This simplifies usage quite a bit and will enable us to implement a
dummy `KeyMgr`  that doesn't depend on the error types from tor-keymgr
(which will replace the "real" `KeyMgr` if the keymgr feature is
disabled).
2023-06-15 18:16:34 +01:00
Gabriela Moldovan 60e2b51f3d keymgr: Add TODO regarding KeyStore rename. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 0525193d99 keymgr: Add TODO about KeyType refactorings. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 97ba27aedb keymgr: Add the key type to the `arti_extension`. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan a958b3a91a arti_client: Add TODO about refactoring code around HsClientSecretKeysBuilder. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 15122a8e10 keymgr: Add TODO regarding some error refactorings. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan eda974cd34 keymgr: Move the HS client and service key specifiers out of tor-keymgr.
The HS `HsClientSpecifier` and `HsClientSecretKeySpecifier` are moved to
`tor-hsclient`. The HS service secret key specifier stubs are moved to
`tor-hsservice`.
2023-06-15 18:16:33 +01:00
Gabriela Moldovan 0828597a2e keymgr: Expand the TODOs regarding HS service key specifiers.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-06-15 18:15:30 +01:00
Gabriela Moldovan e0ded457ba keymgr: Expand HsClientSpecifier docs, add TODO about refactoring.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-06-15 18:15:30 +01:00
Gabriela Moldovan e99ee7ec02 arti-client, keymgr: Initialize KeyMgr with an ArtiNativeKeyStore.
The `KeyMgr` is now initialized with an `ArtiNativeKeyStore` built from
an invalid key store root dir (this is alright for the purposes of this
proof-of-concept, since `ArtiNativeKeyStore::new` won't fail as it
doesn't currently validate the keystore root dir).
2023-06-15 18:15:30 +01:00
Gabriela Moldovan 64c24dca66 keymgr: Introduce ToEncodableKey to simplify lookups.
This means `KeyMgr` users don't need to specify the underlying key type
(e.g. `ed25519::Keypair`) when retrieving keys. Instead, they can just
specify the type required (as long as it implements `ToEncodableKey`),
e.g. `HsClientIntroAuthKeypair`.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan fbed393680 arti-client: Make the client use the KeyMgr.
`TorClient` now uses a `KeyMgr` to retrieve the `HsClientSecretKeys`
client auth keys passed to `get_or_launch_connection`.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan 61f37b1b5c keymgr: Add key manager implementation stub. 2023-06-15 18:15:30 +01:00
Gabriela Moldovan 17ae752a0b keymgr: Implement `SshKeyType::read_ssh_format_erased` for `KeyType`.
This adds a proof-of-concept `SshKeyType::read_ssh_format_erased`
implementation for `KeyType`. The implementation decodes an OpenSSH key
and converts it to one of the key types used internally by Arti. The
value returned is type-erased, and will be downscast later down the line
by the `KeyMgr` (note: `KeyMgr` doesn't exist yet).

The `SshKeyType::write_ssh_format` will be implemented once these APIs
are a bit more stable.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan a2d0ee63cc keymgr: Add ArtiNativeKeyStore implementation skeleton.
This adds implementation stubs for `ArtiNativeKeyStore`, and introduces
the traits needed to make the `KeyStore` APIs work.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan d133c8b0a6 hsclient: Change builder error return type to ConfigBuildError.
It's not perfectly clear what this error type should be, so let's use
`ConfigBuildError` for now (it makes things easier in `arti-client`, as
we already have an `ErrorDetail` for it).
2023-06-15 18:15:30 +01:00
Ian Jackson aa8bf740db Merge branch 'hs' into 'main'
Store our IPT experiences and try to try good IPTs first

See merge request tpo/core/arti!1247
2023-06-15 16:18:06 +00:00
Ian Jackson a1934e7102 tor-hsclient: Make Untried a {}-less unit
Suggested here
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1247#note_2912642

It's unlikely this will grow any content, so fine.
2023-06-15 16:43:45 +01:00
gabi-250 7e601fba01 tor-hsclient: Insert a blank line 2023-06-15 16:43:45 +01:00
gabi-250 d99434d06b tor-hsclient: Docs improvements. 2023-06-15 16:43:45 +01:00
Ian Jackson 856269f7a7 tor-hsclient: Remove two done TODOs 2023-06-15 16:43:45 +01:00
Ian Jackson 731cc9ed44 tor-hsclient: provide intro_index accessor for FailedAttemptError (xref)
Add a cross-reference to docs arising from MR comments in !1246.
2023-06-15 16:43:45 +01:00
Ian Jackson 2dfa00f379 tor-hsclient: Actually store our IPT experiences 2023-06-15 16:43:45 +01:00
Ian Jackson f5a895b33f tor-hsclient: intro_rend_connect: bind `outcome`
This will be used in a moment.
2023-06-15 16:43:45 +01:00
Ian Jackson 4f4f753b6a tor-hsclient: Actually choose which intro points to use
Right now this just always chooses randomly because nothing stores
anything in the HashMap.
2023-06-15 16:43:45 +01:00
Ian Jackson 65d7d499d7 tor-hsclient: Introduce RelayIdForExperience
Wrap this up in a newtype so we don't accidentally use it for anything
else.  Provide two constructors, one for storing and one for lookups.
2023-06-15 16:43:45 +01:00
Ian Jackson 397c4fb01f tor-hsclient: Add random sort key to UsableIpt 2023-06-15 16:43:45 +01:00
Ian Jackson 279afeefc2 tor-hsclient: provide intro_index accessor for FailedAttemptError 2023-06-15 16:43:45 +01:00
Ian Jackson dac7a45ea8 tor-error: Introduce `LooseCmpRetryTime`
Having a newtype for this kind of thing is considerably more
convenient.  I'm going to use this in a moment.
2023-06-15 16:43:45 +01:00
Ian Jackson 1710ce54f4 rpc: Remove some verbiage about 'static, and demo that it's OK without
It's now not actually possible to write code that doesn't work, even
if `Tr` *isn't* 'static, because of the bounds on `CastTable::insert`.

I tried to produce a non-working setup with a non-static `Simple`, but
you can't implement `Object` for such a thing.  Removing 'static from
Object would stop the downcasts from Any to Object working.

Prior to the new typesafe insert, this change
  - let f: fn(&dyn $crate::Object) -> &(dyn $traitname + 'static) = |self_| {
  + let f: fn(&dyn $crate::Object) -> &(dyn $traitname) = |self_| {
would result in a runtime crash.  Now it results in a compiler error.
2023-06-15 12:07:11 +01:00
Ian Jackson 0eedf0e254 rpc: Give the name `O` to "the type associated with this CastTable"
This was locally bound to `S` in one place.  Bind and use it throughout.
Since this is an RPC object, `O` is a better name.

In each item, use the description once and thereafter just the name.
2023-06-15 12:03:53 +01:00
Ian Jackson 2228751a00 rpc: Add Simple test case for CastTable 2023-06-15 12:03:53 +01:00
Ian Jackson 54b364cdcf rpc: Move boxing from macro to CastTable::insert (formatting) 2023-06-15 12:03:53 +01:00
Ian Jackson 890a7b52be rpc: Move boxing from macro to CastTable::insert 2023-06-15 11:32:32 +01:00
Ian Jackson 8452fe11cf rpc: Make CastTable::insert be more type-safe
This checks the Requirements.
2023-06-15 11:13:26 +01:00
Nick Mathewson 84d9bd1d6a Merge branch 'ci' into 'main'
CI: Upgrade every-crate test to required

See merge request tpo/core/arti!1252
2023-06-14 19:19:22 +00:00
Ian Jackson bca999790f CI: Upgrade every-crate test to required
Since it passes now.
2023-06-14 19:49:13 +01:00
Nick Mathewson d66ff621be Merge branch 'ci2' into 'main'
Test every crate with default features

See merge request tpo/core/arti!1250
2023-06-14 18:23:45 +00:00
Ian Jackson a156e60780 Merge branch 'pt-snowflake-fix' into 'main'
make snowflake example feature-gated

See merge request tpo/core/arti!1249
2023-06-14 18:13:57 +00:00
trinity-1686a 02a82ad748 make snowflake example feature-gated 2023-06-14 18:13:57 +00:00
Ian Jackson eeaae5a3bf CI: test every crate with default features 2023-06-14 18:47:51 +01:00