summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/crypto
Commit message (Collapse)AuthorAgeFilesLines
* tor-proto: use RelayCellFormat rather than u8 in tests.Nick Mathewson2025-04-291-14/+14
| | | | (The u8 code was written before RelayCellFormat::V1 was introduced.)
* Rename feature cgo => counter-galois-onion.Nick Mathewson2025-04-291-3/+3
|
* CGO: Fix authenticated-sendme tag handling.Nick Mathewson2025-04-291-5/+20
| | | | | | See discussion at torspec#328: it's important that our SENDME authentication tag always be taken based on the _encrypted_ cell.
* CGO: Note another possible performance improvement.Nick Mathewson2025-04-291-0/+3
|
* proto: Implement and test CGO cryptography.Nick Mathewson2025-04-292-13/+316
| | | | | | | | This provides all the operations from proposal 359, along with the necessary integration and unit tests to make sure that they are behaving properly. Closes #1943
* proto: Implement UIV+, the wide-block RPRP used for CGO.Nick Mathewson2025-04-291-1/+174
|
* proto: Implement CGO functions ET and PRFNick Mathewson2025-04-291-3/+321
| | | | | | | These are a tweakable block cipher, and a pseudorandom byte stream. This commit includes test vectors, which were generated from the Python reference implementation and confirmed with a less optimized Rust implementation.
* New empty CGO module.Nick Mathewson2025-04-291-0/+23
|
* proto: Unified integration tests for relay crypto.Nick Mathewson2025-04-291-3/+210
|
* proto: Make relay-side cell crypto traits return tags.Nick Mathewson2025-04-292-15/+20
| | | | | | (We'll need these tags both to implement authenticated SENDMES at the relay side, and also to make sure that cgo is generating them correctly.)
* proto: Make crypt layers take a ChanCmd argumentNick Mathewson2025-04-293-42/+52
| | | | | | CGO will need this argument so that it can authenticate the command as part of its crypto operations. (Trying to meddle with RELAY vs RELAY_EARLY will no longer work!)
* proto: refactor RelayCrypt trait into separate traitsNick Mathewson2025-04-293-19/+78
| | | | | | It seems very likely that, as with client crypto, we'll want relay crypto to separable into "forward" and "reverse" objects, so that the two can be used more or less independently.
* proto: Tweak semantics of RelayCrypt::originate.Nick Mathewson2025-04-293-3/+5
| | | | | | | | | | This makes the behavior of "originate" match the behavior of OutboundClientLayer::originate_for, which creates the message _and_ encrypts it. This will be necessary for CGO, where "originate" and "encrypt" are not easily separated operations. (Nothing uses this trait yet, since relay circuits aren't yet a thing, so it's a good time to get it right.)
* proto: move tor1 testvector test into tor1 module.Nick Mathewson2025-04-292-54/+79
|
* proto: Clean up imports in tor1.rs.Nick Mathewson2025-04-292-6/+8
|
* proto: Move tor1 relay crypto to a separate file.Nick Mathewson2025-04-292-312/+312
| | | | | | | Since we're about to have a second kind of relay cell crypto, it makes sense to move this module. This change is pure code movement.
* Note some places where we need updates for #1944.Nick Mathewson2025-04-161-0/+5
| | | | (Also note a couple of other CGO-related issues)
* tor-proto: removed "ntor_v3" feature flagSteven Engler2025-04-011-1/+0
| | | | ntor v3 is now always enabled.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-4/+0
| | | | - `try_fill_bytes()` is no longer a member of RngCore.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-3/+3
| | | | - `rand::thread_rng()` has been deprecated and renamed to `rand::rng()`
* tor-proto: Split out send_relay_cell().Gabriela Moldovan2025-01-281-1/+1
|
* tor-proto: put every bench_utils mod behind the bench featureLionel Goffaux2024-11-062-3/+2
|
* tor-proto: change the visibility of the RelayBody inner structLionel Goffaux2024-11-061-1/+1
|
* tor-proto: remove inlines attributesLionel Goffaux2024-11-062-4/+0
|
* tor-proto: Add benchmarks for cell encryption and decryptionLionel Goffaux2024-11-042-0/+175
|
* Some HasMemoryCost impls in tor-protoIan Jackson2024-10-021-1/+4
|
* tor-proto: Use Reader::take_all_but().Nick Mathewson2024-09-161-8/+1
|
* tor-bytes: Error: provide and call Error::incomplete_errorIan Jackson2024-09-111-1/+1
| | | | | | | | | | | | | | | | | | | We introduce the new constructor and call it at the error generation sites. But there is still not yet any functional change. Change the type of Truncated's field to be Sensitive. The original reason for not doing this no longer applies, since we don't generally want to open-code construction of this variant. Conveniently, changing the type means we get to find all the sites where one *is* constructed and adjust them. In reader.rs and tor-proto we can just call incomplete_error. In tor-cell, there's a call site where we previously provided an underestimate, and where the Reader isn't available. We adjust that ad-hoc but this is fine because the error variant will change. (relaycell is using a Reader from from_slice.)
* tor-bytes: Add a deficit field to Error::Truncated (fmt)Ian Jackson2024-09-101-1/+3
|
* tor-bytes: Add a deficit field to Error::TruncatedIan Jackson2024-09-101-1/+2
| | | | This will allow us to fix #1592, but it doesn't do so yet.
* Add allows for many dead code warnings in tor-protoIan Jackson2024-07-082-0/+5
| | | | | | | I'm not sure how to resolve these. See #1467. We ought to fix them before they propagate to +stable, particularly since after !2242 they'll break CI.
* Add temporary allows for some dead code warningsIan Jackson2024-04-252-0/+2
|
* Use uXX::MAX in place of std::uXX::MAXNick Mathewson2024-04-221-2/+2
| | | | | | The old code produced a warning from clippy nightly; we may as well update to use the new associated consts. (They've been there since Rust 1.4x.)
* proto: Simplify a check-and-convert to use try_into+expectNick Mathewson2024-04-221-2/+2
|
* Add and use RelayCellFormatTraitJim Newsome2024-03-201-84/+79
| | | | | | This lets us paramaterize types and functions by a particular relay cell format. We use this e.g. to statically parameterize the cell crypto functions, thereby removing some run-time branching in the hot path.
* Propagate RelayCellFormat selection up to where format decisions will be madeJim Newsome2024-03-201-12/+24
|
* Paramaterize layer crypto objects by cell formatJim Newsome2024-03-201-22/+38
|
* RelayCellBody: generalize over RelayCellFormatJim Newsome2024-03-201-13/+31
| | | | | Different formats will use different ranges for the `recognized` and `digest` fields.
* RelayCellBody::is_recognized: improve doc commentNick Mathewson2024-03-201-1/+7
|
* RelayCellFormat::recognized -> is_recognizedJim Newsome2024-03-201-3/+3
|
* Run maint/add_warning.Nick Mathewson2024-03-135-0/+5
|
* clippy: consequential rustfmtIan Jackson2024-01-021-8/+2
|
* clippy: Use infallible callsIan Jackson2024-01-021-4/+2
| | | | Resolves clippy complaints about needless fallible conversions.
* NtorV3Extension set encoding/decoding: include n_extensionsJim Newsome2023-12-071-3/+3
| | | | | | | | | | An encoded set of extensions in the ntorv3 handshake includes a header with the number of extensions. This change adds that header. It also changes `write_many_onto` to take a slice instead of an iterator, since we need to know the number of extensions up-front. In principle we could take a clonable iterator instead and use Iterator::count, but it's probably not worth the extra complexity.
* Remove RngCompatExt.Nick Mathewson2023-11-292-7/+6
| | | | | | | | | | 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-293-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add NtorV3SecretKey::generate_for_test and NtorV3SecretKey::newJim Newsome2023-11-271-39/+36
|
* NtorV3PublicKey: make fields pub(crate), as for NtorPublicKeyJim Newsome2023-11-271-2/+2
|
* tor-proto: make ClientHandShake and ServerHandshake generic over aux dataJim Newsome2023-11-154-138/+92
|
* Add NtorV3Server and implement ServerHandshake for itJim Newsome2023-11-151-29/+43
|