Commit Graph

2566 Commits

Author SHA1 Message Date
Dirkjan Ochtman 047658675c Merge pki-types history into rustls monorepo 2023-11-20 11:50:40 +01:00
Joseph Birr-Pixton a3bf6ba24a bogo_shim.rs: fully support aws-lc-rs provider
This was only partially ported, but built due to feature unification
from other crates in the workspace.

Unconditionally use a provider, and wrap certificate signature
operations rather than using (ring-only) `default_verify_tls12_signature`
et al.
2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton cd81f32592 quic: give helpful error if used with unsuitable suite
Now Tls13CipherSuite can omit QUIC support, detect and error
on the case that all the configured suites are TLS1.3-capable
but QUIC-incapable.
2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton c26548337e Filter cipher suite offer and acceptance for QUIC
In QUIC connections, we shouldn't offer or accept cipher suites
that have `Tls13CipherSuite::quic` as `None`.  So introduce
`usable_for_protocol` on `SupportedCipherSuite`, and
use it to extend `reduce_given_version` into `reduce_given_version_and_protocol`.
2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton fdd1f8dd4f Move key usage limits up into `CipherSuiteCommon` 2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton cfec92ce70 Make Tls13CipherSuite::quic optional and public
The goal is to make it possible for provider-example to exist
without implementing (eg) QUIC header protection.

This introduces some knock-on requirements for other types/functions
to be the public, so `quic::Algorithm` can be implemented outside
the crate.
2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton 538cb78f83 Abolish quic crate feature
This reveals that bogo_shim fails to build for `--no-default-features --features tls12`.
Feature gate the entire program on `ring | aws-lc-rs`.
2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton 13550cf013 Make it easier to feature-gate entire bogo_shim example 2023-11-17 19:27:21 +00:00
Joseph Birr-Pixton e5a1822298 quic: simplify `packet_key`/`header_protection_key` trait
If we put the key derivation on "our" side of the trait, we avoid
publicising low-level key schedule functions like hkdf_expand_label
& hkdf_expand_label_aead_key, and quic::Version.

Instead we just provide the `AeadKey` and `Iv`, which makes these
interfaces very similar to those in `Tls13AeadAlgorithm`.
2023-11-17 19:27:21 +00:00
Steve Fan e5a4f13741 add server example for example provider 2023-11-17 17:26:43 +00:00
Joseph Birr-Pixton e3e1d8352b provider-example: normalise import order/grouping 2023-11-17 17:26:43 +00:00
Daniel McCarney b7a6091ab4 provider-example: HPKE provider w/ hpke-rs & rust-crypto
This commit implements the Rustls HPKE provider traits using hpke-rs[0]
with the rust-crypto backend.

Since HPKE is not yet used in Rustls (but will be for ECH support),
a unit test based on the RFC 9180 test vectors is added.

Likely in the future we will want to move this test somewhere outside of
the provider-example crate and use it to test a *ring* HPKE
implementation using the same test vector data.

[0]: https://github.com/franziskuskiefer/hpke-rs
2023-11-16 19:32:49 +00:00
Daniel McCarney b4f0bd96a2 crypto: add HPKE module and traits
This commit introduces a trait for a hybrid public key encryption (HPKE)
provider. HPKE is specified in RFC 9180[0], and is a pre-requisite for
implementing encrypted client hello (ECH).

Implementations of this trait can use the cryptographic provider of
their choice to provide HPKE using existing primitives from the crypto
provider.

We've tailored the HPKE trait in Rustls to just what is required for
ECH, e.g. it doesn't support modes other than the unauthenticated 'base'
mode, and it only offers the "single-shot" APIs.

[0]: https://www.rfc-editor.org/rfc/rfc9180
2023-11-16 19:32:49 +00:00
Christian Poveda 63ddf03a7c add `encrypted_payload_len` to `MessageEncrypter` 2023-11-16 19:15:54 +00:00
Dirkjan Ochtman c15768989c Update semver-compatible versions (again) 2023-11-14 19:23:54 +00:00
Daniel McCarney 1bf56c0e56 lib: export crate::error::OtherError
The `error::Error` enum was updated with a `Error::Other` variant that
holds an `error::OtherError` instance. We neglected to export the
`OtherError` type, so this variant ends up opaque. This commit exports
the type so that crate-external users can instantiate an `Error::Other`
variant as needed.
2023-11-14 19:18:24 +00: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