summaryrefslogtreecommitdiff
path: root/crates/tor-llcrypto/src/pk
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-092-0/+2
| | | | | | | | | | | | 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/+2
| | | | | | | | | | | 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-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.
* 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-022-2/+2
|
* 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-041-1/+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]>
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | 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.
* | tor-llcrypto: unconditionally use derive_deftlyhashcatHitman2025-09-231-1/+2
| | | | | | | | | | | | | | 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-231-3/+19
|/ | | | | | | | | | | | | | | | | 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: fix typotcyrus2025-07-231-1/+1
| | | | | `tor_llcrypto::pk::ed25519::PublicKey` is based on `ed25519_dalek::VerifyingKey` and not `ed25519_dalek::SigningKey`.
* llcrypto: add an rng compatibility shim for dalek-cryptoNick Mathewson2025-03-181-2/+4
| | | | | | | | | 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.
* Rename "memquota" feature to "memquota-memcost" when it's just HasMemoryCost ↵Ian Jackson2024-10-162-3/+15
| | | | (fmt)
* Rename "memquota" feature to "memquota-memcost" when it's just HasMemoryCostIan Jackson2024-10-162-7/+7
| | | | It's not documented anywhere ATM. I will do that in a followup MR.
* Some HasMemoryCost impls in tor-llcryptoIan Jackson2024-10-022-0/+11
|
* tor-llcrypto: replace simple_asn1 dependency with der_parserMorgan2024-09-281-18/+16
|
* 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
|
* llcrypto: Make `blind_keypair` build without hsv3-client.Nick Mathewson2024-08-211-2/+2
| | | | | | | | | | The `blind_keypair` function should only call `blind_pubkey` when it is present. Also, fix the documentation: blind_keypair is a hsv3-service function, not a hsv3-client function. Closes #1504.
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* clippy: consequential rustfmtIan Jackson2024-01-021-4/+1
|
* clippy: Use infallible callsIan Jackson2024-01-021-2/+1
| | | | Resolves clippy complaints about needless fallible conversions.
* Fix a rustdoc error.Nick Mathewson2023-11-291-1/+1
|
* Resolve an unfinished sentenceNick Mathewson2023-11-291-1/+2
|
* grammar fix in commentgabi-2502023-11-291-1/+1
|
* llcrypto: remove a comment suggesting a grand renaming.Nick Mathewson2023-11-291-3/+3
|
* llcrypto: Hide the members of ExpandedKeypair.Nick Mathewson2023-11-291-5/+15
| | | | | With this change, we no longer expose the ExpandedSecretKey unescorted, which makes it harder to misuse the API.
* llcrypto: Undo internal ed25519-dalek renamings in keymanip.rsNick Mathewson2023-11-291-8/+7
|
* llcrypto: Remove redundant re-exports in keymanip.Nick Mathewson2023-11-291-10/+3
| | | | (These types were all already re-exported from pk::ed25519.)
* llcrypto: Remove ExpandedSecretKey export.Nick Mathewson2023-11-292-6/+3
| | | | | | | 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.
* Deprecate convert_ed25519_to_curve25519_private as unusedNick Mathewson2023-11-291-0/+5
|
* Remove RngCompatExt.Nick Mathewson2023-11-291-4/+2
| | | | | | | | | | 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-292-134/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Resolve warnings about ambiguous/redundant doc linksNick Mathewson2023-08-221-2/+2
| | | | | Nightly rustdoc now warns if you have a link that isn't necessary, and if you have a link that might refer to two different things.
* tor-llcrypto: Add a missing instance of the standard lint blockIan Jackson2023-07-101-0/+10
| | | | This fixes a needless_vec lint on nightly.
* llcrypto: Add reference to paper about keypair reuse.Gabriela Moldovan2023-06-271-0/+2
|
* llcrypto: Remove `# Availability` doc sections.Gabriela Moldovan2023-06-271-8/+0
| | | | | | | | | | This removes the `# Availability` section from the `convert_ed25519_to_curve25519_private` and `convert_curve25519_to_ed25519_private` docs. We don't generally have this sort of section anywhere else in the codebase (we use unstable cargo-docs features to make sure items are annotated correctly).
* llcrypto: Add cvt-x25519 feature flag for exporting key conversion functions.Gabriela Moldovan2023-06-271-4/+4
| | | | | | The `convert_curve25519_to_ed25519_private` and `convert_ed25519_to_curve25519_private` functions are now exported by `tor-llcrypto` if the `cvt-25519` feature is enabled.