summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/crypto
Commit message (Collapse)AuthorAgeFilesLines
* Precisely cfg-decorate a constantIan Jackson2023-10-311-0/+1
| | | | | | | | | | Peraonally I would prefer | #![cfg_attr(not(all(feature = "full", feature = "experimental")), | allow(dead_code))] but I think that is almost certainly controversial. See tpo/core/arti#704.
* Merge branch 'todos_proto' into 'main'Nick Mathewson2023-10-121-80/+37
|\ | | | | | | | | tor-proto: Resolve a few TODO HSS entries. See merge request tpo/core/arti!1658
| * Remove the (fairly bogus) HsNtorServiceInput type.Nick Mathewson2023-10-121-80/+37
| | | | | | | | This will let avoid some copying inside our HSS code.
* | tor-proto: Add a FIXME about an allowIan Jackson2023-10-121-0/+2
|/
* Merge branch 'refactor-kdf' into 'main'Nick Mathewson2023-10-032-15/+42
|\ | | | | | | | | tor-proto: Refactor the key derivation See merge request tpo/core/arti!1629
| * tor-proto: Refactor the key derivationEmil Engler2023-09-292-15/+42
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | tor-proto: Fix clippy warning.Gabriela Moldovan2023-10-031-1/+1
|/
* Merge branch 'misc-upgrades' into 'main'Nick Mathewson2023-09-283-6/+4
|\ | | | | | | | | Upgrade several dependencies See merge request tpo/core/arti!1626
| * Remove direct dependency on generic-arrayNick Mathewson2023-09-283-6/+4
| | | | | | | | | | | | | | | | | | | | 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.
* Merge branch 'pad_intro2' into 'main'Nick Mathewson2023-09-251-7/+41
|\ | | | | | | | | | | | | Accept and transmit padding in introduce2 plaintexts Closes #1031 See merge request tpo/core/arti!1602
| * Generate padding in Introduce1 messages.Nick Mathewson2023-09-181-7/+41
| | | | | | | | | | | | Closes #1031. This padding ensures that the introduction point doesn't learn the length of the plaintext being sent to the onion service.
* | hs_ntor: replace "32" with a const.Nick Mathewson2023-09-211-1/+1
| |
* | hs_ntor: rename get_{introduce,rendezvous}1_key_material.Nick Mathewson2023-09-211-6/+6
| |
* | hs_ntor: improve several comments.Nick Mathewson2023-09-211-3/+10
| |
* | hs_ntor: rename enc_key to dec_key in service code.Nick Mathewson2023-09-211-5/+5
| |
* | hs_ntor: allow attempting handshake with a set of subcredentials.Nick Mathewson2023-09-201-27/+45
| | | | | | | | | | | | | | Since we are using the same introduction point circuits for multiple time periods, we need the ability to provide a set of subcredentials and see which of them acually works. Fortunately, we "only" have to do digest operations here, which are much faster than public key.
* | hs_ntor: Take our k_hss_ntor keypair explicitly.Nick Mathewson2023-09-201-18/+18
|/
* tor-proto: Add a missing cfgIan Jackson2023-09-131-0/+1
| | | | | Fixes cargo clippy -p tor-hsclient --all-features --all-targets
* 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()`.
* tor-proto: Make HopNum indices appear 1-based in the Display impl.Gabriela Moldovan2023-08-251-1/+4
| | | | | | | | | | This makes `HopNum`s display as 1-indexed values. This will make error messages more intuitive, because when talking about an N-hop circuit, we generally speak in terms of hops 1..N (rather than 0..N-1). Internally, our `HopNum` indices are still 0-based. Closes #996
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-235-0/+5
|
* proto: API to expose the `CircuitBinding` type.Nick Mathewson2023-08-141-2/+1
| | | | Closes #993
* proto: Add (not-yet-exposed) code to remember and use KH valuesNick Mathewson2023-08-142-13/+78
| | | | | | | | These values are computed as part of the circuit extension handshake, and are used as MAC keys to bind `ESTABLISH_INTRO` messages to a particular circuit so that they can't be replayed. Part of #993.
* tor-proto: Make HopNum public.Gabriela Moldovan2023-08-041-1/+1
| | | | | | `HopNum` will be used in `ClientCirc`'s public API when we refactor `ClientCirc::start_conversation_last_hop` to use the provided hop rather than always using the last one.
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-105-0/+5
|
* Back down x25519-dalek to 2.0.0-pre.1 from 2.0.0-rc.2pinkforest2023-06-273-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ========================= Notes from nickm: (This differs from pinkforest's original MR: It removes the Cargo.lock changes and the version bump on tor-llcrypto.) Minimal Cargo.lock changes from downgrade. (These are exactly those changes generated by running "build" and "test".) There are several reasons to do this: * It's best to bump all of our dalek dependencies at once to rc.3 or later, rather than the piecemeal approach we've been stuck with so far. * We don't want to do this bump right now, since there are some tricky questions about clamping we need to figure out (see #808), and we need to make sure we get them right, and we're in a distracted this week. * We _do_ need to move away from 2.0.0-rc.2 right now, since it was causing a failure in `cargo install arti`, and then it got yanked. Thanks to pinkforest for helping us out here and explaining all of this! Fixes #926. Commit-edited-by: Nick Mathewson <[email protected]>
* proto: Put client and service hs_ntor behind individual featuresNick Mathewson2023-06-211-5/+17
| | | | | This lets us keep the service-side hs-ntor handshake experiemental for now.
* proto: Resolve some hs_ntor "TODO HS" comments.Nick Mathewson2023-06-211-10/+7
|
* Lower tor-proto::util::ct::lookup to tor-llcryptoNick Mathewson2023-06-162-3/+4
| | | | | | | | This is mostly code movement; you may want to review it with `--color-moved`. I'm doing this so we can also use the function in netdoc for looking up hsdesc authentication.
* proto: Make sure that auth tags are truncated to 20 bytesNick Mathewson2023-06-131-3/+13
| | | | | | | | Onion service hops (pointlessly) use SHA3-256 for their authentication, but they truncate it to 20 bytes (assuming I'm reading the C right.) See torspec#204 for clarification here.
* proto: Add a commment about a problem in my hs_ntor plans.Nick Mathewson2023-06-121-0/+4
| | | | | I am pretty sure that C tor works around this somehow; we should figure out how!
* proto: code movement and reindentation in hs_ntorNick Mathewson2023-06-121-86/+75
|
* proto: Remove now-unused hs_ntor APIsNick Mathewson2023-06-121-43/+21
|
* proto: refactor hs_ntor to reuse state.Nick Mathewson2023-06-121-14/+49
| | | | | | | | | | We want the ability to send the same handshake request in parallel on multiple introduce circuits. This implies encoding the client handshake more than once. (Sadly we can't _actually_ do this in the protocol as it stands, since the onion service can use a separate KP_hss_ntor for each introduction point; I'll add a comment to that effect later.)
* tor-proto: Remove use of arrayref.Nick Mathewson2023-06-011-2/+5
|
* Merge branch 'virtual_hop' into 'main'Nick Mathewson2023-05-181-24/+93
|\ | | | | | | | | | | | | tor-proto: Add support for extending circuits through virtual hops. Closes #726 See merge request tpo/core/arti!1191
| * proto: Try to improve the documentation in crypto/cell.rsNick Mathewson2023-05-181-24/+86
| |
| * tor-proto: Code to construct crypto layers for virtual hops.Nick Mathewson2023-05-181-0/+7
| | | | | | | | | | This is fairly straightforward, thanks to our existing design work on this code.
* | hs_ntor: several documentation cleanups.Nick Mathewson2023-05-171-6/+14
| |
* | hs_ntor: make encrypt_and_mac take a typed public keyNick Mathewson2023-05-171-10/+6
| | | | | | | | This is still not the most beautiful interface, but it'll do for now.
* | hs_ntor: remove the last lingering AsRef<[u8]>Nick Mathewson2023-05-171-7/+7
| |
* | hs_ntor: Add a test vector case extracted from C tor.Nick Mathewson2023-05-171-0/+104
| |
* | hs_ntor: Calculate MAC on introduce1 message correctly.Nick Mathewson2023-05-171-3/+12
| | | | | | | | | | | | There were two bugs here that made the behavior unlike that of C tor: we had swapped the MAC inputs, and we had forgotten to include the public key X in the input.
* | hs_ntor: Make internal no-rng variants of the handshake functions.Nick Mathewson2023-05-171-2/+25
| | | | | | | | We'll want these so we can implement some test vectors.
* | hs_ntor: Move extra data outside of the "input" fields.Nick Mathewson2023-05-171-59/+33
| | | | | | | | | | | | | | I think that these Input structs had been defined so that we could use hs_ntor interchangeably with other handshakes. The trouble is, though, that it doesn't really work like any other handshakes we have.
* | hs_ntor: Use MAC implementation from tor-hscryptoNick Mathewson2023-05-171-35/+16
| | | | | | | | | | | | Note that some of the invocations for this function seem to put the key and the message in a questionable order. But that's a thing to figure out later, while debugging.
* | hs_ntor: Use correct PK types from tor_hscrypto.Nick Mathewson2023-05-171-20/+24
| |
* | hs_ntor: Use Subcredential type from tor-hscryptoNick Mathewson2023-05-171-4/+3
|/