summaryrefslogtreecommitdiff
path: root/crates/tor-llcrypto/src
Commit message (Collapse)AuthorAgeFilesLines
* tor-llcrypto: Implement Ed25519PublicKey for ExpandedKeypairClara Engler2026-06-251-0/+6
| | | | | ExpandedKeypair already implements Ed25519SigningKey, so there is no reason to not implement Ed25519PublicKey on it.
* hscrypto, linkspec, llcrypto: Use new redaction helpersNick Mathewson2026-06-101-6/+2
| | | | 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-095-0/+5
| | | | | | | | | | | | 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-126-47/+68
| | | | | | | | | | | 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.
* hsservice, llcrypto, SecurityResponse: use cfg({true,false})Nick Mathewson2026-05-071-2/+2
|
* tor-llcrypto: Fix a derive to unconditionally DeftlyIan Jackson2026-04-281-6/+2
| | | | | It is harmless to derive Deftly without doing more. Do that, rather than cfg'ing the use of derive_deftly::Deftly.
* tor-llcrypto: Add RsaIdentity::to_bytes()Clara Engler2026-04-231-0/+5
| | | | | | | | | | This commit adds .to_bytes() to RsaIdentity which is similar to .as_bytes() except that it returns the RsaIdentity as a byte array. We are going to need this at a few places in tor-dirserver. The naming was inspired from x25519-dalek which has similar .as_bytes() and .to_bytes() methods. Besides, copying 20 bytes shall be okay and it avoids having to write ugly try_into() constructs.
* 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.
* tor-llcrypto: add `Ed25519Identity::from_base64()`Steven Engler2026-02-101-0/+42
| | | | | | | | This is intended to be analogous to `RsaIdentity::from_hex()`. I've found myself wanting this a few times, and it makes it easy to grab a `master-key-ed25519` from the consensus and paste it into the code without needing to do extra conversions.
* llcrypto: Depend on tor-memquota-cost, not tor-memquota.Nick Mathewson2026-02-023-3/+3
|
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* tor-llcrypto: Add `RsaIdentity::as_hex_upper`Clara Engler2026-01-151-0/+6
| | | | | | | | | | This commit adds the method `as_hex_upper(&self) -> String` to `RsaIdentity`, which returns the `RsaIdentity` as a hexadecimal string in uppercase. Although this type already implements `ToString`, this result is unsuitable for working with consensuses because they neither contain a `$` prefix, nor are encoded in lowercase.
* Remove unnecessary `doc(cfg(...))` attributesNeel Chauhan2025-12-042-2/+0
| | | | | | | | | Fixes part of #2193. (Edits from nickm: I selected the cases here that I could verify were correct from immediate context.) Edited-by: Nick Mathewson <[email protected]>
* Merge branch 'bug2172' into 'main'Nick Mathewson2025-11-241-1/+1
|\ | | | | | | | | | | | | tor-llcrypto: Stop deriving Deref in CtByteArray Closes #2172 See merge request tpo/core/arti!3432
| * tor-llcrypto: Stop deriving Deref in CtByteArrayNeel Chauhan2025-11-241-1/+1
| |
* | Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-064-4/+4
|/ | | | Run maint/add_warning
* Lay foundations for RSA keys in keystore.Wesley Aptekar-Cassels2025-09-301-0/+14
| | | | | | This currently can't be used due to upstream limitations in the ssh_key crate, which will be removed likely in the next release. In the meantime, we can put in all the groundwork.
* Merge branch 'tor-keyforge-rsa-types' into 'main'wesleyac2025-09-301-6/+50
|\ | | | | | | | | tor-key-forge: Add RSA key types. See merge request tpo/core/arti!3236
| * tor-llcrypto: Add more comments about implementation of RSA sign function.Wesley Aptekar-Cassels2025-09-101-2/+3
| |
| * tor-llcrypto: Add note about key size to RSA KeyPair::generate.Wesley Aptekar-Cassels2025-09-101-0/+4
| |
| * tor-llcrypto: Rename rsa::PrivateKey to rsa::KeyPair.Wesley Aptekar-Cassels2025-09-081-5/+5
| | | | | | | | As discussed with gabi on IRC today.
| * tor-key-forge: Add RSA key types.Wesley Aptekar-Cassels2025-09-081-3/+42
| | | | | | | | | | | | | | Some things I'm still considering here: * We may want to define a tor_llcrypto::pk::rsa::Signature newtype. * We likely want to rename tor_llcrypto::pk::rsa::PrivateKey to RsaKeypair.
* | 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-(hs|ll)crypto: export cteq macros correctlyhashcatHitman2025-09-232-10/+13
| | | | | | | | | | | | | | | | | | | | 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-llcrypto: unconditionally use derive_deftlyhashcatHitman2025-09-232-5/+4
| | | | | | | | | | | | | | I didn't even realize I was still conditionally using it on a feature. That's what I get for always testing with all-features. Signed-off-by: hashcatHitman <[email protected]>
* | tor-(hs|ll)crypto: deftly derive ConstantTimeEqhashcatHitman2025-09-233-5/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-llcrypto: as_bytes on curve25519::StaticSecrethashcatHitman2025-09-161-0/+4
|/ | | | | | | Exposed `as_bytes` on `curve25519::StaticSecret`, allowing a shared reference to the secret bytes rather than needing to copy them. Signed-off-by: hashcatHitman <[email protected]>
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-073-5/+14
| | | | | | | | | | | | | | 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-llcrypto: fix typotcyrus2025-07-231-1/+1
| | | | | `tor_llcrypto::pk::ed25519::PublicKey` is based on `ed25519_dalek::VerifyingKey` and not `ed25519_dalek::SigningKey`.
* Temporarily suppress mismatched_lifetime_syntaxes.Gabriela Moldovan2025-07-071-0/+1
| | | | See #2060.
* tor-llcrypto: Removed dependency on `once_cell`hashcatHitman2025-06-141-2/+2
| | | | | | - Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`. Signed-off-by: hashcatHitman <[email protected]>
* tor-llcrypto: fix feature name typoSteven Engler2025-06-091-1/+1
|
* llcrypto: Document some design choices from CautiousRng.Nick Mathewson2025-03-241-1/+12
|
* Use an EntropicRng trait to enforce key generation rules.Nick Mathewson2025-03-241-1/+44
| | | | | | | | | | | 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.
* Use CautiousRng for keys going into the KeyMgr.Nick Mathewson2025-03-241-0/+16
|
* llcrypto: new CautiousRng for constructing long-lived keysNick Mathewson2025-03-242-0/+143
| | | | | | This Rng combines inputs from several sources, including OsRng, to minimize the likelihood of falling to a vulnerability in any particular one.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-1/+1
| | | | - The Rng::gen() functions have been renamed to Rng::random().
* llcrypto: add an rng compatibility shim for dalek-cryptoNick Mathewson2025-03-184-4/+53
| | | | | | | | | dalek-cryptography is still on rand 0.8, so we need a compatibility shim for the Rng. Fortunately, since we merged interface-abstraction-of-the-daleks (!2868), we no longer need to propagate this compatibility layer throughout our codebase.
* Wrap ed25519-dalek types.Nick Mathewson2025-03-182-31/+155
| | | | | | | | | | | 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.
* Wrap x25519-dalek types.Nick Mathewson2025-03-171-10/+103
| | | | | | | 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 curve25519 implementations, or to upgrade to a newer `rand` ahead of their schedule.
* 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
* 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.
* Rename "memquota" feature to "memquota-memcost" when it's just HasMemoryCost ↵Ian Jackson2024-10-163-4/+20
| | | | (fmt)
* Rename "memquota" feature to "memquota-memcost" when it's just HasMemoryCostIan Jackson2024-10-163-9/+9
| | | | It's not documented anywhere ATM. I will do that in a followup MR.
* Some HasMemoryCost impls in tor-llcryptoIan Jackson2024-10-023-0/+15
|
* tor-llcrypto: replace simple_asn1 dependency with der_parserMorgan2024-09-282-37/+31
|
* 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
* keymanip: Make blind_pubkey exist unconditionallyNick Mathewson2024-08-211-4/+4
| | | | | | | | | Now it exists unconditionally so that we can have our assertion for public key consistency happen unconditionally. (Blinding secret keys is not remotely in the critical path, so I'm not concerned about the critical path.) From a suggestion from Gabi on !2341.
* keymanip: Use doc(cfg(...)) in place of "Availability" sectionsNick Mathewson2024-08-211-8/+2
|