Commit Graph

78 Commits

Author SHA1 Message Date
Joseph Birr-Pixton 0a61a3ad4a Depend on rustls-webpki 0.102.1 2024-01-04 09:21:59 +00:00
Dirkjan Ochtman 937a51c384 Update semver-compatible dependencies 2023-12-11 10:11:15 +00:00
Jacob Hoffman-Andrews 0963cca28d update examples to use pki_types re-export
We now re-export the rustls-pki-types crate. I think that means
our preferred way for crates to consume pki-types is through the
re-exports.
2023-12-08 09:31:35 +00:00
Daniel McCarney b2cd88697f Cargo: version 0.22 -> 0.23-alpha.0
We're starting to land semver incompatible changes into `main`. This
commit bumps the crate version so that the semver detection job won't
cause spurious failures.
2023-12-06 18:40:20 +00:00
Christian Poveda 17e938c3af Batch discard operations 2023-12-06 18:15:37 +00:00
Jorge Aparicio 4505605c1a make MessageDeframer unbuffered 2023-12-06 18:15:37 +00:00
Joseph Birr-Pixton 4d1b762b53 Bump version to 0.22.0 2023-12-01 19:10:46 +00:00
Joseph Birr-Pixton 381dcf99ee Update dependencies 2023-12-01 19:10:46 +00:00
Daniel McCarney a7191785f6 remove unwrap for protocol versions w/ default provider
When building a client config or a server config using the default
provider we know that the ciphersuites will be compatible with any
choice of protocol version. By having the default `builder` method
configure itself with safe default versions, and offering
a `builder_with_protocol_versions` for customization we can transition
directly to `WantsVerifier` for these default provider builders,
removing a `Result` that will never be an error and making the API more
ergonomic in the common case.
2023-11-30 15:53:39 +00:00
Daniel McCarney b92fd839e3 crypto: rework CryptoProvider as struct
This commit replaces the existing `CryptoProvider` trait with
a `CryptoProvider` struct. This has several advantages:

* it consolidates all of the cryptography related settings into one API
  surface, the `CryptoProvider` struct members. Previously the provider
  had methods to suggest default ciphersuites, key exchanges etc, but
  the builder API methods could override them in confusing ways.
* it allows removing the `WantsCipherSuites` and `WantsKxGroups` builder
  states - the "safe defaults" are automatically supplied by the choice
  of a crypto provider. Customization is achieved by overriding the
  provider's struct fields. Having fewer builder states makes the API
  easier to understand and document.
* it makes customization easier: the end user can rely on "struct update
  syntax"[0] to only specify fields values for the required
  customization, and defer the rest to an existing `CryptoProvider`.

Achieving this requires a couple of additional changes:

* The cipher suite and key exchange groups are now expressed as `Vec`
  elements. This avoids imposing a `&'static` lifetime that would
  preclude runtime customization (e.g. the tls*-mio examples that
  build the list of ciphersuites at runtime based on command line
  flags).
* As a result of the `Vec` members we can no longer offer the concrete
  `CryptoProvider`s as `static` members of their respective modules.
  Instead we add `pub fn default_provider() -> CryptoProvider` methods
  to the `ring` and `aws-lc-rs` module that construct the `CryptoProvider`
  with the safe defaults, ready for further customization.

[0]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax
2023-11-30 15:53:39 +00:00
Daniel McCarney 74bd185f6e Cargo: 0.22.0-alpha.5 -> 0.22.0-alpha.6 2023-11-29 21:41:52 +00:00
Daniel McCarney aef3381dea update rustls-webpki to alpha.8, pki-types to 2.2.3
Requires accommodating the new `Debug` bound requirement in the provider
example, and fixing some expected output in a webpki verify test.
2023-11-29 21:41:52 +00:00
Dirkjan Ochtman af80fa35f6 Update semver-compatible dependencies 2023-11-27 14:45:32 +00:00
Dirkjan Ochtman a6233dcc46 Bump rustls version to alpha.5 2023-11-24 14:38:07 +00:00
Dirkjan Ochtman 26ec868b8c Migrate to pki-types ServerName 2023-11-23 21:57:10 +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 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
Joe Birr-Pixton b515abfcb3 `AeadKey`: zeroize on drop 2023-10-20 09:04:27 +00:00
Joseph Birr-Pixton 092a6af3db Take rustls-webpki 0.102.0-alpha.4 2023-10-06 15:24:29 +00:00
Dirkjan Ochtman 8e64ed10b9 Upgrade to ring 0.17 2023-10-06 15:24:29 +00:00
Joseph Birr-Pixton 47cae34706 fuzz: remove unused webpki dependency 2023-10-06 10:25:05 +00:00
Dirkjan Ochtman c7970af179 Keep Cargo.lock under version control 2023-09-26 13:38:35 +00:00
Joseph Birr-Pixton 048ff10740 Use dynamic dispatch for `CryptoProvider`
Instead of the type `rustls::crypto:💍:Ring`, the value
`rustls::crypto:💍:RING` implements this, and is more
entertaining to write.

`ServerConfig::builder()` references this by default, and
is equivalent to `ServerConfig::builder_with_provider(crypto:💍:RING)`.
2023-09-19 11:09:38 +00:00
Daniel McCarney 222690db36 deframer: allow plaintext alerts in early 1.3 HS.
Some TLS 1.3 implementations send plaintext alerts (e.g. for an unknown
certificate issuer) early in the handshake.

Trying to decrypt these messages will produce a decrypt error (because
they're plaintext!). We also don't want to allow plaintext alerts to be
received after encrypted records have been exchanged, since this could
allow an active adversary to inject alerts.

As a compromise to support clients that send a plaintext alert before
any encrypted data, we adjust the deframer in this commit to pass
through plaintext alerts iff:

* The message type is alert, (e.g. not application data, etc)
* There have been no encrypted records received yet.
* The message payload is no more than 2 bytes in size (matching an
  expected plaintext alert payload).
* The negotiated protocol version is TLS 1.3 - in TLS 1.2 the CCS
  messages make whether to expect plaintext or not unambiguous. It's
  only for TLS 1.3 that we need the heuristics mentioned above.

This retains protection against plaintext alerts being sent after
encrypted content while still allowing the server to log the correct
alert in the early-handshake condition, instead of a decrypt error.
2023-08-08 15:06:06 +00:00
Daniel McCarney 17a7e17534 crypto: separate module dir, ring sub-module.
For better code organization this commit moves the generic crypto
interface code from `src/crypto.rs` to `src/crypto/lib.rs`.

The *ring* specific code implementing the generic interfaces is moved to
`src/crypto/ring.rs` as a sub-module of `crypto. All imports are
adjusted accordingly.

This has the advantage of leaving `src/crypto/lib.rs` small, and without
any *ring* specific imports. In the future we may choose to feature-gate
the ring sub-module to allow building the crate without a dependency on
ring.
2023-07-18 17:47:43 +00:00
Dirkjan Ochtman e1860c91a8 crypto: parametrize config types with crypto provider 2023-07-18 17:47:43 +00:00
Daniel McCarney ff5d3e32e4 deps: update rustls-webpki.
This commit updates the webpki dependency of rustls to v0.101.0,
the release that adds CRL support.
2023-07-05 11:34:11 -04:00
Joseph Birr-Pixton ae4ca3290b Cease relying on webpki crate for DNS name types
This introduces similar but simplified `DnsName` and
`DnsNameRef` types.

Fuzz the `client::ServerName` type that exposes this
surface.
2023-06-22 11:57:34 +01:00
Daniel McCarney 18f42bba16 fuzz: fix unused Result clippy finding.
```
warning: unused `std::result::Result` that must be used
  --> fuzzers/persist.rs:14:5
   |
14 |     T::read(&mut rdr);
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
   = note: this `Result` may be an `Err` variant, which should be handled
```
2023-03-20 16:08:55 +01:00
Daniel McCarney ca5725747a fuzz: cargo fmt updates 2023-03-20 16:08:55 +01:00
Daniel McCarney da19f2b069 docs: add small README for fuzz testing suite.
This commit adds a README to the `fuzz` subdirectory of the project
root. The README has a few small pointers to help a developer get
started running the fuzz tests locally, and a link to the upstream
cargo-fuzz docs for more information.
2023-03-03 19:08:13 +01:00
Joseph Birr-Pixton 4ad8b1f432 fuzzer client/server: process packets 2023-01-27 11:19:29 +00:00
Joseph Birr-Pixton eb191d0cc4 Remove opaque StoresClientSessions interface 2023-01-24 13:53:34 +00:00
Dirkjan Ochtman 1acd7a7139 deframer: join handshake messages in deframer buffer 2023-01-17 21:17:13 +01:00
Dirkjan Ochtman c3a84dedae deframer: derive Default implementation 2023-01-17 21:17:13 +01:00
Dirkjan Ochtman 6555b9f630 deframer: move decryption into deframer 2023-01-17 21:17:13 +01:00
Dirkjan Ochtman 6e6baa91e7 Upgrade to 2021 edition 2023-01-13 12:11:26 +01:00
Dirkjan Ochtman 9e657be6b9 hsjoiner: simplify awkward message type checking API 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman 279f88fb26 hsjoiner: lazily parse messages from the handshake joiner 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman 3356e3c705 hsjoiner: abstract over implementation details 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman dbbb4eafc0 hsjoiner: clarify the return type for take_message() 2023-01-05 08:41:51 +01:00
Dirkjan Ochtman 54354c66ab deframer: abstract over internal state 2022-10-23 10:58:48 +02:00
Jacob Hoffman-Andrews a94a0055e1
MessageFragmenter: return an iterator (#1050)
This avoids a couple of unnecessary allocations: the individual Payloads of the
fragmented messages were allocating and filling a Vec, and the call sites were
allocating a VecDeque to be filled with messages.

Instead, always return an iterator of BorrowedPlainMessage, which the caller can
iterate over.
2022-06-13 10:30:45 +02:00
Jacob Hoffman-Andrews dde28baec1 Replace MessageFragmenter::new with impl Default
Previously there were two paths that would check that a max_fragment_size was in
the acceptable range. Now there's just one path: calling set_max_fragment_size.

This provides a way to construct a MessageFragmenter with the default fragment
size that is error-free.
2022-05-30 10:20:36 +02:00
Brian Smith 9159a82c33 Use the new feature resolver (`resolver = "2"`).
Use the new feature resolver stablized in Rust 1.51.0 to improve how
features are handled.
2022-01-14 00:28:46 +01:00
Joseph Birr-Pixton de205650f7 Fix persistence fuzz targets 2021-11-14 10:24:06 +00:00
Dirkjan Ochtman 42e624bbe2 Keep Certificate Transparency support implicitly off by default 2021-09-20 22:39:23 +02:00
Dirkjan Ochtman 74d9c5641b fuzz: remove unused imports 2021-09-18 20:48:39 +02:00
Dirkjan Ochtman 8081a3462f Configure certificate transparency logs in a separate step 2021-09-18 20:48:39 +02:00