Commit Graph

131 Commits

Author SHA1 Message Date
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
Ian Jackson 161b9844da lints: Run maint/add_warning to actually apply new lints 2023-06-21 12:15:41 +01: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
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 95e4021ed8 arti-client, keymgr: Introduce Mistrust settings and enforce FS permissions. 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
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
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 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 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 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