aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/crypto/cell.rs
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Upgrade rand crates to 0.10.Wesley Aptekar-Cassels2026-05-121-1/+1
| | | | | | | | | | | 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.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* proto: Fix typo in OutboundRelayLayer docs.Gabriela Moldovan2025-10-081-1/+1
| | | | | `OutboundRelayLayer::decrypt_outbound()` is for decrypting cells moving *away* from the client (in the "forward direction").
* proto: Consider the channel queue with "Replace" padding to hop 1.Nick Mathewson2025-09-161-0/+5
| | | | | | | | | When we want to send Replace padding (that is, padding that should only be sent if nothing else is queued) to hop 1, we can allow it to be replaced by cells from _any_ circuit being sent over the same channel. (Nobody but hop 1 can tell the difference.) Closes #2169
* proto: derive Ord for HopNum.Nick Mathewson2025-09-101-1/+1
|
* 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.
* proto: Construct CGO instances if that is what is selected.Nick Mathewson2025-07-231-0/+8
|
* proto: remove bench pub wrappersLionel Goffaux2025-05-221-0/+14
|
* proto: extend benchmarksLionel Goffaux2025-05-081-0/+2
|
* proto: Apply type-specific wrappers for tor1 cryptoNick Mathewson2025-05-061-10/+16
| | | | | | | | | | | | | Now instead of using CryptState for everything, we have specific types for each role and direction of crypto. This turned up a harmless-so-far bug in our onion service code: as an onion service, we were using _client_ crypto layers to respond to a client request. That's not correct, and wouldn't have worked with CGO. Instead, we need to use relay crypto layers, wrapped as client layers. Closes #1975.
* proto, cell: Remove RelayCellFormatTrait.Nick Mathewson2025-05-061-18/+15
| | | | | | | | | | | | | | | | The purpose of the trait was to parameterize the tor1 cell crypto on the different possible relay cell layouts. It made sense to have this trait when we thought we would implement the new cell layout for prop340 (packed-and-fragmented) well before we implemented CGO. But it now appears all but certain that CGO will land long before we make any more headway on prop340. Therefore, it doesn't make sense to carry the ability to customize `tor1` for other relay cell layouts. Removing this trait saves a fair bit of complexity.
* Emit SendmeTag directly from cell crypto.Nick Mathewson2025-05-061-13/+12
| | | | | | | | | | | | | | | | | | | | This changes the code to copy a SendmeTag rather than returning a slice. This isn't actually a big change: sending a slice already required 16 bytes (on 64-bit platforms), so sending a SendmeTag around isn't a big deal. We rely extensively on the compiler's ability to optimize away all the checking in code like this: ``` let slice: &[u8]; let a: [u8;N] = slice[0..N].try_into().expect("Nope"); ``` I've spot-checked it somewhat with "cargo-show-asm", but it could use more thorough checking. Closes #1956.
* proto: Split out CGO BlkCipher trait for Encryption/DecryptionNick Mathewson2025-05-061-2/+12
| | | | | | This lets us use `Aes128Dec` and `Aes128Enc` in place of plain old `Aes128`, which can be less space-efficient depending on the back-end.
* 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
|
* proto: Implement and test CGO cryptography.Nick Mathewson2025-04-291-0/+5
| | | | | | | | 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: Unified integration tests for relay crypto.Nick Mathewson2025-04-291-3/+210
|
* proto: Make relay-side cell crypto traits return tags.Nick Mathewson2025-04-291-6/+8
| | | | | | (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-291-21/+27
| | | | | | 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-291-5/+24
| | | | | | 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-291-2/+2
| | | | | | | | | | 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-291-54/+1
|
* proto: Clean up imports in tor1.rs.Nick Mathewson2025-04-291-3/+0
|
* proto: Move tor1 relay crypto to a separate file.Nick Mathewson2025-04-291-312/+2
| | | | | | | 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: Split out send_relay_cell().Gabriela Moldovan2025-01-281-1/+1
|
* tor-proto: put every bench_utils mod behind the bench featureLionel Goffaux2024-11-061-0/+1
|
* tor-proto: change the visibility of the RelayBody inner structLionel Goffaux2024-11-061-1/+1
|
* tor-proto: remove inlines attributesLionel Goffaux2024-11-061-2/+0
|
* tor-proto: Add benchmarks for cell encryption and decryptionLionel Goffaux2024-11-041-0/+38
|
* Some HasMemoryCost impls in tor-protoIan Jackson2024-10-021-1/+4
|
* Add temporary allows for some dead code warningsIan Jackson2024-04-251-0/+1
|
* 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-131-0/+1
|
* clippy: consequential rustfmtIan Jackson2024-01-021-8/+2
|
* clippy: Use infallible callsIan Jackson2024-01-021-4/+2
| | | | Resolves clippy complaints about needless fallible conversions.
* tor-proto: Refactor the key derivationEmil Engler2023-09-291-15/+31
| | | | | | | | | | | | This commit refactors the key derivation, by applying the following: - The spaghetti slice creation with the hard-to-read boundaries got replaced by a closure, which accepts a length, advances the seed slice by n bytes as a side-effect, and returns the just advanced bytes - The use of `.except` got replaced by an `.or`, with the use of the already existing `InvalidKDFOutputLength` error, thereby removing a potential panic (probably not reachable in runtime though) - The conversion from a slice to a `CircuitBinding` got moved into a `TryFrom` trait of the appropriate data structure
* Merge branch 'misc-upgrades' into 'main'Nick Mathewson2023-09-281-1/+1
|\ | | | | | | | | Upgrade several dependencies See merge request tpo/core/arti!1626
| * Remove direct dependency on generic-arrayNick Mathewson2023-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | Instead of tying ourselves to a particular version of the generic-array crate, we now always use the version re-exported by our RustCrypto crates. This lets us avoid the possibility of version mismatch. (Originally I had planned to upgrade to generic-array 1.0, but then I found that we were not actually using it.)
* | tor-proto: Replace repeating pattern with fillEmil Engler2023-09-281-6/+2
|/ | | | | | | | | This commit replaces a repeating code pattern in the `set_digest` function for setting the 'Recognized' and Digest field to zero with a slice fillment. Besides this, it also adds comments explaining which fields are currently getting zeroized.
* tor-proto: Remove the Display impl of HopNum.Gabriela Moldovan2023-08-251-6/+0
| | | | | This removes the `Display` impl of `HopNum` and replaces its usage with `HopNum::display`.
* tor-proto: Add a HopNum::display function.Gabriela Moldovan2023-08-251-3/+39
| | | | | | | | | This function can be used to display a more user-friendly representation of a `HopNum`. This will print hop numbers as 1-indexed values: #1, #2, etc.. We will soon remove HopNum's Display implementation in favour of `.display()`.