Commit Graph

3008 Commits

Author SHA1 Message Date
Joseph Birr-Pixton dc957ece89 Allow customisation of alert sent for InvalidMessage
Use this to send the correct alert for InvalidMessage::PreSharedKeyIsNotFinalExtension
2024-03-13 12:50:22 +00:00
Joseph Birr-Pixton 823e46c1b0 Validate that pre_shared_key extension appears last 2024-03-13 12:50:22 +00:00
Joseph Birr-Pixton ff9555a3d3 Check unknown extensions for duplicates
_Known_ extensions are already checked by code in the previous commit.
But we also need to check _unknown_ extensions which are otherwise
discarded during decoding.
2024-03-13 12:50:22 +00:00
Joseph Birr-Pixton 4d42cb7036 Switch from `Vec<ClientExtension>` to `ClientExtensions` 2024-03-13 12:50:22 +00:00
Joseph Birr-Pixton 8eff76fe4b Introduce `ClientExtensions` type
Instead of `Vec<ClientExtension>`, store the extension data as
a struct.  This is possible because past commits have removed
the need for this us to losslessly round-trip extension data.

This involves fewer allocations to construct the extensions for clients.

It eliminates repeated iteration of the vector to find specific extensions
when processing a `ClientHello` for servers.  It also reduces
the cost of detecting duplicate extensions.
2024-03-13 11:49:08 +00:00
Joseph Birr-Pixton 7b33a9a763 Avoid handshake message round-tripping for binders
Verifying a _received_ `ClientHello` binder should be done
against the original received bytes, not our re-encoding of them.

This previously worked, because we required and tested that
we could round-trip `ClientHello` messages (and others).  This
is about to become not true.
2024-03-12 15:40:29 +00:00
Joseph Birr-Pixton 4243090fdc impl Codec for unit type 2024-03-12 15:36:48 +00:00
Daniel McCarney 0398ac50fe deps: log 0.4.20 -> 0.4.21 2024-03-11 19:32:05 +00:00
Daniel McCarney 7588262aac deps: rustls-pki-types 1.3.0 -> 1.3.1 2024-03-11 19:32:05 +00:00
Daniel McCarney 811d55eda4 deps: asn1 0.16.0 -> 0.16.1 2024-03-11 19:32:05 +00:00
Daniel McCarney f4ba5341d6 deps: rustls-pemfile 2.1.0 -> 2.1.1 2024-03-11 19:32:05 +00:00
Daniel McCarney afedcfe733 deps: rayon 0.8.1 -> 1.9.0 2024-03-11 19:32:05 +00:00
Daniel McCarney 479aec0a9a deps: clap 4.5.1 -> 4.5.2 2024-03-11 19:32:05 +00:00
Josh Triplett 700028200a Add an `aws-lc-rs` feature as an alias for `aws_lc_rs`
The vast majority of Cargo features in the crates ecosystem use dashes
to separate words, rather than underscores. The fact that `aws_lc_rs`
uses underscores, and some crates depending on rustls naturally use the
same name for the feature that rustls does, has led some crates to end
up with inconsistent feature naming that throws people off (e.g. using
the wrong feature name and being surprised at the resulting compilation
failures), and has led other crates to use `aws-lc-rs` for consistency
with their other features which causes inconsistency with rustls.

Add an alias, so that it works either way, and people can reference
either one.
2024-03-11 19:31:27 +00:00
Joseph Birr-Pixton 52efdc99c9 Avoid `clippy::std_instead_of_core` false positive
This is complaining about the import of the `env` module from
`std::env`, instead of `core::env`.

However, `core::env` is a completely different item -- it is
the `env!` macro.
2024-03-11 13:59:00 +00:00
Joseph Birr-Pixton 7a9d9788c8 Address `clippy::mixed_attributes_style` 2024-03-11 13:59:00 +00:00
Joseph Birr-Pixton db4b6c8069 Address `clippy::multiple_bound_locations` 2024-03-11 13:59:00 +00:00
Joseph Birr-Pixton 0bc3a2eee5 Address `clippy::assigning_clones` 2024-03-11 13:59:00 +00:00
Joseph Birr-Pixton 85fdfd4a23 Attempt to improve `merge_group` job performance 2024-03-07 13:52:42 +00:00
Joseph Birr-Pixton e1eb447a67 Fix newly found `unused_qualifications` warnings
eg.

```
error: unnecessary qualification
  --> rustls/src/vecbuf.rs:88:24
   |
88 |             let used = core::cmp::min(chunk.len(), cursor.capacity());
   |                        ^^^^^^^^^^^^^^
   |
help: remove the unnecessary path segments
   |
88 -             let used = core::cmp::min(chunk.len(), cursor.capacity());
88 +             let used = cmp::min(chunk.len(), cursor.capacity());
   |
```
2024-03-06 17:41:53 +00:00
dependabot[bot] 54a95575be build(deps): bump mio from 0.8.10 to 0.8.11
Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.10 to 0.8.11.
- [Release notes](https://github.com/tokio-rs/mio/releases)
- [Changelog](https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/mio/compare/v0.8.10...v0.8.11)

---
updated-dependencies:
- dependency-name: mio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-04 22:00:41 +00:00
Daniel McCarney 3cd97d8f2a cargo: add --all to the fmt-unstable alias
It isn't possible to add extra arguments to an alias like this, so we
might as well add `--all` to make it more useful for developers.
2024-03-04 09:27:43 +00:00
Daniel McCarney 1e656ba1fc ci: avoid fmt-unstable alias for unstable fmt job
Unfortunately the alias doesn't allow passing in custom arguments like
`--all` or `--manifest-path`. Doing so in the manner we tried before
results in output like:

```
> Run cargo fmt-unstable --all --manifest-path=connect-tests/Cargo.toml -- --check
Unrecognized option: 'all'
```

This commit switches to the full `cargo fmt` invocation in each case.
2024-03-04 09:27:43 +00:00
Daniel McCarney 536a0cdc03 fuzz: apply fmt-unstable to fuzz crate 2024-03-04 09:27:43 +00:00
Joseph Birr-Pixton 9ef2150472 dangerous_extract_secrets(): test `ConnectionTrafficSecrets` variant 2024-03-03 11:07:33 +00:00
Arnav Singh 3f5d37e976 Return correct `ConnectionTrafficSecrets` variant when AES-256-GCM is negotiated.
55bb27953d inadvertently changed `extract_keys`
to always return `ConnectionTrafficSecrets::Aes128Gcm`, even when AES-256-GCM
was negotiated. This change fixes it by restoring the key length check.

Fixes #1833
2024-03-03 11:07:33 +00:00
Joseph Birr-Pixton 546a85d912 Format imports with `cargo +nightly fmt-unstable`
Run with nightly-2024-02-21
2024-03-01 15:25:48 +00:00
Joseph Birr-Pixton 2d66fe4d9b Fix `name` for benchmarking toolchain step 2024-03-01 15:25:48 +00:00
Joseph Birr-Pixton a47352629d Run rustfmt nightly in CI
Do not fail the job on changes on nightly.
2024-03-01 15:25:48 +00:00
Joseph Birr-Pixton b6f283ed79 Ask rustfmt to make our imports consistent
These are nightly-only options: so keep them in a separate file.

When it sees unstable features, stable rustfmt gives a diagnostic like:

> Warning: can't set `imports_granularity = Module`, unstable features are only available in nightly channel.
> Warning: can't set `group_imports = StdExternalCrate`, unstable features are only available in nightly channel.

But: _does_ otherwise format the files and exit non-zero.  However, this is noisy.

We arrange that `cargo +nightly fmt-unstable` also does the right thing.
2024-03-01 15:25:48 +00:00
Joseph Birr-Pixton bce2e5e241 Prepare 0.23.1 2024-03-01 15:25:23 +00:00
Joseph Birr-Pixton 69920b0b7e default_fips_provider(): make visible in docs 2024-03-01 14:04:23 +00:00
Joseph Birr-Pixton 384b3d6fb0 Avoid `fips` feature for docs.rs
The docs.rs environment has golang installed, but doesn't have
the environment variables needed to make it actually work:
https://github.com/rust-lang/docs.rs/issues/1303

So avoid that entirely.
2024-03-01 14:04:23 +00:00
Daniel McCarney 03f52c1efc crypto: gate ticketer module on std for aws-lc-rs
Fixes a missing import error when building without std and with
aws_lc_rs:
```
$ cargo check -p rustls --no-default-features --features aws_lc_rs
   Compiling rustls v0.23.0 (/home/daniel/Code/Rust/rustls/rustls)
error[E0432]: unresolved import `ticketer`
   --> rustls/src/crypto/aws_lc_rs/mod.rs:228:9
    |
228 | pub use ticketer::Ticketer;
    |         ^^^^^^^^ use of undeclared crate or module `ticketer`
```

Adding a `std` gate on `TICKETER_AEAD` was also required to fix unused
warnings for builds w/o `std` using either ring or aws_lc_rs:

```
$ cargo check -p rustls --no-default-features --features aws_lc_rs
   Compiling rustls v0.23.0 (/home/daniel/Code/Rust/rustls/rustls)
warning: static `TICKETER_AEAD` is never used
   --> rustls/src/crypto/aws_lc_rs/mod.rs:249:19
    |
249 | pub(super) static TICKETER_AEAD: &ring_like::aead::Algorithm = &ring_like::aead::AES_256_GCM;
    |                   ^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default
```
2024-02-29 19:49:07 +00:00
Daniel McCarney 408a42ae0e docs: update RELEASING to mention running daily-tests
Our daily tests CI job runs some additional tests that are too slow or
too flaky to be run for every merge requests. Before doing a release
it's a good idea to run this workflow manually to make sure there aren't
any lurking regressions that `cargo hack` or another test from this
workflow could catch pre-release.

This commit adds that guidance to `RELEASING.md` for future releases.
2024-02-29 19:17:10 +00:00
Joseph Birr-Pixton eb0791bc94 Prepare 0.23.0 2024-02-29 14:57:47 +00:00
Joseph Birr-Pixton 88022fc91d Reword `no process-level CryptoProvider` panic
Avoid markdown and ensure it is a single sentence.
2024-02-29 11:26:52 +00:00
Yuxiang Cao d5c6036716 refactor: avoid pretty printing when logging
Pretty printing should not used in logging with
level that's higher then Debug.
2024-02-29 09:38:24 +00:00
Joe Birr-Pixton cf098b08d3 Cargo.toml: disentangle std/aws_lc_rs features 2024-02-28 20:27:34 +00:00
Joseph Birr-Pixton 425b527290 ROADMAP.md: prepare for 0.23 release 2024-02-28 17:15:45 +00:00
Daniel McCarney d5842f461e tls13/quic: construct QUIC suite from TLS 1.3 suite
This commit adds a `quic::Suite` struct for representing the combination
of a `Tls13CipherSuite` and a `quic::Algorithm`. This can optionally be
constructed from a `Tls13CipherSuite` that supports QUIC. Having this
type helps downstream users that otherwise need to juggle the
`Option<quic::Algorithm>` and `Option<Tls13CipherSuite>` from
a `SupportedCipherSuite` separately.
2024-02-27 20:08:42 +00:00
Daniel McCarney 4aafdc838b client/server: crypto_provider accessor for configs
When holding a `ClientConfig` or a `ServerConfig` it may be helpful to
be able to access the `&Arc<CryptoProviver>` that will be used for the
configuration. This commit adds accessor functions for this purpose.
2024-02-27 20:08:42 +00:00
Daniel McCarney 50a656330b client_conn: reorder ClientConfig members
The `pub(crate)` members should be below the `pub` members and above the
`pub(super)` members.
2024-02-27 20:08:42 +00:00
Daniel McCarney 5138cd81e1 suites: split integrity and confidentiality limit handling
Previously the `CipherSuiteCommon` type had a `confidentiality_limit`
and a `integrity_limit`. Recent refactoring for better downstream
QUIC ergonomics has pulled these limits into the `quic::PacketKey`
trait. To reduce duplication this commit adjusts our handling of these
two limits.

For the `integrity_limit`, it was already documented in
`CipherSuiteCommon` as being specific to QUIC and irrelevant for TLS
over TCP. For this reason we delete the field from `CipherSuiteCommon`,
leaving it only in `quic::PacketKey` where it is actually useful.

For the `confidentiality_limit` it was described imprecisely and erred
on the side of caution, proposing a limit calculated based on QUIC
overhead even for the TCP usecase. Now that we've split this field the
`CipherSuiteCommon` version's documentation is updated to use a tighter
bound for the TCP use-case, and the associated `PacketKey` field can be
documented to use the QUIC bound.
2024-02-27 20:08:42 +00:00
Dirkjan Ochtman 542b12ca89 quic: expose limits via PacketKey trait 2024-02-27 20:08:42 +00:00
Dirkjan Ochtman 3e4630fb8f quic: name fields of ring::quic::KeyBuilder 2024-02-27 20:08:42 +00:00
Daniel McCarney e8243d8dd5 deframer: test out-of-bounds panic for quic append_hs
The `append_hs` function of the `MessageDeframer` (used only by QUIC
connections) mishandles the case where we were in the process of
deframing a QUIC HS message that required joining.

When copying a payload of the fragmented HS message into the deframer
buffer the `DeframerBuffer<'a, ExternalPayload<'a>>` trait
implementation for `DeframerVecBuffer` _already_ positioned the write
into the unfilled section of the buffer, `self.unfilled()` (e.g.
`self.buf[self.used..]`).

However, the branch of `append_hs` that continues processing of joining
a fragmented HS message was incorrectly further offsetting the copy
position by `meta.payload.end`, which is equal to `self.used` at this
point. In effect trying to write to `self.buf[self.used+self.used..]`.

As a result, if we have buffered more than half the capacity of
`self.buf` and then attempt to join in more payload bytes, the unfilled
offset is outside the bounds of `buf` and an out-of-bounds indexing
panic occurs.

This commit adds a simple integration test, as well as a fix.
2024-02-27 20:08:42 +00:00
Joseph Birr-Pixton 0eab92f3f0 API tests: ignore warnings in ClientStorage mock
This is a complete mock for `rustls::client::ClientSessionStore`,
but we don't have tests that use 100% of its abilities.
2024-02-27 17:23:11 +00:00
Joseph Birr-Pixton 2a7aeec6e8 Clean up no_std and use of std in test code
This fixes a wedge of instances of:

```
warning: the item `String` is imported redundantly
  --> rustls/src/msgs/handshake.rs:27:5
   |
27 | use alloc::string::String;
   |     ^^^^^^^^^^^^^^^^^^^^^
```

Where `String` is present from the std prelude when built
for testing.  Like we just did in webpki, _always_ opt-in
to no_std, and then import the std prelude in tests where
necessary.
2024-02-27 17:23:11 +00:00
Joseph Birr-Pixton dae2b3e0ae bogo_shim: fix new nightly warning
"warning: the item `rustls` is imported redundantly"
2024-02-27 17:23:11 +00:00