Commit Graph

1744 Commits

Author SHA1 Message Date
Daniel McCarney 21b51fc206 msgs: fix clippy::use_self finding
```
warning: unnecessary structure name repetition
    --> rustls/src/msgs/handshake.rs:1385:52
     |
1385 |     pub(crate) fn new(cert: CertificateDer<'a>) -> CertificateEntry<'a> {
     |                                                    ^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self
note: the lint level is defined here
    --> rustls/src/lib.rs:310:5
     |
310  |     clippy::use_self,
     |     ^^^^^^^^^^^^^^^^
```
2024-05-28 14:55:40 +00:00
Joseph Birr-Pixton 99abca5e49 Prepare 0.23.8 2024-05-23 12:46:38 +00:00
Joseph Birr-Pixton 06c777bb3f Hide internals from documentation
This prevents cargo-semver-checks seeing this part of the API,
which improves its accuracy.
2024-05-23 08:56:57 +00:00
Joseph Birr-Pixton 091587bc8b Derive Clone for `ServerConfig` & `ClientConfig`
This seems not to be required now.  Possibly a hangover
from when these were generic over a `CryptoProvider`.
2024-05-23 08:56:57 +00:00
Joseph Birr-Pixton 96648336a7 Refactor construction of `CertificatePayloadTls13` 2024-05-23 08:56:57 +00:00
Joseph Birr-Pixton 45c8a54589 Remove `PayloadU24::new`
This had one caller outside of test code.
2024-05-23 08:56:57 +00:00
Joseph Birr-Pixton 04ef27c7eb api.rs: format imports 2024-05-23 08:56:57 +00:00
jasperpatterson 572f970b0b Add test for CRL expiration 2024-05-21 14:32:11 +00:00
jasperpatterson 8da353056a Add support for enforcing CRL expiration 2024-05-21 14:32:11 +00:00
Joseph Birr-Pixton c57079361b Cover `HandshakeMessagePayload::into_owned()` 2024-05-21 07:16:33 +00:00
Joseph Birr-Pixton 125d64164e Test theoretical support for OCSP pinning 2024-05-21 07:16:33 +00:00
Joseph Birr-Pixton dfa926abf2 Unify limits on certificate message size
Remove misplaced comment complaining about TLS1.3 design.
2024-05-21 07:16:33 +00:00
Joseph Birr-Pixton 3ef136c661 Extend borrowed certificate data support to TLS1.3
Previously this covered only certificates received in a TLS1.2
handshake.  Now it covers TLS1.3 certificates and OCSP responses.
2024-05-21 07:16:33 +00:00
Joseph Birr-Pixton fbaa0f940a Rename `CertificatePayloadTls13::convert` 2024-05-21 07:16:33 +00:00
Joseph Birr-Pixton e45fec43e1 Prepare 0.23.7 2024-05-17 17:26:06 +00:00
Joseph Birr-Pixton 2c72fb0c31 Test for more `close_notify` conditions
- before the handshake finishes
- after a `close_notify` before the handshake finishes
- after a `close_notify` after the handshake finishes
- `read_tls` artificial EOF after `close_notify`
2024-05-17 17:26:06 +00:00
Joseph Birr-Pixton 7d4e809e5e Ignore duplicative `send_close_notify` calls
`tokio-rustls` has a test that accidentally does this twice.
Make this call idempotent.
2024-05-17 17:26:06 +00:00
Joseph Birr-Pixton ced64bcedf `read_tls` refuse to read further data after `close_notify` alert 2024-05-17 17:26:06 +00:00
Joseph Birr-Pixton 386b6fd2f9 Correctly discard data after `close_notify` alert 2024-05-17 17:26:06 +00:00
Joseph Birr-Pixton 252b5d360b Prepare 0.23.6 2024-05-16 14:51:31 +00:00
Joseph Birr-Pixton 55890f0ee6 Test for junk in unbuffered input after `close_notify` 2024-05-16 12:36:10 +00:00
Joseph Birr-Pixton 972da7ff71 Test app data after `close_notify` is ignored 2024-05-16 12:36:10 +00:00
Joseph Birr-Pixton 424bb317ea Test for junk in deframer buffer after `close_notify` 2024-05-16 12:36:10 +00:00
Dirkjan Ochtman 749121a976 Ignore data appearing after `close_notify` 2024-05-16 12:36:10 +00:00
Dirkjan Ochtman ef024342d1 Deduplicate Reader state checks 2024-05-16 12:36:10 +00:00
Dirkjan Ochtman ccb352c075 Linearize Reader::read() and read_buf() 2024-05-16 12:36:10 +00:00
Dirkjan Ochtman 27d81e01e8 Warn on lints, don't deny
We deny warnings in CI (during clippy runs), which seems sufficient.
Denying lints is annoying during development especially when working
on a release branches (after the lints have gotten more precise).
2024-05-16 07:57:08 +00:00
Daniel McCarney 6faac22b10 tests: rework test_config_builders_debug
In practice this test is more noisy than useful. This commit relaxes it
to only check that the builder types/intermediate states are debug, but
not that the debug representation is a byte-for-byte match to an
expected value.
2024-05-12 15:02:33 +00:00
Daniel McCarney 5ce2a49926 handshake: derive Clone for HelloRetryRequest
In order to process ECH HRR acceptance it is convenient to be able to
clone the `HelloRetryRequest`.
2024-05-12 15:02:33 +00:00
Daniel McCarney 86904117a5 crypto: implement Zeroize for HpkePrivateKey 2024-05-12 15:02:33 +00:00
Daniel McCarney 41d283bbc5 crypto: trait tweaks for HpkeSuite, HpkePublicKey
The `HpkeSuite` type is small enough to be a candidate for `Copy`. The
`HpkePublicKey` type should be `Debug` and `Clone` so we can easily use
it for GREASE ECH configurations.
2024-05-12 15:02:33 +00:00
Daniel McCarney e155c6aade crypto: derive Clone & Debug for HpkeSuite
We will want to store this type in configurations that are `Clone` and
`Debug`.
2024-05-12 15:02:33 +00:00
Daniel McCarney 69b5d2374e build: emit rustc-check-cfg for bench, read_buf
Fixes warnings generated with nightly when generating cargo docs of the
form:

```
error: unexpected `cfg` condition name: `bench`
   --> rustls/src/lib.rs:305:31
    |
305 | #![cfg_attr(not(any(read_buf, bench)), forbid(unstable_features))]
    |                               ^^^^^
    |
    = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(bench)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration
```

We also need to apply this suggestion for `read_buf`, because of
a workaround documented for another upstream rust issue.

Note, because our MSRV is 1.63 we have to add the new `build.rs`
directives with the prefix `cargo:` instead of `cargo::` as described in
the warning output, or we get a new error of the form:

```
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `rustls v0.23.5 (/home/daniel/Code/Rust/rustls/rustls)` is 1.63.
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.
```
2024-05-06 18:19:40 +00:00
Daniel McCarney 1265e55111 ring: cfg-gate the hmac module
When building with `--no-default-features --features ring` there are
a couple clippy warnings produced:

```
$ cargo check --manifest-path=rustls/Cargo.toml --no-default-features --features=ring
  error: struct `Hmac` is never constructed
    --> rustls/src/crypto/ring/hmac.rs:16:19
     |
  16 | pub(crate) struct Hmac(&'static ring_like::hmac::Algorithm);
     |                   ^^^^
     |
     = note: `-D dead-code` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(dead_code)]`

  error: struct `Key` is never constructed
    --> rustls/src/crypto/ring/hmac.rs:32:8
     |
  32 | struct Key(ring_like::hmac::Key);
     |        ^^^
```

This is fixed in this branch by conditionally compiling the
`crypto/ring/hmac.rs` mod based on whether we're building tests, or have
the tls-12 feature enabled.
2024-05-04 16:41:04 +00:00
Joseph Birr-Pixton ec8320b4c2 Rename `SignatureScheme::sign`
The old name doesn't really make sense for me.
2024-05-03 09:58:11 +00:00
Joseph Birr-Pixton 08af80a25a aws-lc-rs: reduce priority of `ECDSA_NISTP521_SHA512`
In TLS1.2, this actually means ECDSA_SHA512.  If the peer selects
that, we get caught out depending on the curve of the public key
because we don't support (for example) `ECDSA_NISTP256_SHA512`.

Reducing the preference of this improves matters, because a
peer that respects our priority will only select that if nothing
else is possible (which includes the cases that SHA256 and SHA384
are not supported, in which case we are hosed, but also if the
version is TLS1.3 and public key is on P521).
2024-05-03 09:34:25 +00:00
Dirkjan Ochtman c46cf7e6ca Apply suggestions from clippy 1.78 2024-05-02 20:51:05 +00:00
MOZGIII 682f16c85c Small correction to the quic::PacketKey::integrity_limit doc 2024-04-30 14:25:48 +00:00
Joseph Birr-Pixton 513e374b2e crypto::aws_lc_rs: minor docs nits 2024-04-26 09:48:19 +00:00
Daniel McCarney a74f9d531b deps: update cargo semver compatible deps
Updating hickory-resolver v0.24.0 -> v0.24.1
Updating serde v1.0.197 -> v1.0.198
Updating serde_derive v1.0.197 -> v1.0.198
Updating serde_json v1.0.115 -> v1.0.116
Updating aws-lc-rs v1.6.4 -> v1.7.0
Updating aws-lc-sys v0.14.1 -> v0.15.0
Updating hashbrown v0.13.2 -> v0.14.3
2024-04-24 19:37:52 +00:00
Daniel McCarney f57d4b7954 proj: fix clippy::unnecessary_lazy_evaluation findings
Of the form:
```
error: unnecessary closure used with `bool::then`
  --> rustls/src/tls13/mod.rs:42:9
   |
42 | /         (prev.common.hash_provider.algorithm() == self.common.hash_provider.algorithm())
43 | |             .then(|| prev)
   | |______________------------^
   |                |
   |                help: use `then_some(..)` instead: `then_some(prev)`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
   = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::unnecessary_lazy_evaluations)]`
```
2024-04-19 15:48:18 +00:00
Daniel McCarney dd0b2cea29 proj: MSRV 1.61 -> 1.63
We're seeing more of our deps move to this MSRV or higher (e.g.
`webpki`, `rustls-platform-verifier`) and it's shipped in Debian stable.
Time to move our MSRV to 1.63.
2024-04-19 15:48:18 +00:00
Joseph Birr-Pixton 14cb5d2eac Prepare 0.23.5 2024-04-19 15:01:19 +00:00
Joseph Birr-Pixton 6e938bcfe8 complete_io: bail out if progress is impossible
Have a test that demonstrates another route to reaching this
state: a fully & cleanly closed connection.
2024-04-19 15:01:19 +00:00
Joseph Birr-Pixton 2123576840 Regression test for `complete_io` infinite loop bug 2024-04-19 15:01:19 +00:00
Joseph Birr-Pixton f45664fbde Don't specially handle unauthenticated close_notify alerts 2024-04-19 15:01:19 +00:00
Joseph Birr-Pixton 5ea02ed56f Return `Option` from `handshake_kind()` 2024-04-17 08:56:28 +00:00
Joseph Birr-Pixton d2e1e668aa bogo: verify expected handshake kind 2024-04-16 19:39:26 +00:00
Joseph Birr-Pixton d8a2ae040c Add API exposing shape of the performed handshake
This allows callers to see if their handshake was Resumed,
Full, or Full-with-HelloRetryRequest (which, broadly, are the
three "cost" levels for handshakes).

This is exposed as soon as it is known for sure.
2024-04-16 19:39:26 +00:00
Joseph Birr-Pixton 740ca41773 tests/api.rs: reformat 2024-04-16 19:39:26 +00:00