| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| |
|
|
|
|
|
| |
`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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
The config will soon contain secondary C Tor keystore configuration too,
so the `arti` namespacing is about to stop making sense.
I recommend reviewing this commit using
`git diff --color-moved=zebra --ignore-space-change`
|
| |
|
|
|
|
|
| |
We are about to need this in `tor-keymgr`, where we're about to add a
config for C Tor service keystores (the C Tor keystore config will have
an associated `HsNickname` that specifies which of the arti hidden
services it's supposed to be used with).
|
| | |
|
| |
|
|
|
|
| |
The `derive_more` crate broke backward compatibility with this version,
so this change involved quite a few manual fixups.
With luck, they'll keep compatibility for some while in the future.
|
| |
|
|
|
| |
In !2394 we settled on `kind`. This updates the error messages to
reference the new field name.
|
| |
|
|
|
| |
The keystore settings only configure the *primary* keystore, so they
should be under `keystore.primary`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a follow-up from !2394
I want to keep the `keystore.enabled` option, because I'm planning on
extending `ArtiKeystoreConfig` to support configuring secondary
keystores too (currently, the only supported setting is `keystore.kind`,
which configures the primary keystore). `keystore.enabled` will disable
keystore use altogether (i.e. both primary and secondary).
Currently, we only support configuring the "primary" (previously known
as "default") keystore, which can be either "native" (the on-disk Arti
keystore), or "ephemeral" (an in-memory keystore). To implement #858,
we will need to support configuring additional keystores too, so we will
need to move to a config of the form
```toml
[storage.keystore]
# Whether the keystore is enabled.
#enabled = "auto"
# Configure the primary keystore.
[storage.keystore.primary]
# The type of primary keystore to use
kind = "auto" | "native" | "ephemeral"
# Optionally configure C Tor keystores for arti to use.
#
# Note: The keystores listed here are read-only (keys are only
# ever written to the primary keystore, configured in
# `storage.keystore.primary`).
[[storage.keystore.ctor]]
# If the `kind` is `service`, this should be set to the `HiddenServiceDirectory`
# of your hidden service. Arti will read `HiddenServiceDirectory/hostname`
# and `HiddenServiceDirectory/private_key`. (Note: if your service is running
# in restricted discovery mode, you must set the
# `[[onion_services."<the nickname of your svc>".restricted_discovery.key_dirs]]`
# to `HiddenServiceDirectory/client_keys`
#
# If the `kind` is `client`, this should be set to `ClientOnionAuthDir` of
# your client. If Arti is configured to run as a client (i.e. if it runs in SOCKS
# proxy mode), it will read the client restricted discovery keys from this path.
path = "/foo/bar"
# The type of keystore `path` should be interpreted as
kind = "client" | "service"
```
This moves the current keystore settings to `storage.keystore.primary`
in preparation for that change.
|
| |
|
|
|
| |
I am adding `is_enabled()` back because I plan to un-deprecate the
`enabled` setting.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
| |
Feature is named "ephemeral-keystore".
|
| | |
|
| | |
|
| |
|
|
| |
https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2393#note_3073480
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
| |
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
| |
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]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The derive ed25519 keypair macro now implements the keymgr trait so the
key wrapper can now be used with a keystore without needing to specify
it in the tor-keymgr crate.
For this to work, a slight change to the KeygenRng trait was needed as
in to expect the CryptoRngCore trait which is what ed25519-dalek
requires.
And also, the removal of the Sealed trait since now it is accepted to
implement these traits outside tor-keymgr.
Fixes #1137
Signed-off-by: David Goulet <[email protected]>
|
| | |
|
| |
|
|
|
|
| |
`fs-mistrust` always maps `io::ErrorKind::NotFound` to
`fs_mistrust::Error::NotFound`, so these `io::ErrorKind::NotFound`
branches were unreachable.
|
| |
|
|
|
| |
We now use `CheckedDir::metadata()` to check if the path exists and is
of the correct type.
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
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
|
| | |
|
| |
|
|
|
| |
This warning complains when we say `where T: SomeTrait + ?Sized`
when `SomeTrait` is inherently Sized.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| | |
|
| | |
|
| |
|
|
|
|
| |
The previous approach was buggy: collecting the parts of the time period
into an `ArrayVec` of length 3 would panic if the number of parts was
greater than 3.
|
| |
|
|
|
|
|
|
| |
This test currently fails because we have a bug in `TimePeriod`'s
`from_slug()` implementation. `TimePeriod::from_slug()` splits the slug
by `_`, and attempts to collect the parts into an `ArrayVec` of length
3. This is wrong, because the `collect()` will panic if there are more
than 3 parts.
|
| |
|
|
|
|
|
|
|
|
|
| |
* Change `pub` to `export`
* Change the `=` in define to `:`
* Change `pub_template_semver_check` to `template_export_semver_check`
Right now, 0.12.1 supports both syntaxes. I have verified this branch
also compiles with
https://gitlab.torproject.org/Diziet/rust-derive-deftly/-/merge_requests/402
ee171ffaf56d7dcb7d75584054921153fe19b222
|
| |
|
|
|
|
| |
* Bump in Cargo.toml
* Deal with `${Xmeta as ...}` incompatible change, by
always specifying an `as`, and changing `as tokens`.
|
| |
|
|
|
|
|
|
|
|
|
| |
`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
|
| |
|
|
| |
This is a follow-up from !2131
|
| |\
| |
| |
| |
| |
| |
| | |
tor-keymgr: Refactor code shared between ArtiNativeKeystore and ArtiEphemeralKeystore
Closes #1362 and #1367
See merge request tpo/core/arti!2131
|