aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-hscrypto/src/pk.rs
Commit message (Collapse)AuthorAgeFilesLines
* multiple crates: Fix clippy warningshjrgrn2026-07-101-2/+2
|
* hscrypto, linkspec, llcrypto: Use new redaction helpersNick Mathewson2026-06-101-5/+3
| | | | This eliminates some string slicing.
* everywhere: Add #[allow(clippy::string_slice)]Clara Engler2026-06-091-0/+1
| | | | | | | | This commit adds #[allow(clippy::string_slice)] to all functions in the code where string slices are used, alongside a TODO comment. We do this add the function header to have it consistent, as things like expression based allow's are still experimental.
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* tor-hcrypto: Port to web-time-compatNick Mathewson2026-03-261-2/+2
|
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* tor-hscrypto: derive_deftly is mandatory againhashcatHitman2025-09-231-2/+2
| | | | | | | I don't know why this was breaking rust-recent-async-std-rustls, but oh well. Signed-off-by: hashcatHitman <[email protected]>
* tor-(hs|ll)crypto: export cteq macros correctlyhashcatHitman2025-09-231-8/+8
| | | | | | | | | | The macros to deftly derive `ConstantTimeEq` and `PartialEq` (for `ConstantTimeEq`) are now only defined in `tor-llcrypto` and exported. The macro to deftly derive `ConstantTimeEq` is now struct only and uses `subtle::Choice::from(1)` for improved clarity. Signed-off-by: hashcatHitman <[email protected]>
* tor-(hs|ll)crypto: deftly derive ConstantTimeEqhashcatHitman2025-09-231-289/+64
| | | | | | | | | | | | | | | | | This is my initial attempt at deriving ConstantTimeEq and PartialEq. This includes the previously missed HsSvcNtorKeypair and HsClientDescEncKeypair types. In tor-llcrypto, a few implementations still had to be done by hand, and some types which previously derived normal PartialEq now derive it with ConstantTimeEq. I could not figure out how to properly set up the macros such that they could be used both in the current crate and in others, so for the moment they are duplicated. Just so I can get feedback. Ideally, this will be replaced with a better solution before merge. Signed-off-by: hashcatHitman <[email protected]>
* tor-hscrypto: constant time PartialEq for keyshashcatHitman2025-09-161-1/+282
| | | | | | | | | | | | | | | | | | | | | | | | | | Implemented `subtle::ConstantTimeEq` for all of the following types: - `pk::HsIdKey` - `pk::HsIdKeypair` - `pk::HsBlindIdKey` - `pk::HsBlindIdKeypair` - `pk::HsDescSigningKey` - `pk::HsDescSigningKeypair` - `pk::HsIntroPtSessionIdKey` - `pk::HsIntroPtSessionIdKeypair` - `pk::HsSvcNtorKey` - `pk::HsSvcNtorSecretKey` - `pk::hs_client_intro_auth::HsClientIntroAuthKey` - `pk::hs_client_intro_auth::HsClientIntroAuthKeypair` - `pk::HsClientDescEncKey` - `pk::HsClientDescEncSecretKey` - `pk::HsSvcDescEncKey` - `pk::HsSvcDescEncSecretKey` - `pk::HsSvcDescEncKeypair` `PartialEq` has also been implemented for all listed types, using the constant time comparison under the hood. Signed-off-by: hashcatHitman <[email protected]>
* tor-hscrypto: change redacted `HsId` from "???" to "[…]"Steven Engler2025-08-251-2/+2
| | | | | | | | | | | | | | Before: ```text INFO tor_hsservice: Generated a new identity for service bar: ???mad.onion ``` After: ```text INFO tor_hsservice: Generated a new identity for service foo: […]2qd.onion ```
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-2/+2
| | | | | | | | | | | | | | 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.
* Use new DisplayRedacted/DebugRedacted code for HsId.Nick Mathewson2025-07-311-28/+22
| | | | Closes #2012.
* tor-hscrypto: fix typostcyrus2025-07-231-2/+2
|
* Typo fixes (automatic and hand-verified)Nick Mathewson2025-07-091-1/+1
| | | | Made with https://crates.io/crates/typos-cli
* Wrap ed25519-dalek types.Nick Mathewson2025-03-181-8/+7
| | | | | | | | | | | With this change, we'll no longer need to expose the types from dalek-cryptography as part of our API, and we'll have more freedom to switch ed25519 implementations, or to upgrade to a newer `rand` ahead of their schedule. Unlike with x25519-dalek, I had to tweak the API a bit: There's no way to get a &PublicKey out of a Keypair now, and implementing the old ed25519-dalek traits seemed unnecessary.
* tor-hscrypto: Move encodable key trait impls from tor-key-forge.Gabriela Moldovan2024-12-111-0/+111
| | | | | | | | | This enables us to get rid of the tor-key-forge -> tor-hscrypto dependency, partially addressing the TODO from `tor_key_forge::traits`. This commit is mostly code motion. Best reviewed with `--color-moved`. See also #1778
* tor-hscrypto: Abolish the HasKind impl of HsIdParseError.Gabriela Moldovan2024-11-041-15/+0
| | | | | | | | | | Also changes the `ErrorKind` of `BadOnionAddress` to `ForbbiddenStreamTarget`. See context in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2246#note_3045683 Closes #1483
* tor-hscrypto: Use the new "restricted discovery" terminology.Gabriela Moldovan2024-10-031-1/+1
| | | | Part of #1476
* tor_hsservice: add `impl From<&FooPublicKeySpecifier> for ↵Adam Joseph F0B74D717CDE8412A3E0D4D5F29AC8080DA8E1E02024-09-091-0/+12
| | | | | | | | | | | | | 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
* tor-hscrypto: Implement Eq for HsClientDescEncKey.Gabriela Moldovan2024-08-051-0/+2
| | | | Needed because such keys will be stored in the `OnionServiceConfig`.
* tor-hscrypto: Use collect_tuple to avoid unnecessary Vec allocation.Gabriela Moldovan2024-07-081-6/+3
|
* tor-hscrypto: Remove HsClientDescKeyParseError's HasKind impl.Gabriela Moldovan2024-07-081-12/+0
| | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/2246#note_3045656
* tor-hscrypto: Implement FromStr for HsClientDescEncKey.Gabriela Moldovan2024-07-081-3/+149
| | | | | | | | | | | | | | We will use this impl for parsing the authorized clients of a hidden service running in "restricted discovery" mode. NB: "Restricted discovery" is the new terminology for "services that require client authorization", i.e. services that implement "client authorization" as described in rend-spec HS-DESC-ENC[0]. Note we haven't fully transitioned to the new terminology yet (see #1476). Part of #1292 [0]: https://spec.torproject.org/rend-spec/hsdesc-encrypt.html#HS-DESC-SECOND-LAYER
* tor-hscrypto: Remove unnecessary Display wrapper.Gabriela Moldovan2024-07-081-17/+5
| | | | | | | | | | | I don't think we need a separate wrapper type for displaying `HsClientDescEncKey` keys in the "C Tor format" (`<auth-type>:<key-type>:<base32-encoded-public-key>`). I think this should be the canonical string representation of `HsClientDescEncKey`, so I'm removing the `display_authorized_client` function and corresponding `DisplayAuthorizedHsClientDescEncKey` wrapper type.
* tor-hscrypto: Add helper for encoding client auth keys in C Tor format.Gabriela Moldovan2024-06-271-0/+23
| | | | | | | This will enable us to implement the `arti hsc` client subcommand for generating client auth keys (#1281). Closes #1291
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* hscrypto: Remove a "TODO HSS" about a no-longer-unused type.Nick Mathewson2023-12-121-4/+0
|
* llcrypto: Hide the members of ExpandedKeypair.Nick Mathewson2023-11-291-10/+9
| | | | | With this change, we no longer expose the ExpandedSecretKey unescorted, which makes it harder to misuse the API.
* llcrypto: Remove ExpandedSecretKey export.Nick Mathewson2023-11-291-5/+5
| | | | | | | This type was part of `hazmat`, and was no longer necessary anywhere in our codebase. (It had one remaining user, which was easy enough to remove.) By removing it, we remove the opportunity for using an unescorted ed25519 private key.
* Remove RngCompatExt.Nick Mathewson2023-11-291-2/+1
| | | | | | | | | | This code was needed with the old version of dalek-cryptography, which wasn't compatible with up-to-date versions of the `rand` crate(s). But now that we've upgraded, we can drop this. (We could have left it around and deprecated it, but we are already making a breaking change to tor-llcrypto by upgrading dalek-cryptography.)
* Convert to the latest versions of dalek-cryptographyNick Mathewson2023-11-291-14/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main changes that we have to adjust for are as follows: * In x25519-dalek: * `StaticSecret` is now behind a feature. * `StaticSecret::new` is deprecated in favor of `StaticSecret::random_from_rng`. * StaticSecret no longer does its own clamping. * In ed25519-dalek: * `SecretKey` has (in effect) been renamed to `SigningKey`. The name `SecretKey` is now an alias for `[u8; 32]`. * `SigningKey` is effectively a keypair, since it contains a public key as well. * `PublicKey` has been renamed to `VerifyingKey`. * The functions to extract a signing key and verifying key have been renamed as you might expect. * `ExpandedSecretKey` has been moved to `hasmat` and no longer implements `sign`. * `ExpanededSecretKey` now has as its elements a scalar and a hash prefix. * Various functions that took `&[u8]` now take `&[u8; N]`. * We no longer need a wrapper for older versions of rand. There is a single test in tor-keymgr that does not pass. I've marked it as ignore for now, in hopes that @gabi-250 can help me figure it out. This closes #808. There are several changes I want to make before we merge, however. They are marked with TODO DALEK.
* tor-hscrypto: Define Keypair conversions for all curve25519 newtypesIan Jackson2023-11-231-9/+0
| | | | | | | | | 1. Move `impl From<SpecificKeypair> for curve25519::StaticKeypair` (which was just a bespoke impl for HsClientDescEncKeypair) into the define_pk_keypair macro, so everything has it. Currently the only other user of the curve25519_pair feature is HsSvcNtorKey. 2. Provide the reverse conversion too.
* tor-hscrypto: Move HsClientIntroAuthKey to a separate module (fmt).Gabriela Moldovan2023-11-201-16/+15
|
* tor-hscrypto: Move HsClientIntroAuthKey to a separate module.Gabriela Moldovan2023-11-201-0/+13
| | | | | | | | | We need to add a module-global `#[allow(deprecated)]` to silence the deprecation warnings coming from the derived `derive_more` impls of the 2 newly deprecated structs. Since we don't want the `allow` to apply to the entire `pk` module, let's put `HsClientIntroAuthKey` and `HsClientIntroAuthKeypair` in a separate module and apply the `#[allow(deprecated)]` there.
* tor-hscrypto: Deprecate HsClientIntroAuth{Key, Keypair}.Gabriela Moldovan2023-11-201-1/+4
| | | | Part of #1037
* tor-hscrypto: Add a From<&HsIdKeypair> impl for HsIdKey.Gabriela Moldovan2023-10-191-0/+6
| | | | | | | | Sometimes it's useful to have the ability to derive the `HsIdKey` from the keypair (for example, if we've just read the `HsIdKeypair` from the keystore and also need the `HsIdKey`, this `From` impl enables us to derive the public part of the key, instead of having to read it from the keystore).
* tor-hsservice: Add HsClientDescEncKeypair.Gabriela Moldovan2023-09-251-0/+16
|
* tor-hscrypto: Reinstate HsDescSigningKey/HsDescSigningKeypair.Gabriela Moldovan2023-09-221-2/+0
| | | | We need it to sign descriptors.
* tor-hscrypto: Implement PartialEq for HsClientDescEncKey.Gabriela Moldovan2023-09-181-0/+6
| | | | Needed to implement `PartialEq` for `AuthorizedClientConfig`.
* hscrypto: Define a keypair type for HsSvcNtor{,Secret}KeyNick Mathewson2023-09-171-0/+1
| | | | | (Also, extend our macro so that we can wrap other curve25519 keys in this way, if we want.)
* tor-hscrypto: Impl From<&HsBlindIdKeypair> for HsBlindIdKey.Gabriela Moldovan2023-08-251-0/+7
| | | | This will be used by the descriptor publisher when building descriptors.
* tor-hscrypto: Add a function for deriving the subcredential.Gabriela Moldovan2023-08-251-3/+15
| | | | | | This function will be used by the descriptor publisher (it needs to generate descriptors, and for that it needs the subcredential, which can be derived from the `HsBlindIdKey` and `TimePeriod`).
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* hscrypto: downgrade a comment to HSSNick Mathewson2023-06-221-1/+1
|
* New ErrorKind for invalid onion addressesNick Mathewson2023-06-221-0/+15
| | | | Use this to emit HS_BAD_ADDRESS as appropriate.
* hscrypto: comment out an unused key type.Nick Mathewson2023-06-131-5/+6
| | | | | | | | (I'm not removing it entirely since maybe we _should_ use it, and maybe we _will_ as we do services. I've added a TODO HS for removing it or using it, and removed the TODO HS at the head of pk.rs about making sure that all the key types in the module really belong there.)
* hscrypto: Remove a TODO about extending an internal macro.Nick Mathewson2023-06-131-2/+0
|
* hscrypto: Remove a TODO about implementing ErrorKind.Nick Mathewson2023-06-131-1/+0
| | | | | | I think it isn't actually a great idea for HsIdParseError to implement ErrorKind, since the actual ErrorKind would depend entirely on where the problematic ID came from.