aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-keymgr/src/keystore
Commit message (Collapse)AuthorAgeFilesLines
...
* keymgr: Remove unimplemented/unnecessary has_key_bundle function.Gabriela Moldovan2023-07-201-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The concept of a "key bundle" would introduce a lot of complexity while providing little to no gain. Some context: ``` Originally, "key bundles" were meant to be the answer to the question "which keystore should insert place keys in?": https://gitlab.torproject.org/tpo/core/arti/-/blob/36606a66ddca9abd1595d13c9397bc812bf24cb5/crates/tor-keymgr/src/mgr.rs#L60-69 However, I'm not so sure anymore that "key bundles" are the answer. I don't think there is any way we can "guess" where a key should go. When inserting/generating a new key, we should either: always write to the same, primary key store, OR require the user to be explicit about which key store the new key should go in (by assigning an ID to each key store and expecting the user to provide it when inserting/generating new keys) I prefer the latter option, because it provides more flexibility, which we're going to need when implementing the key management CLI (which I think should allow users to generate keys anywhere they want, e.g. arti keymgr generate <key type> --keystore hsm ...) ``` For more details, see the discussion on #903. Closes #903
* keymgr: Add an `id` function to `Keystore`.Gabriela Moldovan2023-07-201-0/+7
| | | | | | This will enable the `KeyMgr` to look up `Keystore`s by ID (which is a requirement for disambiguating the semantics of `insert`, which currently tries to "guess" which keystore it should be using).
* Merge branch 'clippy-allow' into 'main'Ian Jackson2023-07-111-0/+1
|\ | | | | | | | | clippy: Allow some of our existing code patterns See merge request tpo/core/arti!1396
| * Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
| |
* | keymgr: Use Box<dyn EncodableKey> instead of Box<dyn Any>.Gabriela Moldovan2023-07-101-5/+6
|/ | | | | | | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1337#note_2917701 This will make it harder to accidentally return the wrong value from `Keystore::get` (the returned value is now at least guaranteed to implement `EncodableKey`). Closes #937
* keymgr: Rename KeyStore to Keystore globally.Gabriela Moldovan2023-06-292-12/+12
| | | | | We've been capitalizing the "s" in "KeyStore" inconsistently. This `s/KeyStore/Keystore/g` across the codebase.
* keymgr: Add a TODO about implementing and testing has_key_bundle.Gabriela Moldovan2023-06-291-0/+8
|
* keymgr: Add some basic insert and remove tests.Gabriela Moldovan2023-06-291-0/+52
|
* keymgr: Add assert_found! test helper.Gabriela Moldovan2023-06-291-8/+13
|
* keymgr: Add some key retrieval tests for ArtiNativeKeyStore.Gabriela Moldovan2023-06-291-5/+54
|
* keymgr: Add a gen_keys param to init_keystore.Gabriela Moldovan2023-06-291-2/+16
| | | | | This will enable future tests to optionally initialize the test key store with some test keys.
* keymgr: Add tests for ArtiNativeKeyStore::key_path.Gabriela Moldovan2023-06-291-0/+89
|
* keymgr: Derive Debug for ArtiNativeKeyStore.Gabriela Moldovan2023-06-291-0/+1
|
* keymgr: Implement HasKind for ArtiNativeKeystoreError.Gabriela Moldovan2023-06-281-2/+7
|
* keymgr: Remove AsRef<dyn StdError> trait bound and unneeded impls.Gabriela Moldovan2023-06-261-7/+0
| | | | | | We don't really need the `AsRef<dyn StdError>` impls if we make `StdError` a supertrait of `KeystoreError` (and remove the `AsRef<dyn StdError>` trait bound).
* keymgr: Add the file path to SshKeyError context.Gabriela Moldovan2023-06-261-1/+1
|
* keymgr: Add the path to ArtiNativeKeystoreError Display impl.Gabriela Moldovan2023-06-261-3/+3
|
* keymgr: Replace Error with Box<dyn KeystoreError>.Gabriela Moldovan2023-06-262-22/+26
| | | | Part of #901
* keymgr: Define an error type for ArtiNativeKeyStore.Gabriela Moldovan2023-06-262-0/+75
| | | | Part of #901
* keymgr: Remove outdated TODO.Gabriela Moldovan2023-06-221-1/+0
| | | | This TODO talks about a change we've decided not to implement.
* keymgr: Fix clippy lints.Gabriela Moldovan2023-06-211-1/+1
|
* keymgr: Make ArtiNativeKeyStore::key_path() return a relative path.Gabriela Moldovan2023-06-211-15/+19
| | | | | | | | | This also updates `ArtiNativeKeyStore`'s `KeyStore::remove` implementation to build the absolute path of the file being removed, by joining `self.keystore_dir` and the relpath returned by `ArtiNativeKeyStore::key_path()`. This addresses #908
* Merge branch 'keymgr-api-consistency' into 'main'Ian Jackson2023-06-211-21/+22
|\ | | | | | | | | keymgr: Remove Error::NotFound, update KeyMgr, KeyStore APIs. See merge request tpo/core/arti!1280
| * keymgr: Remove Error::NotFound, update KeyMgr, KeyStore APIs.Gabriela Moldovan2023-06-211-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes the `NotFound` `tor_keymgr::Error` variant. Since `KeyMgr` and `KeyStore` users will need to be able to distinguish between "not found" errors and other I/O errors, this also changes the return types of the `get()` and `remove()` functions of `KeyStore` and `KeyMgr`, which now return `Ok(None)` instead of `Error::NotFound`. This makes the `KeyStore` API consistent with `KeyMgr::get`, which already has a return type of `Result<Option<K>>` (rather than `Result<K>`). This also prepares us for #901, which will make key store errors opaque. Without this change: * we'd have to create a `struct NotFoundError;` error type. Its `HasKind` impl would need to return a new `ErrorKind::KeyStoreErrorNotFound` `ErrorKind` variant * callers would have to match the `error_kind()` of the error to figure out whether the key simply can't be found (`ErrorKind::KeyStoreErrorNotFound`), or if something went wrong (any other `ErrorKind`). Given the above, I think `Result<Option<()>>` makes for a more ergonomic API. Part of #901
* | keymgr: Remove outdated TODO.Gabriela Moldovan2023-06-211-8/+0
|/ | | | | This TODO describes something we're not planning to implement, so let's just remove it.
* keymgr: Fix clippy lints.Gabriela Moldovan2023-06-201-1/+1
|
* keymgr: Enforce keystore_dir properties for every key read/written from the ↵Gabriela Moldovan2023-06-201-16/+19
| | | | keystore.
* keymgr: Update function names and docs to reflect reality.Gabriela Moldovan2023-06-201-2/+2
| | | | | | 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.
* keymgr: Move FS operations out of ssh.rsGabriela Moldovan2023-06-201-5/+15
| | | | | | | 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).
* Merge branch 'update-keymgr-todo' into 'main'Alexander Færøy2023-06-201-1/+2
|\ | | | | | | | | keymgr: Change "TODO hs" to "TODO HSS". See merge request tpo/core/arti!1264
| * keymgr: Defer key bundle support until "Basic Service" milestone.Gabriela Moldovan2023-06-201-1/+2
| | | | | | | | We don't really need "key bundles" for the client keys.
* | arti-client, keymgr: Introduce Mistrust settings and enforce FS permissions.Gabriela Moldovan2023-06-201-5/+35
| |
* | keymgr: Add TODO about separation of concerns wrt FS operations.Gabriela Moldovan2023-06-201-0/+8
|/
* keymgr: Add ArtiNativeKeyStore implementation skeleton.Gabriela Moldovan2023-06-151-0/+72
This adds implementation stubs for `ArtiNativeKeyStore`, and introduces the traits needed to make the `KeyStore` APIs work.