summaryrefslogtreecommitdiff
path: root/crates/tor-hscrypto/src
Commit message (Collapse)AuthorAgeFilesLines
* 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-094-0/+4
| | | | | | | | | | | | 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.
* Upgrade rand crates to 0.10.Wesley Aptekar-Cassels2026-05-122-2/+4
| | | | | | | | | | | When the circ-padding feature is enabled, we use maybenot, which does not yet support rand 0.10. In the meantime, enabling this feature pulls in rand 0.9. This is not ideal, but should be okay as a temporary situation. This also replaces the use of ReseedingRng (which was removed in 0.10) with the reseeding_rng crate. This is somewhat less performant, but it should be okay.
* tor-hcrypto: Port to web-time-compatNick Mathewson2026-03-262-6/+4
|
* Allow clippy::collapsible_if to triggerGabriela Moldovan2026-02-161-0/+1
| | | | | | | | | `clippy::collapsible_if` started triggering after bumping the MSRV to 1.88. Since this triggers from a lot of places, and since there even are a couple of instances where we explicitly allow `clippy::collapsible_ifs`, I've opened #2342 for deciding what to do about it.
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-064-4/+4
| | | | Run maint/add_warning
* Remove "doc_auto_cfg" incantation from all crates.Nick Mathewson2025-09-291-1/+1
| | | | This feature has been removed from nightly, in favor of doc_cfg.
* 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-232-64/+9
| | | | | | | | | | 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-232-290/+120
| | | | | | | | | | | | | | | | | 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 ```
* tor-hsservice: Add disable_pow_compilation option.Wesley Aptekar-Cassels2025-08-131-0/+5
| | | | | | I'm not 100% on this being here, it seems like it might want to be a option for all onion services, rather than per-service. However, this is good enough for now.
* Fix warnings and errors from edition 2024.Nick Mathewson2025-08-071-3/+2
| | | | | | | | | | The two main causes of errors were: - Since some of the lifetime rules have changed, we no longer need to do as many "bind a variable and immediately return it" patterns, and so clippy now warns about them. - We needed to adjust the explicit captures (`use<...>`) in a couple of our RPIT instances.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-073-7/+7
| | | | | | | | | | | | | | 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.
* tor-hsservice: Persist suggested_effort.Wesley Aptekar-Cassels2025-08-051-0/+1
|
* Use new DisplayRedacted/DebugRedacted code for HsId.Nick Mathewson2025-07-311-28/+22
| | | | Closes #2012.
* tor-hscrypto: fix typostcyrus2025-07-232-3/+3
|
* Typo fixes (automatic and hand-verified)Nick Mathewson2025-07-091-1/+1
| | | | Made with https://crates.io/crates/typos-cli
* Temporarily suppress mismatched_lifetime_syntaxes.Gabriela Moldovan2025-07-071-0/+1
| | | | See #2060.
* tor-hsservice: Make PowManager persist state.Wesley Aptekar-Cassels2025-05-272-2/+7
|
* tor-hscrypto: Implement Display and FromStr for Seed.Wesley Aptekar-Cassels2025-05-271-0/+28
| | | | | This is convenient for formatting filenames for the PoW nonce replay log.
* tor-hsservice: Initial parts of PowManager.Wesley Aptekar-Cassels2025-05-272-2/+2
| | | | | | | This adds PowManager, as described in doc/dev/notes/service-side-pow.md, hooks it into IptManager and Publisher, and adds code to publish and rotate seeds, and to keep a updated list of Verifier instances for currently active seeds.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-183-4/+4
| | | | - The Rng::gen() functions have been renamed to Rng::random().
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - The Standard distribution has been renamed to StandardUniform.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - The rand::distributions module has been renamed to rand::distr
* 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: Implement Display for TimePeriodhjrgrn2025-03-131-1/+24
|
* clippy: deny `mod_module_files`Steven Engler2025-01-061-0/+1
| | | | | | Denies 'mod.rs' files for consistency. https://rust-lang.github.io/rust-clippy/master/index.html#mod_module_files
* 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
* add_warnings, *: Allow clippy::needless_lifetimesNick Mathewson2024-12-031-0/+1
| | | | | | | | In 1.83, this warning triggers on many of our crates. We're thinking of fixing them all, but for now, we're going to disable the warning. This is part of #1765.
* PoW: Consolidate feature flags into a single flag.Wesley Aptekar-Cassels2024-11-251-5/+1
| | | | | | | | | | | | | | | | | This replaces the hs-pow, hs-pow-full, hs-pow-v1, pow-v1, and pow-full features with a single hs-pow-full feature. It's possible that in the future we will want to split different schemes into different features, but we can do that when it comes up. For now, having this as a single flag makes it clearer what's going on, since the previous thing was not actually expressive enough to capture some things we care about (like "at least one pow scheme is enabled" that works in a future-compatible way). This change is not semver breaking since it's a experimental feature. Related: #1751
* tor-hscrypto: Add Verifier::seed() helper function.Wesley Aptekar-Cassels2024-11-251-0/+7
|
* tor-hscrypto: Add Seed::new.Wesley Aptekar-Cassels2024-11-251-0/+43
| | | | | This includes the ability to generate a seed that does not share a head with the previously used seed, which is generally what we want to do.
* tor-netdoc: Support writing pow-params line.Wesley Aptekar-Cassels2024-11-251-1/+1
| | | | | | | I'm not particularly happy with the code that does the actual writing out of the pow-params line, in particular the error handling there seems very verbose. However, I don't know of a better way to structure it given that APIs I'm working with.
* 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
* Rename "memquota" feature to "memquota-memcost" when it's just HasMemoryCostIan Jackson2024-10-161-2/+2
| | | | It's not documented anywhere ATM. I will do that in a followup MR.
* hs-pow: Effort type improvements.Wesley Aptekar-Cassels2024-10-091-1/+35
| | | | | | | | The Effort type didn't have any const constructor and we had to disassemble it to do any arithmetic. This adds a const constructor and int/float saturating arithmetic methods. Co-authored-by: Micah Elizabeth Scott <[email protected]>
* tor-hscrypto: Fixup broken doc links.Wesley Aptekar-Cassels2024-10-093-4/+4
| | | | Co-authored-by: Micah Elizabeth Scott <[email protected]>
* hs-pow: Refactor to prefer stub types rather than cfg sprawl.Wesley Aptekar-Cassels2024-10-094-9/+17
| | | | | | | | | | | | | | | | | | | | | | In this design, the thin multiplexing layer between PoW types is always available when onion services are in use, but the specific pow schemes (and their dependency libraries) are gated by crate features everywhere. There are now no new cfg() gates. When the pow-v1 scheme is disabled, we can parse `pow-params v1` lines into an empty type (so clients know a PoW scheme exists that might be supported if they were configured differently). We currently don't save the contents of unknown hsdesc items. On the relaycell side, the hs ext module already sets a strong precedent for keeping unrecognized data as a byte vec, and it doesn't provide a good way to signal soft parse errors like unrecognized optional extensions. There, the `v1` type is completely optional, and services lacking a pow scheme suggested by a client would see one of these 'unrecognized' blobs. This isn't necessarily helpful but it fits the rest of the design. Co-authored-by: Micah Elizabeth Scott <[email protected]>
* tor-hspow: Big refactor, dissolve this crateWesley Aptekar-Cassels2024-10-099-0/+663
| | | | | | | | | | | | | | | | | My previous strategy here was to try and centralize hspow in one crate, writing it like a self-contained feature. That introduced friction in the data types, prompting the use of simplistic types at the netdoc/cell layers and full-featured types in the optional modules. This changes tactics, dissolving the low-level parts of tor-hspow into tor-hscrypto and the high-level parts into hsclient/hsservice. Full featured types are used everywhere now, but the tradeoff is that compile-time configurability is a lot more pervasive. Anything that knows about PoW types at all needs to be fully configured out. I took this opportunity to try a more complete set of crate features, allowing users to configure individual PoW schemes. Co-authored-by: Micah Elizabeth Scott <[email protected]>
* tor-hscrypto: Use the new "restricted discovery" terminology.Gabriela Moldovan2024-10-031-1/+1
| | | | Part of #1476
* Some HasMemoryCost impls in tor-hscryptoIan Jackson2024-10-021-0/+8
|
* 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