aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-keymgr/src/keystore
Commit message (Collapse)AuthorAgeFilesLines
...
* tor-keymgr: Add arti native keystore helper for parsing tor certs.Gabriela Moldovan2024-12-042-0/+42
| | | | | We'll soon use this in `ArtiNativeKeystore`'s `Keystore` implementation for parsing certs read from disk.
* tor-keymgr: s/key/item in error message test.Gabriela Moldovan2024-12-042-2/+2
|
* tor-keymgr: Rename error variant.Gabriela Moldovan2024-12-043-14/+13
|
* tor-key-forge: Implement EncodableItem for Tor ed25519 certs.Gabriela Moldovan2024-12-041-3/+3
| | | | | This will enable us to store `tor_cert::EncodedEd25519Cert`s in the keystore.
* tor-keymgr: Replace as_ssh_key_data with as_keystore_item (fmt).Gabriela Moldovan2024-12-041-1/+1
|
* tor-keymgr: Replace as_ssh_key_data with as_keystore_item.Gabriela Moldovan2024-12-042-12/+16
|
* tor-keymgr: Replace KeyType with KeystoreItemType (fmt).Gabriela Moldovan2024-12-044-11/+52
|
* tor-key-forge: Remove no longer needed KeyType::Unknown variant.Gabriela Moldovan2024-12-041-14/+0
| | | | | Items that have an unrecognized file extension now get mapped to `KeystoreItemType::Unknown`.
* tor-keymgr: Replace KeyType with KeystoreItemType.Gabriela Moldovan2024-12-046-110/+129
| | | | | This is part of the work needed to support storing certificates in the keystore (they won't have a `KeyType`, but rather `CertType`).
* tor-key-forge: Rename EncodableKey to EncodableItem.Gabriela Moldovan2024-12-044-10/+10
| | | | | | | | This is the first step in replacing `EncodableKey` with the new `EncodableItem` trait (see doc/dev/keymgr-certificates.md). (this refactoring is split over multiple commits to make reviewing easier)
* tor-keymgr: Feature-gate RelKeyPath::from_parts constructor.Gabriela Moldovan2024-11-201-0/+1
| | | | | Otherwise, we get a dead code warning when the `ctor-keystore` feature is disabled.
* tor-keymgr: Add tests for CTorServiceKeystore.Gabriela Moldovan2024-10-081-1/+148
|
* tor-keymgr: Add tests for CTorClientKeystore.Gabriela Moldovan2024-10-082-2/+131
|
* tor-keymgr: Move assert_found helper to test_utils.Gabriela Moldovan2024-10-081-14/+1
| | | | | This moves `assert_found` out of the `keystore::arti::test` so we can reuse it for testing other keystore implementations too.
* tor-keymgr: Add a keystore for C Tor client keys.Gabriela Moldovan2024-10-083-0/+330
|
* tor-keymgr: Add a keystore for C Tor service keys.Gabriela Moldovan2024-10-083-0/+476
|
* tor-keymgr: Rename Filesystem variant to Io for clarity (fmt).Gabriela Moldovan2024-10-082-44/+57
|
* tor-keymgr: Rename Filesystem variant to Io for clarity.Gabriela Moldovan2024-10-082-3/+3
| | | | | The `FilesystemError::Filesystem` variant was actually just for IO errors.
* tor-keymgr: Refactor common fs errors into a separate error enum.Gabriela Moldovan2024-10-083-76/+96
| | | | | | | | This will be reused by other on-disk key stores (such as the C Tor ones we're about to add). I recommend reviewing this commit using `git diff --color-moved=zebra --ignore-space-change`
* tor-keymgr: Add RelKeyPath::from_parts constructor.Gabriela Moldovan2024-10-081-0/+5
| | | | This will be used to create relative paths representing C Tor keys.
* tor-keymgr: Rename RelKeyPath::new to RelKeyPath::arti.Gabriela Moldovan2024-10-082-3/+3
| | | | We're about to add a separate constructor for CTor paths.
* tor-keymgr: Move the checked_op utils out of the arti module.Gabriela Moldovan2024-10-082-10/+15
| | | | We are about to use this for the ctor keystore implementation too.
* tor-keymgr: Reimagine CTorPath as an enum.Gabriela Moldovan2024-10-081-0/+16
| | | | | | | | | | | | | | | | | | | | | | C Tor's client restricted discovery keys don't have the service hsid encoded in the filename (the hsid of the service each key is associated with is encoded in contents of the key file). This means that given a key specifier like `HsClientDescEncKeypairSpecifier` (which is a wrapper over an HsId), we can't actually compute the relative path of the key in its `KeySpecifier::ctor_path()` implementation. To do so we would need to access the keystore to figure out which path contains the requested HsId, which we can't (and shouldn't!) do from within the `KeySpecifier` impl. This suggests the String newtype (representing a relative path) we previously had is not a good abstraction for `CTorPath`s. Moreover, `CTorPath` are static (they don't have dynamic components like `ArtiPath`), so it makes more sense to model `CTorPath` as an enum. The new `CTorPath::ClientHsDescEncKey(HsId)` variant will be used to instruct the C Tor client keystore to find the file that contains the specified `HsId`, while the `Service` variant will be used for hidden service keys.
* tor-keymgr: add disk-related docs to `ArtiEphemeralKeystore`Steven Engler2024-09-171-0/+6
|
* Rename tor-keys crate to tor-key-forgeDavid Goulet2024-09-045-5/+5
| | | | Signed-off-by: David Goulet <[email protected]>
* tor-keymgr: Use tor-keys crate and remove dead codeDavid Goulet2024-09-045-14/+19
| | | | | | | | | | | Everything copied in the previous commits to tor-keys is now removed and tor-keys crate is used accross the code. Minor changes to tor-keys to accomodate this change. Part of #1137 Signed-off-by: David Goulet <[email protected]>
* Fix typosDimitris Apostolou2024-09-031-2/+2
|
* tor-keymgr: Remove unnecessary io::Error handling.Gabriela Moldovan2024-08-081-6/+0
| | | | | | `fs-mistrust` always maps `io::ErrorKind::NotFound` to `fs_mistrust::Error::NotFound`, so these `io::ErrorKind::NotFound` branches were unreachable.
* tor-keymgr: Use CheckedDir::metadata() instead of PathBuf::try_exists().Gabriela Moldovan2024-08-082-12/+48
| | | | | We now use `CheckedDir::metadata()` to check if the path exists and is of the correct type.
* tor-keymgr: Use the new relative path wrapper (fmt).Gabriela Moldovan2024-08-081-9/+15
|
* tor-keymgr: Use the new relative path wrapper.Gabriela Moldovan2024-08-082-43/+24
|
* tor-keymgr: Add new rel_path module with helpers for handling relative paths.Gabriela Moldovan2024-08-082-0/+77
|
* tor-keymgr: Add private RelKeyPath type for relative paths.Gabriela Moldovan2024-08-081-10/+22
| | | | | | | | This makes `rel_path` return a `RelKeyPath` instead of a `PathBuf` to prevent the accidental misuse of relative key paths (like the one from #1492). Closes #1494
* tor-keymgr: Use Path::try_exists() instead of Path::exists().Gabriela Moldovan2024-07-301-3/+10
|
* tor-keymgr: Fix ArtiNativeKeystore::contains() bug.Gabriela Moldovan2024-07-171-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug in `ArtiNativeKeystore`'s `Keystore::contains()` implementation: previously, it called Path::exists() on the relative path (built by concatenating the key specifier and the extension), so unless your current directory happened to be the root of the keystore, `contains()` would always return `false`. `KeyMgr::generate` uses `Keystore::contains()` under the hood, so it was affected by this bug too: if called `overwrite = false`, it would misbehave and overwrite any existing keys. Internally, we call `KeyMgr::generate` in a couple of places: * `tor-hsservice/src/lib.rs`, to generate the `hsid` if it doesn't already exist. This callsite is not affected by the bug, because `KeyMgr::generate` is only called if `KeyMgr::get` returns `None` * `tor-hsservice/src/ipt_mgr.rs`, to generate `KS_hss_ntor` and `KS_hs_ipt_sid` keys for intro point establishment. This callsite is also not affected (because it too calls `get()` before attempting to `generate()`) The bug affects any downstream users that use `KeyMgr::generate` with a key manager backed by `ArtiNativeKeystore`. ------ `KeyMgr::get_or_generate` is not affected, even though it calls `Keymgr::generate` (it performs a separate extra check before calling `generate()`). (Both suffer from a known TOCTOU race, but that's a separate matter.) As an aside, I'd like to somehow unify `KeyMgr::get_or_generate` and `KeyMgr::get` (I've had some attempts in the past but ended up abandoning them because the result was more unergonomic than the existing APIs). Part of #1492
* tor-keymgr: Rename function to clarify it returns a relative path (fmt).Gabriela Moldovan2024-07-171-1/+2
|
* tor-keymgr: Rename function to clarify it returns a relative path.Gabriela Moldovan2024-07-171-15/+15
|
* tor-keymgr: Add test for ArtiNativeKeystore::contains.Gabriela Moldovan2024-07-171-0/+2
| | | | | | | | | | This new assertion fails, because the implementation of `ArtiNativeKeystore::contains()` is buggy: it calls Path::exists() on the relative path built by concatenating the key specifier and the extension (so unless your current directory happens to be the root of the keystore, contains() is always going to return false). Part of #1492
* tor-keymgr: Correct message for mistrust errorIan Jackson2024-07-102-4/+4
|
* tor-keymgr: Add script for generating test key files.Gabriela Moldovan2024-05-151-0/+6
| | | | | | | | | | | `tor-keymgr/testdata` contains a bunch of OpenSSH keys used for testing. I meant to share the script I generated them with, but somehow never got around to it. Note: the OpenSSH keys generated by this script are going to look slightly different than the ones that are checked into the repo. This is because some of those original key files were generated ad-hoc (I manually modified them a while ago, but I forgot exactly how
* Revert "tor-keymgr: Fix now-failing test."Gabriela Moldovan2024-05-081-0/+16
| | | | This reverts commit 9ea35caeb1ed23fd029627d04819debc41d85c77.
* tor-keymgr: Validate the KeyType when inserting into the ephemeral keystore.Gabriela Moldovan2024-05-081-0/+20
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2131#note_3028014
* tor-keymgr: Make SshKeyData an opaque type.Gabriela Moldovan2024-05-072-24/+3
| | | | | | This helps prevent external users from creating `SshKeyData` out of unsupported types of `ssh_key::public::KeyData` and `ssh_key::private::KeypairData`.
* tor-keymgr: Do not make SshKeyData infallibly convertible from ↵Gabriela Moldovan2024-05-071-4/+4
| | | | KeyData/KeypairData.
* tor-keymgr: Update ephemeral keystore docs.Gabriela Moldovan2024-05-071-2/+2
|
* tor-keymgr: Dedupe all the convert functions.Gabriela Moldovan2024-05-072-141/+17
|
* tor-keymgr: Make an ArtiNativeKeystore-specific function private.Gabriela Moldovan2024-05-071-20/+16
| | | | | | | The `ssh_algorithm()` function was only meant for use in the ArtiNativeKeystore, for extracting the `KeyType` given the `SshAlgorithm` of a key read from disk, so it really shouldn't be crate-public.
* tor-keymgr: Move arti-specific ssh code to arti module.Gabriela Moldovan2024-05-073-2/+397
| | | | | | | | | Some of the types and impls from `key_type/ssh.rs` (such as `UnparsedOpenSshKey`) have nothing to do with `KeyType`, and are only used by the `ArtiNativeKeystore`, so I'm moving them to the `arti` keystore module. The shared ssh-related stuff now lives in the top-level `ssh.rs`.
* tor-keymgr: Test that the ephemeral store returns the correct type.Gabriela Moldovan2024-05-071-2/+6
|
* tor-keymgr: Fix now-failing test.Gabriela Moldovan2024-05-071-16/+0
| | | | | | Inserting a key that has the wrong key type no longer fails, because we now store the `KeyData` as-is, without attempting to parse it as a specific kind of SSH key.