summaryrefslogtreecommitdiff
path: root/crates/tor-proto/src/crypto
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* ServerHandshake: extend to support ntorv3 extensionsJim Newsome2023-11-153-15/+108
|
* NtorV3Client: implement ClientHandshakeJim Newsome2023-11-151-7/+13
|
* ClientHandshake: extend to support ntorv3 extensionsJim Newsome2023-11-153-18/+50
|
* NtorV3Client: take a slice instead of a vec of extensionsJim Newsome2023-11-151-5/+3
|
* ntor_v3: replace `impl digest::XofReader` with `NtorV3XofReader`Jim Newsome2023-11-151-15/+20
|
* hs_ntor: fix comment typo INTROUDCE1Jim Newsome2023-11-151-1/+1
|
* 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