aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-keymgr
Commit message (Collapse)AuthorAgeFilesLines
...
* keymgr: Move KeyMgr::get impl to Keymgr::get_from_store.Gabriela Moldovan2023-07-201-26/+36
| | | | | | This refactoring will make more sense later, when we give `KeyMgr::get` an extra parameter that specifies which keystore to retrieve the key from.
* keymgr: Remove unimplemented/unnecessary has_key_bundle function.Gabriela Moldovan2023-07-203-16/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Require callers to specify which keystore to insert keys in.Gabriela Moldovan2023-07-203-28/+34
| | | | | | | | | | The caller uses `KeystoreSelector` to specify which keystore to insert the new key into (only `KeystoreSelector::Id` and `KeystoreSelector::Default` are supported for `insert`). The ability to insert keys in a particular keystore will come in handy when we implement the key management CLI (the CLI will have an option for specifying the keystore to access/modify).
* keymgr: Add a convenience function for boxing keystore errors.Gabriela Moldovan2023-07-203-7/+8
|
* keymgr: Add an error type for misuse errors.Gabriela Moldovan2023-07-201-2/+28
| | | | | | This error will be returned by `KeyMgr` if the caller tries to access a keystore that does not exist, or if the requested `KeystoreSelector` cannot be applied.
* keymgr: Add type for specifying which keystore to access.Gabriela Moldovan2023-07-202-0/+14
|
* keymgr: Add a function for looking keystores up by ID.Gabriela Moldovan2023-07-201-0/+5
| | | | | This will be used by `KeyMgr::insert` after we add an additional argument to `insert` for specifying the keystore it should be using.
* keymgr: Add an `id` function to `Keystore`.Gabriela Moldovan2023-07-203-0/+13
| | | | | | 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).
* keymgr: Iterate over all the stores, not just the secondary ones.Gabriela Moldovan2023-07-201-1/+7
|
* keymgr: Explicitly specify the default keystore for `KeyMgr`.Gabriela Moldovan2023-07-203-5/+13
|
* keymgr: Add a type alias for `Box<dyn Keystore>`.Gabriela Moldovan2023-07-201-2/+5
| | | | This makes the code slightly less verbose.
* keymgr-config: Make fields private, add function for checking if keystore is ↵Gabriela Moldovan2023-07-203-2/+20
| | | | | | | | | enabled. Hiding the underlying value of `enabled` enables us to give it a different `auto` value depending on whether the `keymgr` feature is enabled or not (it defaults to `true` if `keymgr` is enabled, and `false` otherwise).
* keymgr: Upgrade to latest itertools.Nick Mathewson2023-07-171-1/+1
| | | | (Everything else is already on 0.11.0.)
* tor-keymgr: Add ArtiNativeKeystoreConfig.Gabriela Moldovan2023-07-135-1/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the keystore config consisted of a single field in `StorageConfig`, which encoded 2 bits of information: whether the keystore is enabled, and its root directory: ``` [storage] # use this path, fail if compiled out # keystore = "/path/to/arti/keystore" # # use default path, fail if compiled out # keystore = true # # disable # keystore = false ``` This commit adds `ArtiNativeKeystoreConfig`, which will replace the multi-purpose `keystore` field. The new config will look like this: ``` #[storage.keystore] # Whether the keystore is enabled. # # If the `keymgr` feature is enabled and this option is: # * set to false, we will ignore the configured keystore path. # * set to "auto", the configured keystore, or the default keystore, if the # keystore path is not specified, will be used # * set to true, the configured keystore, or the default keystore, if the # keystore path is not specified, will be used # # If the `keymgr` feature is disabled and this option is: # * set to false, we will ignore the configured keystore path. # * set to "auto", we will ignore the configured keystore path. # # Setting this option to true when the `keymgr` feature is disabled is a # configuration error. #enabled = "auto" # The root directory of the arti keystore #path = "${ARTI_LOCAL_DATA}/keystore" ``` While `ArtiNativeKeystoreConfig` currently only has 2 fields, `enabled` and `path`, future versions of the keystore might require additional config options.
* Merge branch 'clippy-allow' into 'main'Ian Jackson2023-07-115-0/+5
|\ | | | | | | | | 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-105-0/+5
| |
* | keymgr: Add semver.md.Gabriela Moldovan2023-07-101-0/+2
| |
* | keymgr: Use Box<dyn EncodableKey> instead of Box<dyn Any>.Gabriela Moldovan2023-07-104-10/+20
|/ | | | | | | | | | 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
* Remove explicit allows for missing_panics_docs.Nick Mathewson2023-07-061-1/+0
| | | | These are no longer needed.
* Run add_warning to remove `missing_panics_doc` deny.Nick Mathewson2023-07-061-1/+0
| | | | Closes #950.
* keymgr: Explain why the TODO regarding EncodableKey can't be addressed.Gabriela Moldovan2023-07-051-1/+12
|
* keymgr: Fix broken doc link.Gabriela Moldovan2023-06-301-2/+2
|
* Bump patchlevel versions on crates with smaller changesNick Mathewson2023-06-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Done with the commands below. The following crates have had various changes, and should get a patchlevel bump. Since they are pre-1.0, we do not need to distinguish new APIs from other changes. ``` cargo set-version --bump patch -p arti-client cargo set-version --bump patch -p safelog cargo set-version --bump patch -p tor-bytes cargo set-version --bump patch -p tor-cert cargo set-version --bump patch -p tor-circmgr cargo set-version --bump patch -p tor-config cargo set-version --bump patch -p tor-consdiff cargo set-version --bump patch -p tor-dirclient cargo set-version --bump patch -p tor-dirmgr cargo set-version --bump patch -p tor-error cargo set-version --bump patch -p tor-hsservice cargo set-version --bump patch -p tor-linkspec cargo set-version --bump patch -p tor-llcrypto cargo set-version --bump patch -p tor-netdir cargo set-version --bump patch -p tor-netdoc cargo set-version --bump patch -p tor-proto cargo set-version --bump patch -p tor-rpcbase cargo set-version --bump patch -p tor-socksproto ``` This crate has new features, but no new non-experimental Rust APIs. So even though it is post-1.0, it gets a patchlevel bump. ``` cargo set-version --bump patch -p arti ```
* Bump minor versions on crates with breaking changesNick Mathewson2023-06-301-1/+1
| | | | | | | | | | Done with: ``` cargo set-version --bump minor -p tor-hsclient cargo set-version --bump minor -p arti-rpcserver cargo set-version --bump minor -p tor-hscrypto cargo set-version --bump minor -p tor-cell ```
* Merge branch 'arti-path-bug' into 'main'gabi-2502023-06-301-9/+22
|\ | | | | | | | | keymgr: Allow periods in ArtiPath and ArtiPathComponent. See merge request tpo/core/arti!1358
| * keymgr: Update ArtiPath and ArtiPathComponent docs.Gabriela Moldovan2023-06-301-2/+2
| | | | | | | | | | The docs were lying, we actually support UTF-8 paths (though we might later decide to restrict the charset further).
| * keymgr: Allow periods in ArtiPath and ArtiPathComponent.Gabriela Moldovan2023-06-301-9/+22
| | | | | | | | | | | | | | The `ArtiPath` of a client auth key contains the `HsId` of the onion Since the `HsId` contains a `.onion` component, let's allow `.` for now. In the future, we may want to update the code (and keystore structure) to strip away the `.onion` part before building the `ArtiPath`.
* | Merge branch 'keymgr-docs' into 'main'Ian Jackson2023-06-302-3/+3
|\ \ | |/ |/| | | | | keymgr: Downgrade "TODO hs" to "TODO HSS" See merge request tpo/core/arti!1360
| * keymgr: Downgrade "TODO hs" to "TODO HSS"Gabriela Moldovan2023-06-302-3/+3
| | | | | | | | This TODO doesn't need to block the release.
* | Merge branch 'fixup-features' into 'main'Ian Jackson2023-06-301-1/+3
|\ \ | |/ |/| | | | | Run fixup-features on current `main` See merge request tpo/core/arti!1352
| * Resolve XXXs from fixup-features.Nick Mathewson2023-06-291-1/+0
| | | | | | | | | | Some of these seem spurious: it looks like fixup-features resolved an issue and then complained about it too. I'll investigate further.
| * Run "cargo sort".Nick Mathewson2023-06-291-1/+0
| |
| * Run "fixup-features".Nick Mathewson2023-06-291-0/+4
| |
* | keymgr: Rename KeyStore to Keystore globally.Gabriela Moldovan2023-06-298-35/+35
|/ | | | | We've been capitalizing the "s" in "KeyStore" inconsistently. This `s/KeyStore/Keystore/g` across the codebase.
* Merge branch 'exp' into 'main'Ian Jackson2023-06-291-1/+1
|\ | | | | | | | | tor-error: Make KeystoreFsPermissions experimental for now See merge request tpo/core/arti!1350
| * tor-keymgr: When keymgr enabled, enable tor-error's experimental tooIan Jackson2023-06-291-1/+1
| |
* | Merge branch 'validate-client-spec' into 'main'Ian Jackson2023-06-293-7/+144
|\ \ | | | | | | | | | | | | keymgr: Validate ArtiPaths, replace HsClientSpecifier with generic ArtiPathComponent See merge request tpo/core/arti!1262
| * | keymgr: Remove unstable ErrorKind, use internal! for ArtiPath errors.Gabriela Moldovan2023-06-291-21/+7
| | |
| * | keymgr: Validate the individual ArtiPahtComponents of ArtiPath.Gabriela Moldovan2023-06-291-37/+25
| | | | | | | | | | | | | | | This also implicitly forbids leading and trailing slashes in an `ArtiPath`.
| * | keymgr: Rephrase ArtiPath docs.Gabriela Moldovan2023-06-291-14/+5
| | | | | | | | | | | | This updates the docs with Diziet's suggested doc improvements.
| * | keymgr: Remove ArtiPath normalization, introduce additional restrictions.Gabriela Moldovan2023-06-292-45/+46
| | |
| * | keymgr: Document how ArtiPath validation is actually supposed to work.Gabriela Moldovan2023-06-291-7/+11
| | |
| * | keymgr: Move validation requirements to the ArtiPath docs.Gabriela Moldovan2023-06-291-12/+15
| | |
| * | keymgr: Make ArtiPath platform-independent by always using '/' as a separator.Gabriela Moldovan2023-06-291-10/+10
| | |
| * | keymgr: Add tests for ArtiPath validation.Gabriela Moldovan2023-06-291-0/+90
| | |
| * | keymgr: Validate ArtiPath and ArtiPathComponent.Gabriela Moldovan2023-06-291-12/+45
| | |
| * | keymgr: Derive Into for ArtiPath and ArtiPathComponent.Gabriela Moldovan2023-06-291-1/+3
| | |
| * | keymgr: Define an error type for bad `ArtiPathComponents`.Gabriela Moldovan2023-06-291-1/+18
| | |
| * | keymgr: Derive Display for ArtiPath and ArtiPathComponent.Gabriela Moldovan2023-06-291-3/+4
| | |
| * | keymgr: Define `ArtiPathComponent`.Gabriela Moldovan2023-06-292-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An `ArtiPathComponent` is a substring of an `ArtiPath`. An `ArtiPathComponent` will be validated according to the same rules as `ArtiPath`. In the future we can replace `HsClientSpecifier` with `ArtiPathComponent` (they both serve the same purpose except `ArtiPathComponent` is more generic).