Commit Graph

2833 Commits

Author SHA1 Message Date
Sean McGrail d805e1fdfd Add 'fips' Cargo feature
Add `rustls::crypto::default_fips_provider()` behind this
feature.
2024-01-16 11:31:02 +00:00
Joseph Birr-Pixton e1149286ff 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.
2024-01-16 11:31:02 +00:00
Joseph Birr-Pixton 12bf74d2cf aws-lc-rs: avoid chaha20poly1305 for ticketer algorithm 2024-01-16 11:31:02 +00:00
Daniel McCarney fa81bd23c0 deps: serde_json v1.0.110 -> v1.0.111 2024-01-15 16:39:01 +00:00
Daniel McCarney 50ae4c1d65 deps: base64 v0.21.5 -> v0.21.7 2024-01-15 16:39:01 +00:00
Daniel McCarney 4dc47b8104 deps: serde v1.0.194 -> v1.0.195 2024-01-15 16:39:01 +00:00
Daniel McCarney 06069d5e38 deps: clap v4.4.12 -> v4.4.16 2024-01-15 16:39:01 +00:00
Nick Kirby 021933ce7d Update hs.rs
Fix typo in comment
2024-01-13 15:51:18 +00:00
Goncalo Gomes c296594db3 Randomize ClientHello extensions
Google Chrome project proposes Client Hello extensions should be
randomized in order to prevent fingerprinting [1]

This commit sorts all the extensions that have been sent in the same
order as before by using a seed that is saved at the start of the
connection. And keeps the PSK extension in the end.

[1] https://chromestatus.com/feature/5124606246518784

resolves #1313

Co-authored-by: Joseph Birr-Pixton <jpixton@gmail.com>
2024-01-12 16:45:17 +00:00
Joseph Birr-Pixton 432ceca9b8 Partially support -verify-prefs
This exits with BOGO_NACK if an unsupported verification algorithm is
requested.  That is enough to enable 78 more test cases.
2024-01-10 15:59:34 +00:00
Joseph Birr-Pixton 235008b8d5 Take newer bogo version
- implement -shim-id option
- ignore -ipv6 option
- track name change on ALPS test
2024-01-10 15:59:34 +00:00
Daniel McCarney 25135a06f0 hash_hs: derive Clone for HandshakeHash[Buffer]
For client ECH support we'll need to be able to fork (e.g. clone) the
`HandshakeHashBuffer` and `HandshakeHash` types used to maintain the
client transcript.

For ECH confirmation we'll fork the existing hash(buffer), add some specially
encoded messages, and then use the hash state to derive a shared secret.
If the secret matches an expected value we'll use the original
`HandshakeHash`/`HandshakeHashBuffer`'s state from before our twiddling
to continue the handshake.
2024-01-09 18:30:59 +00:00
Daniel McCarney f357aa0a3b hash_hs: rename get_xxx methods to avoid get_ prefix 2024-01-09 18:30:59 +00:00
Christian Poveda 49d5d4c976 decode CertificateChain without allocating
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda a27c713b37 make HandshakePayload decoding partially non-allocating
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda 65370b8de1 prepare State trait to handle borrowed types
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda 0423bb69e7 make MessagePayload decoding partially non-allocating
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda 85a175450f make Payload::read non-allocating
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda 8ddbc77b21 make ConnectionCommon::deframe return a borrowed message
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda d8abdb3e0a add a Borrowed variant to Payload
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda d2b95ae772 prepare Codec for non-allocating decoding
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda 4e214a091c add copy_within logic to DeframerBuffer::copy
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda 0d88ef5564 add and use RawSlice to return slices from MessageDeframer::pop
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda a2d4e720c5 simplify MessageDeframer tests with util functions
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda a4ddaa2b6d switch Decrypted to BorrowedPlainMessage 2024-01-09 17:53:17 +00:00
Christian Poveda dc4cf38c03 make Decrypt trait use Borrowed{Opaque,Plain}Message 2024-01-09 17:53:17 +00:00
Christian Poveda 1b551e712e use BorrowedOpaqueMessage in MessageDeframer 2024-01-09 17:53:17 +00:00
Christian Poveda aa820d1e38 introduce and expose BorrowedOpaqueMessage
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda e6dede5f5f introduce and expose BorrowedPayload
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda ef41a6dbd6 introduce ReaderMut
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda b068ca3643 maximize lifetimes in Reader API
Co-authored-by: Jorge Aparicio <jorge.aparicio@ferrous-systems.com>
2024-01-09 17:53:17 +00:00
Christian Poveda b1c0a29b6a Batch discard operations 2024-01-09 17:53:17 +00:00
Daniel McCarney ab774c73cd handshake: derive Clone on a few more messages
To support implementing client-side ECH we'll need to clone a few
message types to make modifications. This commit adds derived `Clone`
implementations for `ClientHelloPayload`, `HelloRetryExtension` and
`ServerHelloPayload`.
2024-01-09 16:26:58 +00:00
Daniel McCarney e521e94912 handshake: derive PartialEq on more types
As part of implementing client-side ECH support we will want to be able
to return a `PeerIncompatible` error variant that includes ECH configs
to use for potential retry.

Since `PeerIncompatible` derives `PartialEq` we need to thread
derivations of this trait down through the `EchConfig` and associated
types.
2024-01-09 16:26:58 +00:00
Daniel McCarney 1a2405a26e provider-example: clarify the hpke-rs backend 2024-01-09 15:29:07 +00:00
Daniel McCarney 166b598032 crypto: make EncapsulatedSecret derive Debug 2024-01-09 15:29:07 +00:00
Daniel McCarney e855192df6 crypto: tighten up HPKE lifetime bounds
In practice we need `'static` here to be able to easily hold `Box<dyn
HpkeSender>` and friends. Our existing provider implementation already
matches this lifetime bound.
2024-01-09 15:29:07 +00:00
Daniel McCarney 461c6936ce msgs: derive Copy for HpkeSymmetricCipherSuite
This type holds simple numeric identifiers and can be cheaply copied.
2024-01-09 15:29:07 +00:00
Daniel McCarney 9ab0139f5d crypto: add stateful HPKE interfaces
Encrypted Client Hello support requires that clients maintain the HPKE
sealer context between sending an initial client hello, and processing
a hello retry request, such that the subsequent client hello can re-use
the HPKE state.

This commit updates the HPKE trait to add `setup_sealer` and
`setup_opener` fns in addition to the "one-shot" APIs. New
`HpkeSealer` and `HpkeOpener` traits are used to represent the
stateful sender/receiver contexts in a backend neutral way.

The existing hpke-rs provider example is updated to implement the new
required traits and fns.
2024-01-09 15:29:07 +00:00
Daniel McCarney bd7122f150 hpke: reorder seal/open args, less terse arg names
* Move the public key/secret key arguments to be last, since they are
  "long lived".
* Rename `pk_r` -> `pub_key` and `sk_r` to `secret_key`. Reference RFC
  9180's terse names.
2024-01-09 15:29:07 +00:00
Daniel McCarney 962814eadb client: reorder ClientConfig fields by visibility
`pub` fields should appear first, then `pub(super)` ones.
2024-01-09 14:41:03 +00:00
Daniel McCarney be5a62294c client: order ClientConfig impls
The inherit `ClientConfig` impl should appear first, and then the
`Clone` impl.
2024-01-09 14:41:03 +00:00
Daniel McCarney 8285bf1b28 client: move TLs12Resumption enum down
The `ClientConfig` parts should appear before the types it references.
The `Tls12Resumption` enum should appear after the `Resumption` type
that uses it.
2024-01-09 14:41:03 +00:00
Benjamin Jurk 20ac87f64f examples: unbuffered-server: skip argv[0] 2024-01-08 12:09:04 +00:00
Benjamin Jurk 567d89227d examples: simpleserver: skip argv[0] & update doc comment 2024-01-08 12:09:04 +00:00
Joseph Birr-Pixton a3cc0bcb72 bogo: enable TLS13-Empty-Client-CA-List test
This acts as a regression test for the previous commit.  This also enables:

- TLS12-Server-CertReq-CA-List
- TLS13-Server-CertReq-CA-List
- Null-Client-CA-List
2024-01-05 16:31:50 +00:00
Joseph Birr-Pixton 9f79bac621 Don't add empty `certificate_authorities` extension 2024-01-05 16:31:50 +00:00
Daniel McCarney f1cfaec555 manual: add pointer to rustls-cng
This commit adds a small pointer to rustls-cng in the manual's section
on customizing private key usage.
2024-01-05 14:22:13 +00:00
Daniel McCarney fccff80241 crypto: KeyProvider pointer to customizing private key usage
The `KeyProvider` trait associted with the `CryptoProvider` struct is
specific to private key material that can be loaded from a DER
representation. For users that want to use private keys used through
a handle, or PKCS11 style interface an alternative integration approach
is needed.

This commit adds a doc string update to the `KeyProvider` to guide such
users to look at the Rustls manual's section on customizing private key
usage.
2024-01-05 14:22:13 +00:00
Daniel McCarney acdb721546 msgs: HandshakeMessagePayload::get_encoding_for_binder_signing -> encoding_for_binder_signing 2024-01-05 14:21:50 +00:00