Commit Graph

4563 Commits

Author SHA1 Message Date
Nick Mathewson dd944bc787 Generate correct ErrorKinds for hsdesc decryption failures.
Part of #736
2023-06-21 10:22:42 -04:00
Gabriela Moldovan 523eb7e5f0 keymgr: Remove outdated TODO.
This TODO describes something we're not planning to implement, so let's
just remove it.
2023-06-21 14:55:13 +01:00
Gabriela Moldovan 521ba309cc keymgr: Remove unnecessary condition.
We don't need to special-case `NotFound` errors because
`ssh_key::PrivateKey::from_openssh` doesn't read from disk (so it
shouldn't be returning `NotFound` errors in the first place).

Previously, this condition made sense because we were using
`ssh_key::PrivateKey::read_openssh_file` instead of
`ssh_key::PrivateKey::from_openssh`, which _does_ read from disk. This
condition should have been removed in !1263 (the refactoring where we
switched to `from_openssh`).

(Also, after #901 is implemented, we probably won't have an
`Error::NotFound` error anymore).
2023-06-21 14:42:42 +01:00
Nick Mathewson a7627341ec Merge branch 'onionsocks' into 'main'
arti: return prop304 extended socks5 reply codes for onion services

See merge request tpo/core/arti!1248
2023-06-21 13:38:42 +00:00
Nick Mathewson 16a07a8f63 Upgrade to memmap2 0.7 2023-06-21 09:13:55 -04:00
Nick Mathewson 0505579497 Upgrade to strum 0.25. 2023-06-21 09:12:36 -04:00
Saksham Mittal 056ca5c438
Remove extra 'this' in some methods 2023-06-21 18:40:18 +05:30
Saksham Mittal 341cf5c690
Create chanmgr() method in TorClient 2023-06-21 18:34:24 +05:30
Nick Mathewson 2d7756956e Add and use ErrorKinds for remaining onion service errors 2023-06-21 09:01:02 -04:00
Nick Mathewson 36c4112600 arti: return prop304 extended socks5 reply codes for onion services
We don't yet return all of them; this commit adds some todo notes
about changes we may need to our ErrorKinds.

Part of #736
2023-06-21 09:01:01 -04:00
Nick Mathewson fbb3d98fb3 arti: Abbreviate SocksStatus and ErrorKind imports and refactor. 2023-06-21 09:00:03 -04:00
Nick Mathewson f14a87e4c8 Merge branch 'todos' into 'main'
tor-hsclient: Dispose of easy todos and remove many allows

See merge request tpo/core/arti!1272
2023-06-21 12:53:16 +00:00
Nick Mathewson 372a72e185 Fix a rustdoc link. 2023-06-21 08:45:25 -04:00
Nick Mathewson 21ff8e8060 Merge branch 'chanmgr-doc-fix' into 'main'
Remove message 'For now, only direct channels are supported' in tor-chanmgr docs

See merge request tpo/core/arti!1273
2023-06-21 12:35:46 +00:00
Nick Mathewson 107fbb05de Merge branch 'geoip-nullity-fromstr' into 'main'
Followups wrt country-code robustness

See merge request tpo/core/arti!1268
2023-06-21 12:32:23 +00:00
Saksham Mittal c3384df00f
Remove message 'For now, only direct channels are supported' in tor-chanmgr docs 2023-06-21 17:29:11 +05:30
Ian Jackson 9a05fbb10d tor-hsclient: Apply deferred clippy churn needed by fmt churn
rustfmt *introduced* this clippy warning.
2023-06-21 12:54:57 +01:00
Ian Jackson fe41d2059e tor-hsclient: Apply deferred rustfmt churn 2023-06-21 12:19:04 +01:00
Ian Jackson 60fc4ef98a tor-hsclient: Drop most allows that are marked for removal 2023-06-21 12:19:04 +01:00
Ian Jackson a57d3067a5 tor-hsclient: Drop a large number of unneeded imports 2023-06-21 12:19:04 +01:00
Ian Jackson ae1f144829 tor-hsclient: Add HSID to some log messages
For the debug!, we can use the unredacted form.  For error!, we use
Sensitive.
2023-06-21 12:19:04 +01:00
Ian Jackson d4b7714926 tor-hsclient: Do Debug the descriptor as part of Data
Empirically, this does not cause the descriptor to be spat out in
normal operation.  And it seems right.
2023-06-21 12:19:04 +01:00
Ian Jackson c94a726664 tor-hsclient: Drop some temporary trace calls
These were added as part of a debugging #885, and are no longer
needed.
2023-06-21 12:19:04 +01:00
Ian Jackson 8267fb4535 tor-hsclient: Drop two eprintlns in production code 2023-06-21 12:19:04 +01:00
Ian Jackson 0845694021 tor-hsclinet: Promote dead code allows to cover all tests
We want to remove the crate-level dead code allows.  The tests are
incomplete and there are multiple todos for that.
2023-06-21 12:19:04 +01:00
Ian Jackson 63ab6fb01c tor-hsclient: Use a formulaic TODO mark for incompleteness of tests 2023-06-21 12:19:04 +01:00
Ian Jackson 5a7ea7067d tor-hsclinet: Add a narrow allow, pending answer to open question
I need to talk to HS expert(s) about when this circuit can be
torn down.
2023-06-21 12:19:04 +01:00
Ian Jackson 9a30c4afce tor-hsclient: Remove unused Context.hs_blind_id_key 2023-06-21 12:19:04 +01:00
Ian Jackson 8f90fe619e tor-hsclient: Add an allow for a deliberately-unused variable 2023-06-21 12:19:04 +01:00
Ian Jackson be3433891f tor-hsclient: Omit some unussed struct fields in patterns
For the arms that have a fixed retry time, or a fixed ErrorKind,
dont't bind the unused inner error.
2023-06-21 12:19:04 +01:00
Ian Jackson 161b9844da lints: Run maint/add_warning to actually apply new lints 2023-06-21 12:15:41 +01:00
Nick Mathewson 8676b27e95 geoip: Add a few more tests. 2023-06-20 16:22:21 -04:00
Nick Mathewson b0342a8ede geoip: Explain in more detail what a CountryCode is to us. 2023-06-20 16:22:21 -04:00
Nick Mathewson f918a86c10 geoip: require that ccs actually are printable ascii.
(There are plenty of strings that convert into 2 bytes of UTF8
without being two ascii characters, and there are plenty of
sequences of two ascii characters that aren't printable.)
2023-06-20 16:22:21 -04:00
Nick Mathewson cf9d902320 geoip: Make ?? a little more bullet-proof
We want to make sure that ?? is always None, never a CountryCode.
2023-06-20 16:22:21 -04:00
gabi-250 db7f46265e Merge branch 'keymgr-refactor-fs-ops' into 'main'
keymgr: Move FS operations out of KeyType impl

See merge request tpo/core/arti!1263
2023-06-20 18:41:33 +00:00
Nick Mathewson f41b1178c5 netdoc: downgrade two accessor-related TODOs 2023-06-20 14:02:04 -04:00
Nick Mathewson 17fab6e913 netdoc: Use derive amplify::Getters for HsDesc accessors.
Closes #909.
2023-06-20 14:00:41 -04:00
Nick Mathewson 8d4ca94e19 Merge branch 'add-tor-geoip' into 'main'
tor-geoip: Add new crate with GeoIP database functionality

See merge request tpo/core/arti!1239
2023-06-20 17:59:15 +00:00
Gabriela Moldovan c40e064b42 keymgr: Fix clippy lints. 2023-06-20 18:54:35 +01:00
Gabriela Moldovan 97350cfe4b keymgr: Address clippy lints and run cargo fmt. 2023-06-20 18:54:35 +01:00
Gabriela Moldovan 2f10b08d41 keymgr: Enforce keystore_dir properties for every key read/written from the keystore. 2023-06-20 18:54:35 +01:00
Gabriela Moldovan 9bfd263f42 keymgr: Update function names and docs to reflect reality.
The functions that handle OpenSSH-formatted keys now no longer read or
write from disk. This commit updates their names and doc strings to stop
suggesting they do.
2023-06-20 18:54:35 +01:00
Gabriela Moldovan abdf854547 keymgr: Move FS operations out of ssh.rs
This moves the filesystem calls from the `ssh` module to
`ArtiNativeKeyStore`. While `ArtiNativeKeyStore` shouldn't be concerning
itself with filesystem operations either, that refactoring will be
tackled separately (see arti#899).
2023-06-20 18:54:35 +01:00
Nick Mathewson a812a486c3 Downgrade every "TODO HS" in tor-hsservice
These are all service-specific, and not client-specific.
2023-06-20 13:30:56 -04:00
eta d5632eacb2 tor-geoip: Add new crate with GeoIP database functionality
- This adds a new crate, `tor-geoip`, which can parse and perform
  lookups in the GeoIP database C-tor already uses (generated by a
  maintenance utility in the C-tor codebase).
- We embed a copy of C-tor's databases with the crate and use
  `include_str!` to ship them with the binary, bloating its size
  somewhat.
  - This does, however, solve the problem of figuring out how to
    distribute these.
  - The plan is to gate this functionality behind a feature flag anyway,
    so the cost should be nil unless explicitly opted into.

Part of tpo/core/onionmasq#47.
2023-06-20 16:57:58 +01:00
Gabriela Moldovan 181638333f keymgr: Create a temporary error type for the key types we don't support yet. 2023-06-20 16:48:36 +01:00
Gabriela Moldovan 0c7e5d1924 keymgr: Create a separate error source for key corruption errors. 2023-06-20 16:48:36 +01:00
Alexander Færøy 2fa8a4e56c Merge branch 'update-keymgr-todo' into 'main'
keymgr: Change "TODO hs" to "TODO HSS".

See merge request tpo/core/arti!1264
2023-06-20 13:42:28 +00:00
Gabriela Moldovan c0762f76f1 keymgr: Fix broken docs. 2023-06-20 13:34:32 +01:00
Gabriela Moldovan 84e05591c7 arti-client: Remove unnecessary #[cfgs(...)].
The `keymgr` module selects one of the key manager implementations
(dummy or "real") and exposes all the APIs we need, so we can remove
all of the cfgs related to the `keymgr` feature from `client.rs`.

Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 733a559322 arti-client: Create module exposing one of the key manager APIs.
This moves the key manager API selection (dummy vs "real" impl) into the
`keymgr` module. The module exports the dummy API if the `keymgr`
feature is disabled, and the impl from `tor-keymgr` otherwise.

Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 8202be3cfe arti-client: Make some of the dummy KeyMgr impls return an error.
`insert` and `remove` should return an error rather than `Ok(())`, as
`Ok(())` implies the key was stored/removed, which is impossible in the
no-op implementation.
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 02c36dabd7 arti-client: Add more dummy keymgr APIs.
This will help us reduce the number of `#[cfgs(...)]` from `client.rs`

Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan c7d32dbf4c arti-client: Add a result type for the dummy keymgr impl.
Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan b289c0fd15 arti-client: Add an Error type for the dummy key manager.
Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 95e4021ed8 arti-client, keymgr: Introduce Mistrust settings and enforce FS permissions. 2023-06-20 13:29:10 +01:00
Gabriela Moldovan be5c911ac8 arti-client: Temporarily ignore key store errors.
We currently initialize the `ArtiNativeKeyStore` with a dummy root dir,
so when `ArtiNativeKeyStore` starts validating directories, this code
will start to fail. Let's preemptively ignore any errors coming from
`ArtiNativeKeyStore::new`. This is temporary and will be removed when we
introduce the key store config (and a real default value for the
keystore root dir).
2023-06-20 13:29:10 +01:00
Gabriela Moldovan e8176ac8b5 keymgr: Add TODO about separation of concerns wrt FS operations. 2023-06-20 13:29:10 +01:00
Gabriela Moldovan 6837dbce58 keymgr: Add an error variant for fs_mistrust errors.
This will be useful later, when `KeyMgr` will start validating
permissions and paths.
2023-06-20 13:29:10 +01:00
Gabriela Moldovan 01b43f7f26 keymgr: Add a FsErrorSource to Error::Fs.
In the future, the potential causes of an `Error::Filesystem` error will
include permission errors as well as other errors (not just
`io::Error`s).
2023-06-20 13:29:10 +01:00
Nick Mathewson f24a7d48c0 Merge branch 'circmgr-todos' into 'main'
Resolve several "TODO HS" comments in circmgr.

See merge request tpo/core/arti!1258
2023-06-20 12:13:24 +00:00
Ian Jackson affa5b5e91 Merge branch 'rpcdoc' into 'main'
rpc: Minor docs improvements

See merge request tpo/core/arti!1260
2023-06-20 12:11:49 +00:00
gabi-250 602bcc3c47 Typo fixes 2023-06-20 11:47:02 +00:00
Nick Mathewson 3e704a080c rpc: Fix docs typo 2023-06-20 11:38:31 +00:00
Gabriela Moldovan fed726e4ff keymgr: Defer key bundle support until "Basic Service" milestone.
We don't really need "key bundles" for the client keys.
2023-06-20 11:36:04 +01:00
Gabriela Moldovan 0bb7c7f600 keymgr: Change "TODO hs" to "TODO HSS".
We probably don't need to support passphrases for the "Basic Client"
milestone, so let's update this TODO accordingly.
2023-06-20 11:24:03 +01:00
Alexander Færøy f55187e065 Merge branch 'arti-client' into 'main'
Sort out .onion handling in arti-client

See merge request tpo/core/arti!1257
2023-06-19 14:44:55 +00:00
Nick Mathewson c7fa6cb746 Merge branch 'rpc_session_mgt' into 'main'
More work on RPC sessions, connections, and managers

See merge request tpo/core/arti!1254
2023-06-16 18:08:58 +00:00
Nick Mathewson b9500c6f3d Merge branch 'netdoc-todos' into 'main'
Resolve many TODO HS items in tor-netdoc

See merge request tpo/core/arti!1251
2023-06-16 17:31:31 +00:00
Nick Mathewson a34af0323b Fix compilation afver last suggestion. 2023-06-16 13:24:41 -04:00
Ian Jackson 0e3dbdee8e Apply 1 suggestion(s) to 1 file(s) 2023-06-16 17:07:25 +00:00
Ian Jackson 85a046e266 rpc: Cross-reference up from tor-rpcbase re where DispatchTable lives 2023-06-16 17:48:59 +01:00
Ian Jackson ceaa70f41a rpc: Expand and clarify and cross-reference lock hierarchy 2023-06-16 17:48:59 +01:00
Ian Jackson 0460a4a4d8 rpc: Document relationship between `Connection` and `RpcSession` 2023-06-16 17:48:59 +01:00
Nick Mathewson 34fc77081c hsdesc.rs: finally remove "allows".
The last piece here is removing some needless keygen from the
tests.  This causes the test output (using the deterministic PRNG)
to change.
2023-06-16 12:24:05 -04:00
Nick Mathewson 1091918525 netdoc::doc::hsdesc changes to let us downgrade/remove allows 2023-06-16 12:24:05 -04:00
Nick Mathewson f1b90fdfee netdoc: unmark MAC_KEY_LEN as conjectural.
The value here is 32 bytes; I'm adding it to to the specification
as torspec!141
2023-06-16 12:24:05 -04:00
Nick Mathewson d8f7ce510c SharedRandVal: Note that it doesn't have to be Ct. 2023-06-16 12:24:05 -04:00
Nick Mathewson 984d97a38d netdoc: remove a TODO about moving a module to where it already is. 2023-06-16 12:24:05 -04:00
Nick Mathewson 6edcca7df3 netdoc: use ct_lookup for rend descriptor cookie lookup
(I doubt that there is a viable side channel here, but still we
might as well get in the habit of doing these things properly.)
2023-06-16 12:24:05 -04:00
Nick Mathewson 2eba3d213e llcrypto: add another warning to ct_lookup. 2023-06-16 12:24:05 -04:00
Nick Mathewson 25db56777c Lower tor-proto::util::ct::lookup to tor-llcrypto
This is mostly code movement; you may want to review it with
`--color-moved`.

I'm doing this so we can also use the function in netdoc for
looking up hsdesc authentication.
2023-06-16 12:24:05 -04:00
Nick Mathewson a20c3eda6e netdoc: Downgrade an HS todo wrt HS_DESC_AUTH_TYPE 2023-06-16 12:24:05 -04:00
Nick Mathewson 6fb19c00f5 netdoc: downgrade some TODO HS to TODO HSS.
I'm using HSS for hs-service features.
2023-06-16 12:24:05 -04:00
Nick Mathewson 3c824fe302 netdoc::build remove very broken example.
This could never be a full rustdoc test, since rustdoc never
runs tests for private items.   Even if it were a rustdoc test,
it uses a bunch of types that aren't exposed in the right places,
and it invokes nonexistent functions, and it assumes a `self`
that isn't there.

In lieu of writing a new untested test, I've added a note to refer
the developer to where they can find working example code.
2023-06-16 12:24:05 -04:00
Nick Mathewson 7a617a2dbd netdoc: Remove a TODO that we already solved. 2023-06-16 12:23:56 -04:00
Nick Mathewson 072ce9182b hsclient: note that we should check revctr. 2023-06-16 12:23:56 -04:00
Nick Mathewson c2764cf111 tor-cell: Downgrade 2 TODO-HS to TODO-HSS 2023-06-16 12:21:27 -04:00
Nick Mathewson 1691c35392 circmgr: Use a slightly nicer way to pick a circuit from our pool.
This algorithm only looks at circuits until it finds one that
satisfies our needs.  To get a random circuit, it just randomizes
the starting point within the pool.

This optimization may help if we let circuit pools grow large.
2023-06-16 12:14:49 -04:00
Nick Mathewson 686d5cf209 circmgr: Make hspool size dynamic
Previously we'd always try to keep 8 circuits ready.  That doesn't
make sense if we are super-busy.  Instead, if we run out of
circuits, we double the amount that we try to keep ready, and if we
never go under 80% of our target number, we half the number we try
to keep ready.

We limit the rate of change here, to make sure that we aren't
flapping too much or shrinking too aggressively.

This algorithm is still a mite arbitrary, and will need tuning in
the future.
2023-06-16 12:11:49 -04:00
Nick Mathewson 69179c5dfe circmgr::hspool: Move the Mutex into an intermediary Inner struct
This will be helpful as we complexify the pool behavior a bit.
2023-06-16 11:42:38 -04:00
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
Ian Jackson b34ba70070 arti-client: hs: remove some now-obsolete allows 2023-06-16 16:18:02 +01:00
Ian Jackson f877f37308 arti-client: address: Prefer to throw OnionAddressResolveRequest (fmt) 2023-06-16 16:18:02 +01:00
Ian Jackson d9f1c7195b arti-client: address: Prefer to throw OnionAddressResolveRequest
Reformatting deferred for clarity.
2023-06-16 16:18:02 +01:00
Ian Jackson dafccf93b0 arti-client: hs: Test cases for variously disabling .onion
This test case shows that we return a suboptimal error in some cases.
2023-06-16 16:18:02 +01:00
Ian Jackson 18291cb001 arti-client: Provide ErrorDetailDiscriminants for convenient testing
ErrorDetail isn't PartialEq so we can't assert_eq! it.
But the discriminants will be.
2023-06-16 16:18:02 +01:00
Ian Jackson 0a7ca71e70 arti-client: StreamPrefs::connect_to_onion_services: honour 2023-06-16 16:18:02 +01:00
Ian Jackson 2d112efc0f arti-client: StreamPrefs::connect_to_onion_services: docs
This disposes of the TODO as well.
2023-06-16 16:18:02 +01:00
Ian Jackson c5b655ed45 arti-client: StreamPrefs::connect_to_onion_services: fix cfg 2023-06-16 16:18:02 +01:00
Ian Jackson 21090aa6f0 arti-client: StreamPrefs::connect_to_onion_services: fix name 2023-06-16 16:18:02 +01:00
nate_d1azzz 08b7419138 Added setter method in impl for StreamPrefs
(Taken from tpo/core/arti!1113 and squashed by Ian Jackson, with
conflicting hunk in StreamPrefs struct skipped.

The setter name is wrong, the cfg feature is wrong, there are no
docs, and the TODO is still there.  These will be fixed in a moment.)
2023-06-16 16:18:02 +01:00
Ian Jackson 40dae63b65 arti-client hs: connect_to_onion_services: default to true
This should be enabled by default.  There's still no setter for not,
nor is it honoured - those are separate TODOs.
2023-06-16 16:18:02 +01:00
Ian Jackson ce72588322 arti-client: OnionAddressNotSupported: Change description and kind
Previously this error meant "we haven't written this code yet".
Now, we change it to "you haven't built Arti with this feature".
2023-06-16 16:18:02 +01:00
Ian Jackson 2521b88cd6 arti-client: address: Apply deferred rustfmt churn 2023-06-16 16:18:02 +01:00
Ian Jackson 60cfb09e77 arti-client: address: Plumb StreamPrefs into enforce_config
No functional change yet.  We'll use this shortly.
2023-06-16 16:18:02 +01:00
Ian Jackson bf93519cdd arti-client: address: Move config enforcement
Disposes of two TODOs.
2023-06-16 16:18:02 +01:00
Ian Jackson eb9b0d0d78 arti-client: address: Move config enforcement (pre-fmt)
This will make subsequent commits less noisy to read.
2023-06-16 16:18:02 +01:00
Ian Jackson e95f9e52cc arti-client: address: Disable some tests when HS disabled
These have already been partially/replaced supplemented.
The other test referred to will appear shortly.
2023-06-16 16:18:02 +01:00
Ian Jackson e5d53091cf Merge branch 'hs-naming-arti' into 'main'
arti-*: Rename hs feature to onion-service-client

See merge request tpo/core/arti!1039
2023-06-16 13:22:25 +00: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
Ian Jackson 07d5bc9537 arti-client: Rename hs feature to onion-service-client (cfg lines) 2023-06-16 12:34:53 +01:00
Ian Jackson 8d98982bb2 arti-client: Rename hs feature to onion-service-client
Rationale as per #756.

This is the same name as in the `arti` crate.
2023-06-16 12:34:47 +01: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
Nick Mathewson 6521864a34 rpc: Document and apply lock hierarchy for Mgr/Connection 2023-06-15 12:53:50 -04:00
Nick Mathewson 9e8ad5415e rpc: Give the session-creation function an argument.
This will later let us tell the session-creation function
how the authentication occurred, which will let it decide
what privileges to provide.
2023-06-15 11:50:12 -04:00
Nick Mathewson 2d28402fb7 rpc: revise session initialization a lot.
Formerly, every time we wanted to launch a new connection, we had
to give the RpcMgr a TorClient.  The connection would hold that
TorClient until a session was authenticated, and then would wrap
it in a Session and put it in the object map.

Now, the RpcMgr holds a Box<dyn Fn()...> that knows how to
create Sessions.  When a connection is authenticated, it
asks the Mgr to make it a new session.  This lets us make it
clearer that the TorClient simply can't be given out until the
connection is authenticated.  Later, it will let us create
more types of Session objects under more complicated rules.
2023-06-15 11:44:14 -04: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