aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-keymgr/src/mgr.rs
Commit message (Collapse)AuthorAgeFilesLines
...
* arti: keys: Add `keys check-integrity` CLI toolhjrgrn2025-09-041-3/+35
|
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-31/+44
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* arti: hss: Add `arti hss ctor-migrate`hjrgrn2025-07-311-0/+61
|
* tor-keymgr: Add err::Error::KeystoreNotFoundhjrgrn2025-07-231-1/+1
|
* arti: keys: Add arti keys-rawhjrgrn2025-07-141-178/+265
| | | | | | | | | | | | | | | | | | | * CLI: Add `keys-raw` and subcommand `remove-by-path` * arti: Add `arti::subcommand::raw` for the CLI `keys-raw` * tor-keymgr: Add `ArtiNativeKeystoreError::UnexpectedRawEntry`, `ArtiEphemeralKeystoreError::NotSupported` * tor-keymgr: Add `tor-keymgr::raw` module * tor-keymgr: Add `Keystore::remove_unchecked` * tor-keymgr: Change `Keystore::list` to return `KeystoreEntry` * tor-keymgr: Add field `KeystoreEntry::raw_id` * doc: Update keys.md * doc: Add raw.md * tor-keymgr: BREAKING: `UnrecognizedEntryError::new` associated function is now only accessible within the crate `tor-keymgr` * tor-keymgr: BREAKING: `UnrecognizedEntryId` is renamed to `UnrecognizedEntry` * tor-keymgr: BREAKING: `KeyMgr::list()` and `Keystore::list()` now return `Result<Vec<KeystoreEntryResult<KeystoreEntry>>>`
* Merge branch 'typos-20250709' into 'main'Nick Mathewson2025-07-091-1/+1
|\ | | | | | | | | Typo fixes (automatic and hand-verified) See merge request tpo/core/arti!3089
| * Typo fixes (automatic and hand-verified)Nick Mathewson2025-07-091-1/+1
| | | | | | | | Made with https://crates.io/crates/typos-cli
* | keymgr: fix spelling of MethodNotSuppor(t)ed.Nick Mathewson2025-07-091-5/+5
|/
* arti: Add keys list and keys list-keystoreshjrgrn2025-06-121-8/+160
|
* tor-keymgr: BREAKING: Refactor API: Keystore::listhjrgrn2025-05-301-4/+121
| | | | | * Change return type `Result<Vec<(KeyPath, KeystoreItemType)>>` if favor of `Result<Vec<StdResult<(KeyPath, KeystoreItemType), UnrecognizedEntryError>>>`
* tor-keymgr: Refactor ItemMetadata to support certificate metadatashivam374832025-05-061-75/+159
|
* tor-keymgr: BREAKING: Refactor API: Keystore::insertplaybahn2025-04-021-7/+4
| | | | | | Drop redundant/unused param item_type: &KeystoreItemType from keystore::Keystore::insert. Method now uses param key: &dyn EncodableItem to obtain a KeystoreItemType
* tor-keymgr: Fix TODO: Refactor API: Keystore::insertplaybahn2025-04-021-6/+5
| | | | Makes param item_type redundant. Renames item_type -> _item_type.
* tor-keymgr: Introduce ItemMetadata type for testing.vijayabhaskar_782025-03-261-86/+149
|
* Use an EntropicRng trait to enforce key generation rules.Nick Mathewson2025-03-241-8/+12
| | | | | | | | | | | We want to require that whenever we generate a key that's persistent (stored in KeyMgr), it's going to be made from a stronger-than-usual Rng. This trait helps us enforce that. We also add a FakeEntropicRng struct to use for testing. Note that this turned up a case that we'd missed, which required an internal change in tor-hsservice.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - `rand::thread_rng()` has been deprecated and renamed to `rand::rng()`
* tor-keymgr: Use ParsedEd25519Cert when decoding certs.Gabriela Moldovan2025-01-131-1/+2
| | | | | | | This helps us get rid of our uses of `KeyUnknownCert`. Needed because `KeyUnknownCert` can't readily be converted back to `EncodedEd25519Cert` (while `ParsedEd25519Cert` *can* -- see the `certs` module from `tor-relay-crypto`).
* tor-keymgr: Fix cert handling tests.Gabriela Moldovan2025-01-131-8/+19
| | | | | | This updates and reenables the cert management tests. Part of #1768
* tor-keymgr: Use Ed25519Cert::decode to parse the certs.Gabriela Moldovan2025-01-131-0/+3
|
* tor-key-forge: Split out ItemType as a separate trait.Gabriela Moldovan2025-01-131-7/+11
| | | | | | | | This is necessary because `ParsedCert`s will not be `EncodableItem`s. This is because we cannot (and don't want to) write certificates that have not yet been validated to the keystore. They do need to be retrievable from the keystore though, so we also change `ErasedKey` to be `Box<dyn ItemType>` instead.
* tor-key-forge: Distinguish between parsed certs and encodable certs.Gabriela Moldovan2025-01-131-8/+9
| | | | | | | | | | | | | | | We need two different types to represent * certs that have been parsed, but not yet validated (`KeyUnknownCert`) * newly generated encodable certs (`EncodedEd25519Cert`) Currently, we don't use `KeyUnknownCert` anywhere, and instead use `EncodedEd25519Cert` to represent "parsed" but not-yet-validated certs. This approach is wrong and relies on a broken (no-op) `EncodedEd25519Cert::from_bytes` implementation. A future commit will address this problem by replacing `EncodedEd25519Cert::from_bytes` with `Ed25519Cert::decode` to actually parse the cert upon retrieving it from the keystore.
* tor-keymgr: Replace from_encodable_cert with validation function.Gabriela Moldovan2025-01-131-15/+5
| | | | | | | | In practice, we won't be able to obtain an `ToEncodableCert` type from an `EncodableItem` cert without validating it first, so we need to collapse `validate` into `from_encodable_cert`. Part of #1768
* fix: fix typosDimitris Apostolou2025-01-061-1/+1
|
* tor-keymgr: Replace internal error with keystore corruption error.Gabriela Moldovan2024-12-041-1/+1
| | | | | This replaces a placeholder error with a concrete `KeystoreCorruptionError` variant.
* tor-keymgr: Add tests for the new cert mgmt functions.Gabriela Moldovan2024-12-041-1/+172
|
* tor-keymgr: s/TestKey/TestItem in tests.Gabriela Moldovan2024-12-041-55/+55
| | | | | We're about to reuse TestKey as our test key "certificate", so let's preemptively rename it to something more fitting.
* tor-keymgr: Remove unused KeyType import.Gabriela Moldovan2024-12-041-1/+1
|
* tor-keymgr: Add KeyMgr::get_or_generate_key_and_cert.Gabriela Moldovan2024-12-041-0/+119
|
* tor-keymgr: Add KeyMgr::get_key_and_cert() (fmt).Gabriela Moldovan2024-12-041-5/+7
|
* tor-keymgr: Add KeyMgr::get_key_and_cert().Gabriela Moldovan2024-12-041-2/+91
|
* tor-keymgr: Split some logic out of KeyMgr::get_from_store().Gabriela Moldovan2024-12-041-6/+24
| | | | | We're soon going to need the "raw" version of the function (the one that returns the key as `K::Key`).
* 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-041-8/+8
|
* tor-key-forge: Replace EncodableItem::key_type() with item_type() (fmt).Gabriela Moldovan2024-12-041-2/+1
|
* tor-key-forge: Replace EncodableItem::key_type() with item_type().Gabriela Moldovan2024-12-041-16/+16
| | | | | This function now returns a `KeystoreItemType`, enabling us to represent certs as `EncodableItem`s.
* tor-keymgr: Replace KeyType with KeystoreItemType (fmt).Gabriela Moldovan2024-12-041-6/+2
|
* tor-keymgr: Remove now-unused import.Gabriela Moldovan2024-12-041-1/+1
|
* tor-keymgr: Replace KeyType with KeystoreItemType.Gabriela Moldovan2024-12-041-30/+35
| | | | | 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-041-6/+6
| | | | | | | | 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: Implement KeyPath::matches for CTorPaths.Gabriela Moldovan2024-10-081-1/+1
| | | | | | | `KeyPath::matches` now returns a boolean (because we can't return a matching "range" for `CTorPaths`, because unlike ArtiPaths, they're not represented as `String`s, and do not have variable parts that need to be captured).
* tor-keymgr: Return an error if the keystore IDs are not unique.Gabriela Moldovan2024-10-081-0/+8
| | | | | | | | The `KeyMgrBuilder` now returns an error if the configured keystores don't have pairwise unique IDs. This is needed because some keymgr operations take a `KeystoreSelector` specifying the ID of the keystore the operation should be performed on, and assume that the keystore ID uniquely identifies a single keystore.
* tor-keymgr: Rename the primary keystore for clarity.Gabriela Moldovan2024-09-231-23/+23
| | | | | | | | | | Previously, arti's primary keystore was referred to as its "default" keystore. However, "default" is inaccurate here: there is no way to meaningfully override this "default" (the "default" store acts as the main keystore). Throughout the codebase, we query all keystores for keys (including the secondary ones), but only ever write to the default/primary keystore. This is OK for now, because it enables us to have one mutable keystore, and multiple secondary, read-only stores.
* tor-keymgr: add an overwrite flag to KeyMgr::insert()Morgan2024-09-101-8/+47
|
* rename get_keypair_specifier() to keypair_specifier()Adam Joseph F0B74D717CDE8412A3E0D4D5F29AC8080DA8E1E02024-09-091-2/+2
| | | | https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2393#note_3073480
* tor_keymgr: teach the KeyStore how to satisfy public key requests using a ↵Adam Joseph F0B74D717CDE8412A3E0D4D5F29AC8080DA8E1E02024-09-091-1/+9
| | | | | | | | | | | | | | | keypair Now that: - KeySpecifier::get_keypair_specifier() can be used to convert the KeySpecifier for a public key into the KeySpecifier for its secret key - ToEncodableKey<Key=PublicKey> has a "type level pointer" to ToEncodableKey<Key=KeyPair> We can use these two features together to automatically satisfy any request to get a public key using the corresponding secret key (if available).
* tor_key_forge::traits::ToEncodableKey: add KeyPair associated typeAdam Joseph F0B74D717CDE8412A3E0D4D5F29AC8080DA8E1E02024-09-091-0/+2
| | | | | | | | | | This comment adds a second associated type `KeyPair` to ToEncodableKey. For a `ToEncodableKey` which represents a (secret) KeyPair, this type is Self. For a `ToEncodableKey` which represents a public key, this is the `ToEncodableKey` whose `Key` is the pair of which this is the public part. This is essentially a "type level pointer" from the ToEncodableKey for a public key to the ToEncodableKey for its secret key.
* tor_keymgr: add get_keypair_specifier() to KeySpecifier, and derive itAdam Joseph F0B74D717CDE8412A3E0D4D5F29AC8080DA8E1E02024-09-091-0/+4
| | | | | | | This commit adds a new method `get_keypair_specifier()` to `KeySpecifier`. This method is used to indicate when one KeySpecifier (e.g. `KP_hs_id`) is the public part of another keypair (e.g. `KS_hs_id`). It will return the containing keypair in this case, and `None` otherwise.
* tor_hsservice: add `impl From<&FooPublicKeySpecifier> for ↵Adam Joseph F0B74D717CDE8412A3E0D4D5F29AC8080DA8E1E02024-09-091-0/+6
| | | | | | | | | | | | | FooKeypairSpecifier` instances This adds the following trivial `From` instances: - tor_hsservice: impl From<&HsIdPublicKeySpecifier> for HsIdKeypairSpecifier - tor_hsservice: impl From<&BlindIdPublicKeySpecifier> for BlindIdKeypairSpecifier - tor_hscrypto::pk: impl From<HsBlindIdKeypair> for HsBlindIdKey - tor_llcrypto::pk::ed25519: impl From<ExpandedKeypair> for PublicKey - tor_keymgr::mgr: impl From<TestKey> for TestPublicKey - tor::hscrypto::pk: impl From<HsIdKeypair> for HsIdKey
* Rename tor-keys crate to tor-key-forgeDavid Goulet2024-09-041-5/+5
| | | | Signed-off-by: David Goulet <[email protected]>
* tor-keymgr: Use tor-keys crate and remove dead codeDavid Goulet2024-09-041-7/+8
| | | | | | | | | | | 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]>