Commit Graph

2538 Commits

Author SHA1 Message Date
Dirkjan Ochtman 34c74b0b6f Bump rustls version to alpha.5 2023-11-14 10:11:46 -08:00
Daniel McCarney ccb79947a4 Cargo: update semver compatible dependencies 2023-11-13 13:52:08 +00:00
Joseph Birr-Pixton 42cf372405 General smoke-test for `max_fragment_size`
`test_client_mtu_reduction` and `test_server_mtu_reduction` already exist
but only check client/server behaviour in (relative) isolation.

This test just checks handshaking and bidirectional data flow over
a matrix of key types, TLS versions, and max_fragment_sizes.
2023-11-10 17:44:32 +00:00
Joseph Birr-Pixton e3925b18e6 Use `BorrowedCursor` & `BorrowedBuf` from core::io 2023-11-10 16:11:42 +00:00
Joseph Birr-Pixton d3ab8f030b Opt in to feature(core_io_borrowed_buf)
This is needed for `BorrowedBuf` now, even if via the std::io reexport.
2023-11-10 16:11:42 +00:00
Daniel McCarney 9fc145a3df server/handy: import HashMap directly 2023-11-09 18:26:12 +00:00
Daniel McCarney 557da04188 client: derive Debug for Resumption
All of the fields of `Resumption` are now `Debug` friendly, so we can
derive `Debug` instead of implementing it by hand.
2023-11-09 18:26:12 +00:00
Daniel McCarney 4196a01099 client: derive Debug for ClientConfig
All of the fields of `ClientConfig` are now `Debug` friendly, so we can
derive `Debug` instead of implementing it by hand.
2023-11-09 18:26:12 +00:00
Daniel McCarney 66524008a7 server: derive Debug for ServerConfig
All of the `ServerConfig` fields are now `Debug` friendly, so we can
drop the custom impl and derive `Debug`.
2023-11-09 18:26:12 +00:00
Daniel McCarney 875636e6ba client: derive Debug for AlwaysResolvesClientCert
Since `sign::CertifiedKey` has a `Debug` bound now we can derive
`Debug` for `AlwaysResolvesClientCert` instead of implementing it by
hand.
2023-11-09 18:26:12 +00:00
Daniel McCarney 2f6373b2a5 internal: derive Debug for FixedSignatureSchemeSigningKey
Since the `sign::SigningKey` trait has a `Debug` bound we can derive
`Debug` here instead of doing it manually.
2023-11-09 18:26:12 +00:00
Daniel McCarney 7f8a332a23 server: add Debug bound to StoresServerSessions
This commit adds a `Debug` bound to the `StoresServerSessions` trait in
addition to `Send` and `Sync`. Types implementing this trait are updated
to either derive `Debug` or implement it by hand as appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney 7a3542f9a2 server: add Debug bound to ResolvesServerCert
This commit adds a `Debug` bound to the `ResolvesServerCert` trait in
addition to `Send` and `Sync`. Types implementing this trait are updated
to either derive `Debug` or implement it by hand as appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney 70c93d16f0 ticketer: add Debug bound to ProducesTickets
This commit adds a `Debug` bound to the `ProducesTickets` trait in
addition to `Send` and `Sync`. Types implementing this trait are updated
to either derive `Debug` or implement it by hand as appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney cc0666e795 verify: add Debug bound to ServerCertVerifier
This commit adds a `Debug` bound to the `ServerCertVerifier` trait in
addition to `Send` and `Sync`. Types implementing this trait are updated
to either derive `Debug` or implement it by hand as appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney ff86ccf140 verify: add Debug bound to ClientCertVerifier
This commit adds a `Debug` bound to the `ClientCertVerifier` trait in
addition to `Send` and `Sync`. Types implementing this trait are updated
to either derive `Debug` or implement it by hand as appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney a7f4ff9f4e client: add Debug bound to ResolvesClientCert
This commit adds a `Debug` bound to the `ResolvesClientCert` trait,
alongside `Send` and `Sync`. The types implementing this trait are
updated to either derive `Debug`, or implement it by hand, as
appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney cee7e700e5 conn: add Debug bound to SideData
This commit adds a `Debug` bound to the `SideData` trait. The types
implementing it are updated to derive `Debug` or implement it by hand as
appropriate.
2023-11-09 18:26:12 +00:00
Daniel McCarney 7445b53d58 client: add Debug bound to ClientSessionStore trait
This commit adds a `Debug` bound to the `ClientSessionStore` trait,
alongside `Send` and `Sync`. Types implementing the trait are updated
with derived or hand-written `Debug` impls as appropriate, taking care
to avoid leaking any sensitive information.
2023-11-09 18:26:12 +00:00
Daniel McCarney e076630986 crypto: add Debug bound to Signer trait
This commit adds a `Debug` bound to the `Signer` trait alongside the
existing `Send` and `Sync` bounds. Types implementing the trait are
updated with a hand-written `Debug` impl to avoid leaking sensitive
data.
2023-11-09 18:26:12 +00:00
Daniel McCarney c6347b7a61 crypto: add Debug bound to SigningKey
This commit adds a `Debug` bound to the `SigningKey` trait, alongside
`Send` and `Sync`. Types implementing this trait are updated to hand
implement `Debug` to avoid leaking any sensitive data.
2023-11-09 18:26:12 +00:00
Daniel McCarney 653abcbf7f key_log: add Debug bound to KeyLog trait
This commit adds a `Debug` bound to the `KeyLog` trait in addition to
`Send` and `Sync`. Each implementation in the codebase is updated to
derive, or hand-implement the `Debug` trait, taking care not to include
any fields that may contain secret key information.
2023-11-09 18:26:12 +00:00
Joseph Birr-Pixton b742a4a2a6 Remove *CertVerifierBuilder::with_signature_verification_algorithms
These seem no longer necessary.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 6189d780d8 Run feature tests in rustls/ directory
Otherwise they get altered by feature unification from other
members of the workspace.  That's more "spooky action at a distance"
than is desirable.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton b5c428d223 Fix HMAC_SHA512 dead-code warning
It isn't possible to write a cfg expression that says when this
is used, because it would differ over the two instantiations.

Note that HMAC-SHA512 is only actually used to run test vectors posted
to the tlswg mailing list by some random in 2009.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 1379f12657 Enable testing and benchmarking with aws-lc-rs 2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton aaf21d1cdf Allow optional use of aws-lc-rs
Provide shims for limited number of places where ring 0.17 and
aws-lc-rs (ring 0.16-era) APIs have diverged.  This is a
short-term fix, as they are likely to diverge more over time.
Eventually we'll have to stop sharing the code like this.

For unit-like tests, export a `test_provider` alias that resolves
to a provider module, for use in these tests.

This resolves to:

- *ring* if cfg(feature = "ring"), else
- aws-lc-rs if cfg(feature = "aws_lc_rs"), else
- is absent
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 8ea64754ac Remove reexport of signing impls in `rustls::sign::*`
These continue to be available in `rustls::crypto:💍:sign::*`.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 48d78f7232 Improve docs around `{Server,Client}Config::builder` 2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton c6c792b616 Delegate choosing webpki algorithms to `CryptoProvider`
This drastically simplifies `provider-example`.  But the
primary goal is ensuring a client configured `with_provider(AWS_LC_RS)`
only uses algorithms from aws-lc-rs, irrespective of crate features.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 6719bc52be Move webpki `SUPPORTED_SIG_ALGS` into `crypto::ring` 2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 3897bceeca Delegate private key loading to `CryptoProvider` 2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 0e296980fd Move `rustls::cipher_suite` members into provider module
Naming cipher suites individually seems like a "detail" feature, and
therefore having to name the provider too is not a large imposition.

Naturally this is a breaking change.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 7aa87e98a4 Make modules in crypto::ring reusable
They take the dependency on ring via `super::ring_like`, which
means they can be reused against a different, ring-compatible
crate.
2023-11-09 16:18:11 +00:00
Joseph Birr-Pixton 332d27f10f ring/kx.rs: tidy up and clarify imports 2023-11-09 16:18:11 +00:00
Jorge Aparicio 45e98d704d replace HashSet with BTreeSet in msgs::handshake
BTreeSet is in alloc but HashSet is not. all the affected sets contain
integers
2023-11-08 13:43:30 +00:00
Daniel McCarney de9bf1d2e9 connect-tests: add EchConfig fetch tests
This commit adds a new `connect-tests/tests/ech.rs` module that performs
a DNS over HTTPS lookup for HTTPS type records, finding `EchConfig`s and
testing we can deserialize the raw form into the Rustls representation
without error.

Presently it tests against:
* `crypto.cloudflare.com`
* `defo.ie`
* `tls-ech.dev`

Since these are network based tests they need to live in `connect-tests`
to avoid flakyness during normal CI runs.

In previous WIP branches this was done as part of an overall end-to-end
example of using ECH, but we can test this in isolation ahead of having
full ECH support.
2023-11-08 13:40:02 +00:00
Daniel McCarney 8583cd504c msgs: add ECH config messages and parsing
This commit breaks out representation of Encrypted Client Hello (ECH)
configuration from overall support for the feature. This code is
relatively isolated and so can be added without much impact to the rest
of the codebase. It does _not_ provide any actual ECH support.

The code is almost entirely derived from earlier WIP branches adding ECH
support, updated for the current Rustls codebase, and spot checked
against the current most ECH draft at the time of writing (draft-17).
HPKE references are also updated to use the published RFC (RFC 9180).

Notable updates from the WIP version:
* adapting to the `Codec` return type change.
* adapting to the enum builder changes.
* adapting to the server name changes.
* adapting to `TlsListElement` trait.
* adapting HPKE registry refs to use the RFC instead of an earlier
  draft.
* adding `Hpke` prefix to enums to clarify their purpose.
* adapting base64 usage to avoid deprecated fns.
* reworking unit tests for de-duplication, adding another encoded test
  case, adding more asserts for decoded content.
* fixing `clippy::use_self` finding.
* Changing `default` fn on `HpkeSymmetricCipherSuite` to be an impl of
  `Default`.
* Updating trust-dns-resolver code to use latest hickory-resolver.
* Pulling out ECH config fetch + deserialize from ECH example program to
  a connect-tests unit test.
2023-11-08 13:40:02 +00:00
Yuxiang Cao 1f0e6ad626 feat: add a new variant in Error
Add `Other` variant in Error to express any other error. The main
intention for this is to use it to hold errors throw from underlying
custom crypto provider or pki provider.

A new unit struct `OtherError` is added to properly implement
`PartialEq`.
2023-11-07 00:53:49 +00:00
Yuxiang Cao 3355e06f97 refactor: more general error in SupportedKxGroup
Use `Error` instead of `GetRandomFailed` in trait `SupportedKxGroup`,
so that underlying crypto provider could throw errors other than RNG
related errors.
2023-11-07 00:53:49 +00:00
Jacob Hoffman-Andrews e7a380f536 vecbuf: use drain rather than split_at
split_at always creates a new Vec, but drain just moves bytes within the
existing Vec.
2023-11-06 13:43:26 +00:00
Jacob Hoffman-Andrews 04ed53f7a6 Move, rather than clone, Certificate message
This saves some allocations and copies of relatively large data.
2023-11-06 13:43:26 +00:00
Jacob Hoffman-Andrews 22a35838f8 x509: reduce allocations for wrap_in_sequence
Instead of taking a `Vec<u8>` and inserting bytes at the beginning,
take a `&[u8]` and return a new vector containing those bytes plus
a tag and a length.

This isn't the perfect approach for all situations, but for one of the
main places we call wrap_in_sequence (DistinguishedName::in_sequence),
it's optimal because the input is `&[u8]`, meaning we can't write to
a previously existing `Vec<u8>` (which would potentially save
allocations by using excess capacity at the end of the Vec).

In the process, change the one call site for `wrap_in_asn1_len` to call
the new `asn1_wrap` function instead, which encodes a tag and length at
the same time, reducing reallocations and copies.

This has a slight secondary benefit: the resulting Vec is exactly sized
to what it holds, instead of following the doubling approach and
possibly over-allocating. This saves a handful of bytes in a long-lived
data structure.
2023-11-06 13:35:26 +00:00
Dirkjan Ochtman da280af796 Update semver-compatible dependencies 2023-11-06 13:34:13 +00:00
Paolo Barbolini d8e86aaf45 key_log_file: replace `env::var` with `env::var_os`
Instead of matching the error from `env:var` in order to accept
non-unicode file paths we switch to the more idiomatic `env::var_os`.
2023-11-06 13:26:59 +00:00
Jorge Aparicio 793ca28c0c disable subtle's default features
suble depends on libstd by default and its default features are not
being used
2023-11-03 15:14:28 +00:00
Daniel McCarney b776a5778a Cargo: 0.22.0-alpha.3 -> 0.22.0-alpha.4 2023-10-30 15:31:19 +00:00
Daniel McCarney 1ec7b727de Cargo: use rustls-webpki v0.102.0-alpha.6
This version of webpki improves CRL ergonomics. Notable changes:

* use `with_status_policy builder` fn

The upstream crate added a more ergonomic interface we can use in
place of having to keep around a mutable builder and doing our own
matching.

* avoid CRL dyn trait hurdles

The upstream crate made working with CRLs easier by replacing the
`CertRevocationList` trait with an `enum` representation.

Notably this makes working with the `Vec<OwnedCertRevocationList>` that
the webpki verifier builders and verifiers hold much easier: we no long
have to do as many contortions to convert to a `&[&dyn
CertRevocationList]`.
2023-10-30 15:31:19 +00:00
Daniel McCarney c3f00c7179 tests: test server hint subject control
Adds tests for:
* Sending an empty root hint subjects list.
* Adding custom root hint subjects in addition to the defaults.
2023-10-30 15:04:46 +00:00
Daniel McCarney 3cfa71d853 tests: generalize client cert resolve test
Pull out a generic helper from the existing client cert resolver test,
rename the test that uses the helper to emphasize it's testing a default
configuration. This will make it easier to add a test for non-default
configurations.
2023-10-30 15:04:46 +00:00