Commit Graph

2675 Commits

Author SHA1 Message Date
Joseph Birr-Pixton 327444fdb8 Expose FIPS "service indicator"
This means a `ClientConfig` and `ServerConfig` can be asked whether it
is in fips mode, and it answers by asking the same of all its
constituent cryptography.
2023-12-07 13:45:27 +00:00
Joseph Birr-Pixton afe43b0213 aws-lc-rs: avoid chaha20poly1305 for ticketer algorithm 2023-12-07 13:44:23 +00:00
Joseph Birr-Pixton 82b1e3f1db aws-lc-rs: enable FIPS mode 2023-12-07 11:59:09 +00:00
Dirkjan Ochtman 976e522a0d suites: move Debug impl below inherent impl 2023-12-07 09:56:50 +00:00
Dirkjan Ochtman 2800ad712e quic: require that PacketKey and HeaderProtectionKey are Send + sync 2023-12-07 09:56:50 +00:00
Christian Poveda 1118c74cc0 Mark `SupportedProtocolVersion` as non-exhaustive 2023-12-07 08:35:10 +00:00
Daniel McCarney 495acf3444 crypto: explain TLS 1.2 version in TLS 1.3 message encrypters
Without the context of RFC 8446 in your mind the use of the
`ProtocolVersion::TLSv1_2` constant in the TLS 1.3 `MessageEncrypter`
implementations appears like an oversight or copy/paste error. This
commit adds a brief explanatory comment.
2023-12-06 18:41:59 +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
Christian Poveda 3ec3641662 Introduce `DeframerSliceBuffer` 2023-12-06 18:15:37 +00:00
Jorge Aparicio 17982e92b1 make append_hs generic 2023-12-06 18:15:37 +00:00
Jorge Aparicio 4505605c1a make MessageDeframer unbuffered 2023-12-06 18:15:37 +00:00
Jorge Aparicio 756bab942f extract out MessageDeframer buffer 2023-12-06 18:15:37 +00:00
Christian Poveda e1e3f09b48 Make `assert_len` more succint 2023-12-06 18:15:37 +00:00
Jorge Aparicio 575157ffe9 deframer: move helpers after tests 2023-12-06 18:15:37 +00:00
Geoffroy Couprie 6ff948efba remove the TLS 1.2 session ticket on DecryptError
if for some reason the recorded session ticket is invalid or decoded
incorrectly by the server, we can get into a case where the resumption
handshake happens, and right after the ChangeCipherSpec message, the
server sends an encrypted handhsake message using the invalid ticket,
and the client rejects it with the BadRecordMAC alert.
Unfortunately, if the calling code retries the connection, if it will
try again with the same ticket and obtain the same result.
This commit makes sure that if we fail to decrypt the first message, we
will remove the session ticket for this server, to start from cratch on
the next connection.
2023-12-06 15:36:57 +00:00
Dirkjan Ochtman 85eed3a6ca provider-example: consistently format versions 2023-12-06 14:25:09 +00:00
Dirkjan Ochtman c9836a61a2 provider-example: minor tweaks, mostly stylistic 2023-12-06 14:25:09 +00:00
aashish 8a72972425 doc: fix outdated documentation 2023-12-05 22:00:45 +00:00
Jorge Aparicio f7c12c02c0 CI: build provider-example in no-std mode 2023-12-05 20:28:54 +00:00
Jorge Aparicio be41a034a9 introduce a "std" Cargo feature 2023-12-05 20:28:54 +00:00
Jorge Aparicio 57c5e19ac9 disable unused Cargo features that use libstd API 2023-12-05 20:28:54 +00:00
Jorge Aparicio 8647315c6a put deps used only by examples under dev-dependencies 2023-12-05 20:28:54 +00:00
Jorge Aparicio d6790d4b0f provider-example: switch to core prelude
in preparation for no-std support
2023-12-05 20:28:54 +00:00
girlbuzz e051f5c172
minor fix: fix comment that incorrectly says "google.com" instead of "rust-lang.org" (#1667)
fix inaccurate comment
2023-12-05 09:25:02 -05:00
Jacob Hoffman-Andrews 6845c013cb doc: remove `crate::` prefix for links
Instead, use `#[cfg(doc)]` to conditionally import names that we want to
use in the docs. This provides a user-friendlier link name.
2023-12-04 17:58:51 +00:00
Dirkjan Ochtman 74321cfbb1 Update semver-compatible dependencies 2023-12-04 09:46:53 +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 553f400785 docs: link to SignatureSchemes from WebPkiSupportedAlgorithms 2023-12-01 18:27:53 +00:00
Daniel McCarney 822f86e822 docs: link to ActiveKeyExchange::complete from SharedSecret
Also drops "as a value".
2023-12-01 18:27:53 +00:00
Daniel McCarney e34d46d46d docs: link to SupportedKxGroup for ActiveKeyExchange doc 2023-12-01 18:27:53 +00:00
Daniel McCarney a572b301f5 msgs: docstrings for KeyExchangeAlgorithms
This type appears in the 'crypto' mod docs without any accompanying
text. This commit adds some.
2023-12-01 18:27:53 +00:00
Daniel McCarney e7cb24fe4e docs: re-order feature descriptions
This puts ring, aws-lc-rs, and the tls12 features up front. They're
likely more interesting than the logging and read_buf features that are
increasingly niche.
2023-12-01 18:27:53 +00:00
Daniel McCarney 50e43cebbb docs: consistently describe default features
Consistently describe te default features, include that *ring* is
default enabled.
2023-12-01 18:27:53 +00:00
Daniel McCarney 4f5e24d84b docs: clarify tlsserver-mio/tlsclient-mio links
* Use their proper filenames, with the `-mio` suffix.
* Link to `mio` crate.
2023-12-01 18:27:53 +00:00
Daniel McCarney 5ec414c266 docs: describe webpki-roots as simplest, not recommended
Also link to the crate.
2023-12-01 18:27:53 +00:00
Daniel McCarney d0aef3a11c docs: fix stale ref. to CryptProvider being a trait 2023-12-01 18:27:53 +00:00
Jacob Hoffman-Andrews cefd6c4bc6 remove InvalidKeyError
The per-provider key loading functions returned this singleton error,
but it was usually then wrapped into Error::General("invalid private key").
That means the singleton error is unnecessary API surface, but also
it means potentially valuable information is lost.

Move the wrapping into `Error::General` to a lower level, add detail
about which specific parsing operation failed, and pass along error
details from the lower-level library.
2023-12-01 17:41:24 +00:00
Jacob Hoffman-Andrews b1f5fef16f api: use OtherError consistently
`CertificateError` and `CertRevocationListError` both had an `Other` variant
containing `Arc<dyn StdError + Send + Sync>`, while `rustls::Error` used
the newtype `OtherError`. Use `OtherError` in all three cases.

Also, implement `StdError` and `Display` for `OtherError`, and
specifically implement `source()` to return the underlying error.
2023-12-01 10:00:33 +00:00
Jacob Hoffman-Andrews f83bc90969 Prf: document guarantees and take &mut [u8; 48]
Also document at the call site for `for_key_exchange` why those guarantees
are upheld.

I didn't get far enough to document where those guarantees are upheld at
the call sites for `for_secret`, but they are relied upon by one of the
implementations:

303b3ff97d/rustls/src/crypto/aws_lc_rs/tls12.rs (L407-L412)
2023-12-01 08:49:37 +00:00
Jacob Hoffman-Andrews 022042f17c doc: make it easier to find changelog
Many projects use CHANGELOG.md to convey their list of changes. Add a
link there. In README.md, instead of describing "release history",
use the "Changelog" terminology.
2023-12-01 08:40:16 +00:00
Jacob Hoffman-Andrews 303b3ff97d doc: add detail on UnexpectedEof
Add documentation at the top level, and link to that documentation in
the error message.
2023-11-30 18:20:36 +00:00
Jacob Hoffman-Andrews 58c2d26ed0 api: move CipherSuiteCommon into crypto
The top level of the crate is meant for "paved path" exports.

In 0.21.x, this type was in `cipher_suites`, along with a few other
types that got moved to specific crypto providers. Moving this to
`crypto` instead of re-exporting under its old name in `cipher_suites`
seems acceptable, because it will mainly be used in implementing crypto
providers. Also, its internals have changed significantly so there is
already churn for this type.
2023-11-30 17:44:07 +00:00
Daniel McCarney 90b20a2567 docs: update README project membership
* Leadership -> membership.
* Clarify roles per member.
* List full-time members and funding source.
* Add Josh Aas, project management.
* Link to GitHub profiles.
2023-11-30 17:10:43 +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 b4971785fd crypto: CryptoProvider is-a KeyProvider -> has-a
In preparation for moving to a struct based model where
a `CryptoProvider` has a `&'static dyn KeyProvider` field, this commit
splits the `KeyProvider` trait from the `CryptoProvider` trait. In its
place `CryptoProvider` gets a `key_provider(&self)` fn that acts as
a stand-in for what will be a field in the struct based approach.
2023-11-30 15:53:39 +00:00
Daniel McCarney 2b791938bb crypto: split out KeyProvider trait
We're working towards making `CryptoProvider` a struct holding distinct
elements to be used for cryptography. To support this the
`load_private_key` fn needs to be lifted to a new trait, `KeyProvider`.
We can hold a `&dyn KeyProvider` in the to-be-added struct to invoke
as required for `load_private_key`.

This commit adds the new trait, includes `KeyProvider` in the existing
`CryptoProvider` trait bounds, and updates the *ring*, aws-lc-rs, and
provider example crypto providers to implement `KeyProvider`.
2023-11-30 15:53:39 +00:00
Daniel McCarney 3b5cf17ade crypto: CryptoProvider is-a SecureRandom -> has-a
In preparation for moving to a struct based model where
a `CryptoProvider` has a `&'static dyn SecureRandom` field, this commit
splits the `SecureRandom` trait from the `CryptoProvider` trait. In its
place `CryptoProvider` gets a `secure_random(&self)` fn that acts as
a stand-in for what will be a field in the struct based approach.
2023-11-30 15:53:39 +00:00