Commit Graph

86 Commits

Author SHA1 Message Date
Gabriela Moldovan 4941a88494 keymgr: Fix wrong_key_type test.
The string representation of `SshKeyAlgorithm` on `main` changed between
the time the tests were introduced and the time they were merged.
2023-06-29 15:21:27 +01:00
gabi-250 9407fe1ab5 Merge branch 'keymgr-tests' into 'main'
keymgr: Add tests for ArtiNativeKeyStore

See merge request tpo/core/arti!1337
2023-06-29 13:02:07 +00:00
gabi-250 b059e02093 Merge branch 'keymgr-x25519-keys' into 'main'
keymgr: Add support for x25519 keys.

Closes #900

See merge request tpo/core/arti!1321
2023-06-29 11:46:03 +00:00
Gabriela Moldovan 294bb728cf keymgr: Add a TODO about implementing and testing has_key_bundle. 2023-06-29 12:10:35 +01:00
Gabriela Moldovan 68c91223f1 keymgr: Add some basic insert and remove tests. 2023-06-29 12:10:35 +01:00
Gabriela Moldovan 4d5f414017 keymgr: Add assert_found! test helper. 2023-06-29 11:54:54 +01:00
Gabriela Moldovan 91573c6cbc keymgr: Add some key retrieval tests for ArtiNativeKeyStore. 2023-06-29 11:54:54 +01:00
Gabriela Moldovan fd3b42688d keymgr: Add a gen_keys param to init_keystore.
This will enable future tests to optionally initialize the test key
store with some test keys.
2023-06-29 11:54:54 +01:00
Gabriela Moldovan bc447524c2 keymgr: Add tests for ArtiNativeKeyStore::key_path. 2023-06-29 11:54:54 +01:00
Gabriela Moldovan 89d52fff3e keymgr: Derive Debug for ArtiNativeKeyStore. 2023-06-29 11:49:31 +01:00
Gabriela Moldovan ff02270307 keymgr: Add tests for ssh key handling.
Part of #895
2023-06-29 11:49:31 +01:00
Gabriela Moldovan 16a7bb4624 keymgr: Return the key, not Box<()>.
This fixes a bug which caused the function to always return a
type-erased `()` instead of the actual key!
2023-06-29 11:49:31 +01:00
Gabriela Moldovan 609e6ce7c7 keymgr: Downgrade "TODO hs" to "TODO HSS".
These TODOs can be deferred for now: we're not declaring the keymgr APIs
stable until we add support for hidden services.
2023-06-28 16:44:06 +01:00
Gabriela Moldovan 70f468d0f1 keymgr: Downgrade some TODOs to "TODO HSS".
These don't need to be blockers for the next release.
2023-06-28 13:11:53 +01:00
Gabriela Moldovan 928a9cd7ca keymgr: Remove outdated TODOs regarding error handling.
These were tackled in #901.
2023-06-28 13:07:52 +01:00
Gabriela Moldovan dff8c0163b keymgr: Implement HasKind for ArtiNativeKeystoreError. 2023-06-28 11:59:00 +01:00
Gabriela Moldovan ef1c969c73 keymgr: Implement HasKind for SshKeyError. 2023-06-28 11:59:00 +01:00
Gabriela Moldovan e332caf562 keymgr: Remove unneeded error variant.
The `Unsupported` variant is no longer needed now that we support
`KeyType::X25519StaticSecret`s.
2023-06-27 20:11:07 +01:00
Gabriela Moldovan 7732ac131b keymgr: Add support for x25519 keys. 2023-06-27 20:11:07 +01:00
Gabriela Moldovan 257797fff6 keymgr: Return a concrete type from read_ed25519_keypair.
This also fixes a bug which caused the function to always return a
type-erased `()` instead of the actual key!
2023-06-27 20:11:07 +01:00
Gabriela Moldovan b91a1c2859 keymgr: Move TODO closer to the code it refers to. 2023-06-27 20:11:07 +01:00
Gabriela Moldovan c114c413c2 keymgr: Map KeyType::X25519StaticSecret to an SshKeyAlgorithm. 2023-06-27 20:11:07 +01:00
Gabriela Moldovan 8edbd04413 keymgr: Define an SshKeyAlgorithm enum.
This previously just re-exported `ssh_key::Algorithm`.

However, we will need to support x25519 keys (which aren't supported by
the `ssh_key` crate), so we define our own enum for the key algorithm.
In addition to the `Algorithm` variants from `ssh_key`, our enum also
has an `X25519` variant.
2023-06-27 20:11:07 +01:00
Gabriela Moldovan 6dfcf40d20 keymgr: Add regression test for tor_keymgr::Error recursion bug. 2023-06-27 19:22:30 +01:00
Gabriela Moldovan a41c3a5c7c keymgr: Fix infinite recursion in Error impl.
The `source` impl `tor_keymgr::Error` was just calling itself
recursively.
2023-06-27 19:22:30 +01:00
Gabriela Moldovan b3b4abcf90 keymgr: Document why we need the StdError impl for tor_keymgr::Error. 2023-06-26 13:16:58 +01:00
Gabriela Moldovan a1dbec79bd keymgr: Remove AsRef<dyn StdError> trait bound and unneeded impls.
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).
2023-06-26 13:16:58 +01:00
Gabriela Moldovan de0f662fb6 keymgr: Add the file path to SshKeyError context. 2023-06-26 13:16:04 +01:00
Gabriela Moldovan 60036b3cc3 keymgr: Add the path to ArtiNativeKeystoreError Display impl. 2023-06-26 13:16:04 +01:00
Gabriela Moldovan 85305e156f keymgr: Replace Error with Box<dyn KeystoreError>.
Part of #901
2023-06-26 13:16:03 +01:00
Gabriela Moldovan 4870c2e7d9 keymgr: Add helper for boxing SshKeyError. 2023-06-26 13:13:44 +01:00
Gabriela Moldovan 74f41fd7f3 keymgr: Implement KeystoreError for SshKeyError. 2023-06-26 13:13:43 +01:00
Gabriela Moldovan 165b1060ef keymgr: Add some initial variants to SshKeyError. 2023-06-26 13:13:16 +01:00
Gabriela Moldovan a5b8291ca9 keymgr: Define an error type for the ssh module. 2023-06-26 13:13:16 +01:00
Gabriela Moldovan 158255b827 keymgr: Define an error type for ArtiNativeKeyStore.
Part of #901
2023-06-26 13:13:16 +01:00
Gabriela Moldovan fe929d8efe keymgr: Implement KeystoreError for Bug.
This also implements `AsRef<StdError>` for `Bug` to satisfy the
`KeystoreError: AsRef<dyn StdError>` trait bound.

Part of #901
2023-06-26 13:13:16 +01:00
Gabriela Moldovan 7c023f2ec2 keymgr: Create a KeyStoreError trait for keystore errors.
The new `BoxedError` type will replace `tor_keymgr::Error`.

Part of #901
2023-06-26 13:13:15 +01:00
Gabriela Moldovan bc24e7974c keymgr: Make the dummy types non_exhaustive. 2023-06-22 18:34:20 +01:00
Gabriela Moldovan 8bfdb69ebc keymgr: Add a TODO regarding missing dummy impls. 2023-06-22 18:34:20 +01:00
Gabriela Moldovan 297248cd9f keymgr: Update outdated docs. 2023-06-22 18:34:19 +01:00
Gabriela Moldovan cd0cad3aa6 keymgr: Remove outdated TODOs. 2023-06-22 18:34:04 +01:00
Gabriela Moldovan f2d81c73ac keymgr: Remove unnecessary dummy types.
We don't need dummy impls for `Error` and `Result`.
2023-06-22 18:34:04 +01:00
Gabriela Moldovan fbb1ad0b1e keymgr: Move dummy implementation to tor-keymgr. 2023-06-22 18:33:43 +01:00
Gabriela Moldovan fbdf05946c keymgr: Remove unnecessary pub(crate). 2023-06-22 18:07:57 +01:00
Gabriela Moldovan e5aafa129b keymgr: Downgrade 2 "TODO hs" to "TODO HSS". 2023-06-22 11:28:24 +01:00
Gabriela Moldovan 84b2cc98d5 keymgr: Remove outdated TODO.
This TODO talks about a change we've decided not to implement.
2023-06-22 11:25:27 +01:00
Alexander Færøy d1658a120e Merge branch 'stderr' into 'main'
lints: Promote clippy::print_stderr and clippy::print_stdout

See merge request tpo/core/arti!1271
2023-06-21 16:41:10 +00:00
Gabriela Moldovan b8279c3421 keymgr: Fix clippy lints. 2023-06-21 17:04:03 +01:00
Gabriela Moldovan d8743771e8 keymgr: Remove outdated TODO.
This TODO was addressed in #899
2023-06-21 17:03:41 +01:00
Gabriela Moldovan 1e1cb05d27 keymgr: Make ArtiNativeKeyStore::key_path() return a relative path.
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
2023-06-21 17:03:40 +01:00