Commit Graph

3093 Commits

Author SHA1 Message Date
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 a2c21fe050 deps: update cargo semver compatible deps
Updating serde v1.0.199 -> v1.0.200
Updating serde_derive v1.0.199 -> v1.0.200
Updating base64 v0.22.0 -> v0.22.1
Updating aws-lc-rs v1.7.0 -> v1.7.1
Updating aws-lc-sys v0.15.0 -> v0.16.0
2024-05-07 12:26:35 +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 4ba3a0a8c5 Cargo.lock: update rustls version under hickory
This avoids a dependency on a vulnerable version of ourself.
2024-05-03 10:16:53 +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
Joseph Birr-Pixton ffcc718e23 README.md: fix spelling error 2024-05-01 11:56:22 +00:00
MOZGIII 682f16c85c Small correction to the quic::PacketKey::integrity_limit doc 2024-04-30 14:25:48 +00:00
Daniel McCarney 59c33df57f deps: update cargo semver compatible deps
* serde v1.0.198 -> v1.0.199
* serde_derive v1.0.198 -> v1.0.199
* rustls-pki-types v1.4.1 -> v1.5.0
* hashbrown v0.14.3 -> v0.14.5
2024-04-29 16:48:14 +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
Joe Birr-Pixton 7b936042cc Install golang on macos runners
The macos-latest runner no longer comes with golang preinstalled.

Note that the fips build is not technically certified on macos,
but it is still nonetheless useful to defend the ability to
do `cargo test --all-features` on developer laptops.
2024-04-24 19:19:17 +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
Daniel McCarney 1f5146cdfa docs: update SECURITY example
The existing example should be easy enough to understand, but it's also
easy enough to update for the current major releases for maximum
clarity.
2024-04-19 14:26:22 +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
Daniel McCarney 5ed2c9739d deps: update cargo semver compatible deps
* anyhow 1.0.81 -> 1.0.82
* async-trait 0.1.79 -> 0.1.80
* time 0.3.34 -> 0.3.36
2024-04-15 14:00:03 +00:00
Daniel McCarney 793553ea99 docs: update ROADMAP post-quantum kex item
Rustls 0.23.2 added the groundwork for opting in to experimental
post-quantum key exchange support using `X25519Kyber768Draft00`.
Afterwards the remaining required pieces were released in a separate
crate, `rustls-post-quantum`. As a result this commit moves the
post-quantum KEX feature from the Future priorities to the Past
priorities.
2024-04-11 16:03:03 +00:00
Daniel McCarney fa605bfff0 test-ca: add README, point to test_ca.rs tool 2024-04-09 14:26:12 +00:00
Daniel McCarney e65110e730 test-ca: remove legacy OpenSSL tooling/config 2024-04-09 14:26:12 +00:00
Daniel McCarney c8aac1ba69 test-ca: regenerate with rcgen
This commit regenerates the test-ca PKI using the rcgen tooling.

A couple of small adjustments to unit tests are required:

1. We have to adjust down some expected write sizes: previously the
   singular RSA chain had 2048, 3072 and 4096 bit keys and the larger
   modulus sizes ensured a certain unit test always wrote more than 4000
   bytes of data. With the new 2048 chain having _only_ 2048 bit keys
   the expected write threshold needs to be adjusted down to 3000 bytes.
2. The expected subject common names expected in the client auth hint
   tests need adjusting for the new RSA root common names.
3. We introduce new RSA_3072 and RSA_4096 key sizes, using the newly
   generated test chains.

Otherwise all existing tests continue to pass as expected without
modification.
2024-04-09 14:26:12 +00:00
Daniel McCarney cf8f5a3c03 rustls/examples: add rcgen based CA generation tool
This commit updates the rustls crate's `examples/internal` module with
a new `test_ca` binary that generates the Rustls test PKI. It closely
matches the existing `build-a-pki.sh` script that generates the existing
test data, but does so in pure Rust using `rcgen`. It can be run with:

```
cargo run -p rustls --example test_ca
```

Unlike the existing script the RSA chain generation was switched to be
uniform with the approach used for ECDSA. Previously there was one RSA
chain with the EE/client certs using RSA 2048, the intermediate using
3072 and the root using 4096. This version instead uses the same key
size for all certs in the chain, but generates three chains: one for RSA
2048, one for 3072, and one for 4096.

The existing test-data is left as-is with this commit and will be
regenerated in a subsequent commit.
2024-04-09 14:26:12 +00:00
Daniel McCarney 2b0e174be2 deps: rcgen 0.12 -> 0.13
This updates the project dev dependency on rcgen from 0.12 to 0.13,
fixing breaking API changes as appropriate.
2024-04-09 14:26:12 +00:00
Daniel McCarney 9444dcbc7b Cargo: alphabetize workspace members 2024-04-09 14:26:12 +00:00
Daniel McCarney 961db38da1 tests: remove .req and .rsa test files
These aren't used anywhere and are just a byproduct of the OpenSSL based
generation script. We'll soon be rid of this script, so let's remove
these files.
2024-04-09 14:26:12 +00:00
Daniel McCarney 277b4a607c tests: move existing RSA test data to RSA 2048
This prepares for a change where we will generate RSA certificate
chains for three modulus sizes. The existing certificates are left
as-is, meaning the rsa-2048 intermediate and CA are using RSA 3072 and
4096 respectively. This will be fixed in subsequent commits with
a switch to new tooling.
2024-04-09 14:26:12 +00:00
Daniel McCarney bf5b0734c7 deps: update cargo semver compatible deps
* rustls-pemfile 2.1.1 -> 2.1.2
* rustversion 1.0.14 -> 1.0.15
* der 0.7.8 -> 0.7.9
2024-04-08 13:57:15 +00:00
dependabot[bot] 3b90d88315 build(deps): bump h2 from 0.3.24 to 0.3.26
Bumps [h2](https://github.com/hyperium/h2) from 0.3.24 to 0.3.26.
- [Release notes](https://github.com/hyperium/h2/releases)
- [Changelog](https://github.com/hyperium/h2/blob/v0.3.26/CHANGELOG.md)
- [Commits](https://github.com/hyperium/h2/compare/v0.3.24...v0.3.26)

---
updated-dependencies:
- dependency-name: h2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-06 07:06:50 +00:00
Daniel McCarney cc87ce1987 deps: aws-lc-rs 1.6.2 -> 1.6.4
Notably this brings in pre-generated bindings for more platforms.
See the upstream release notes[0][1] for more details.

[0]: https://github.com/aws/aws-lc-rs/releases/tag/v1.6.3
[1]: https://github.com/aws/aws-lc-rs/releases/tag/v1.6.4
2024-04-05 16:07:00 +00:00
Daniel McCarney c5d283a400 deps: update semver compatible deps
clap v4.5.3 -> v4.5.4
rustls-pki-types v1.4.0 -> v1.4.1
tokio v1.36.0 -> v1.37.0
serde_json v1.0.114 -> v1.0.115
2024-04-02 20:23:19 +00:00
Daniel McCarney 4b72f384e8 connect-tests: ignore rsa8192.badssl.com
This test server's certificate has expired. The issue has been flagged
with the upstream project. Until resolved let's ignore this test.
2024-04-02 18:49:10 +00:00
Joseph Birr-Pixton a5a992a0db Correct references to `VerifierBuilderError` 2024-04-02 14:55:09 +00:00
Joseph Birr-Pixton aff893f0ca Test for illegal IP address in server name extension 2024-04-02 14:43:44 +00:00
Joseph Birr-Pixton 3d4dae2f97 api.rs: reformat 2024-04-02 14:43:44 +00:00
Joseph Birr-Pixton f0d33d13a8 Ignore `server_name` extension containing IP address
This works around quality-of-implementation issues in OpenSSL and
Apple SecureTransport: they send `server_name` extensions containing
IP addresses.  RFC6066 specifically disallows that.

It is a similar work-around to that adopted by LibreSSL: ignore
SNI contents if they can be parsed as an IP address.
2024-04-02 14:43:44 +00:00
Daniel McCarney d8d438aecc no-std: ServerSessionMemoryCache, ClientSessionStore, Ticketer
This commit introduces a new `lock` module that exports a `Mutex`
wrapper type.

When the `std` feature is enabled the `Mutex` is a thin wrapper around
`std::sync::Mutex`. When the `std` feature is disabled, the user of the
library must provide a `Lock` implementation and a `MakeMutex`
implementation for producing instances of an appropriate lock.

`ServerSessionMemoryCache`, `ClientSessionStore`, `TicketSwitcher`, and
the aws-lc-rs/ring `Ticketer`s all rely on both a `HashMap`
implementation, and a `Mutex` implementation and so were gated as
requiring the `std` feature previously. With the `hashbrown` and
`crate::lock` module we can allow all of these items when either `std`
or the `hashbrown` features are enabled, supporting use in no-std
environments.
2024-03-30 13:49:58 +00:00
Christian Poveda 8831ced544 no-std: limited_cache, sni_resolver support w/ hashbrown
This commit introduces a new `hash_map` module that exports `HashMap`
and `Entry` types when the `std` or `hashbrown` feature are enabled.

The underlying types are provided from `std::collections` for the
former, and the optional `hashbrown` dependency for the latter.

`LimitedCache` and `ResolvesServerCertUsingSni` both relied on
a `HashMap` implementation, and so were gated as
requiring the `std` feature previously. With the `hashbrown` feature
we can allow both when either `std` or `hashbrown` features are enabled,
supporting their use in no-std environments.
2024-03-30 13:49:58 +00:00