Commit Graph
1168 Commits
Author SHA1 Message Date
Dirkjan Ochtman 2c643313f0 Clarify availability of client auth state in HandshakeHash 2021-03-08 12:55:26 +01:00
Dirkjan Ochtman aa70cc04eb Eliminate unwrapping in HandshakeHash 2021-03-08 12:45:29 +01:00
Dirkjan Ochtman ce698b1123 Detach emit methods from CompleteClientHelloHandling state 2021-03-08 12:19:01 +01:00
Dirkjan Ochtman 7d700f200d Deduplicate arguments for start_resumption() 2021-03-08 11:57:12 +01:00
Dirkjan Ochtman f37ce5487e Detach emit methods from ExpectClientHello state 2021-03-08 11:47:49 +01:00
Dirkjan Ochtman 70bfd7e977 Move HandshakeHash into handshake states 2021-03-08 10:45:42 +01:00
Dirkjan Ochtman f12604ada5 Clarify flow in server ExpectCertificate states 2021-03-08 10:09:34 +01:00
Dirkjan Ochtman 9c2533a2f9 Inline creation of next states 2021-03-08 10:09:34 +01:00
Dirkjan Ochtman f8cc38a7aa Add some documentation about handshake state machines 2021-03-07 14:57:47 +01:00
Benjamin Saunders 32a143fe7f Support stable QUIC transport parameters handshake extension
Preserves the prior extension for backwards-compatibility on the wire,
requiring an API tweak for the application to dictate which version to
be compatible with.
2021-03-07 13:41:41 +01:00
ABGH, C 1721e5188f Refactor ExpectClientKX to inline methods to avoid unwrapping implicit state 2021-02-24 19:18:35 +01:00
ABGH, C 57bacb308d Refactor hs::can_resume to avoid its callers unwrapping 2021-02-24 09:20:07 +01:00
ABGH, C 678c4a3b68 Refactor ExpectClientKX::into_expect_tls12_certificate_verify to avoid unwrapping 2021-02-24 07:13:23 +01:00
Joseph Birr-Pixton f06ed3f336 Improve docs. 2021-02-21 19:12:41 +00:00
Joseph Birr-Pixton 88d3776511 Hook curve selection into bogo_shim 2021-02-21 19:12:41 +00:00
Joseph Birr-Pixton 1e9c5e4763 Add test to exercise helloretryrequest
This is also a regression test for the HRR race condition found recently.
2021-02-21 19:12:41 +00:00
Joseph Birr-Pixton 34c440b5d2 Refactor key exchange code
Builds on the previous commit, and prepares for the ability to discard
unused key exchange algorithms at link-time.

This varies some server error handling -- the precise errors aren't
specified by the standard.
2021-02-21 19:12:41 +00:00
Thom Wiggers 8c823196e2 Allow selecting supported groups in config 2021-02-21 19:12:41 +00:00
Dirkjan Ochtman f3449a6a76 Deduplicate server ticket emitter code 2021-02-21 10:16:06 +00:00
Brian Smith 34ce10945b Client: Remove sent_tls13_fake_ccs from HandshakeDetails.
It is only used by the client, so it shouldn't be in `HandshakeDetails`, which
is shared between the client and the server. Further, it is only used for the
initial messages, so there's no need to store it for the whole handshake.

This refactoring enables further refactorings to clarify the state machine. In
particular, this allows us to clear up the unwrapping logic related to
`fill_in_psk_binder`, but this is also useful for other refactorings, including
the ECH implementation.
2021-02-21 09:55:10 +00:00
Stiopa Koltsov 138bf01c15 What is the reason webpki operation failed?
I don't know if it's me or everyone, but debugging TLS setup issues
is usually non-trivial.

For example, right now I'm fighting with this issue:
an `openssl s_client` works fine, but a client implemented with
rustls fails with an error:

```
Custom { kind: InvalidData, error: WebPKIError(UnknownIssuer) }
```

`WebPKIError` can be emitted for several reasons. This PR adds the
operation name to the error. I have identified five operations:
* validate server certificate
* validate client certificate
* validate certificate for DNS name
* parse the certificate
* verify message signature

The error can be expanded further later, but even this basic list
will provide some clue where to look.
2021-02-21 09:50:19 +00:00
Brian Smith eb8b2b8901 Store SupportedCipherSuite in ClientSessionValue.
Do the mapping to `SupportedCipherSuite` at the time `ClientSessionValue` is
constructed so that we don't have to look it up all the time. This eliminates
some unwrapping.

Simplify the implementation of `find_cipher_suite` to match what is done during
`ClientSessionValue` decoding.
2021-02-19 21:12:57 +01:00
Brian Smith 8dffd2a7e2 Client: Always randomize session ID unless doing legacy resumption.
This fixes the TLS13SessionID-TLS13 Bogo test, so enable it.

Inline `random_sessionid_for_ticket` into its caller so all the
session ID calculation is in one spot.
2021-02-19 16:08:10 +01:00
Stiopa Koltsov f197dcf6bf derive Debug for Stream and StreamOwned 2021-02-19 16:01:22 +01:00
Brian Smith 37c5eb8c71 Client: Make some mut references non-mut where the mutability is not used. 2021-02-19 10:08:08 +01:00
Brian Smith 1b253873a3 Client: Clarify when server cert details are filled in and fully available.
Clarify when the full `ServerCertDetails` and related inputs are available
*with their correct and complete values*. Now the point at which
`ServerCertDetails` is constructed is the earliest point in which the
validation could happen.

Drop the `ServerCertDetails` immediately after certificate validation to
free up memory. The TLS 1.3 state machine was holding onto the
`ServerCertDetails` for many messages longer than needed.
2021-02-17 10:17:20 +01:00
ABGH, C 2e4b6529f5 Refactor version negotiation to avoid unwrapping 2021-02-16 22:28:45 +01:00
Brian Smith d3c5ff6e57 TLS 1.2 Client: Thread negotiated cipher suite through state machine.
Avoid using `get_suite_assert()`.
2021-02-16 10:17:16 +01:00
Brian Smith c5bc060770 TLS 1.2: Add cipher suite to SessionSecrets.
Allow retrieving the cipher suite from `SessionSecrets` to reduce usage
of `get_suite_assert()`.
2021-02-16 10:17:16 +01:00
Brian Smith 38740a4464 Client: Remove some superfluous use of get_suite_assert().
Avoid calling `get_suite_assert()` when the cipher suite is already known.

Pass the cipher suite as a paramter to other functions.

Call `get_suite_assert()` fewer times (at most once) in other functions,
to make further refactoring away of these calls easier.
2021-02-16 10:17:16 +01:00
Brian Smith 2998b2f8e0 Client: Move session ID initialization to emit_initial_client_hello.
The session ID is not allowed to change between the initial client hello and
a retry client hello.
2021-02-16 09:52:45 +01:00
Dirkjan Ochtman b419824610 Remove CertifiedKey::has_sct_list()
This became unused in #505. It was originally added 4 years ago in
df361f832b, so it seems there was no
specific reason for making it public. In addition, we already have
some breaking API changes lined up, so might as well remove this.
2021-02-15 15:09:21 +01:00
Brian Smith ebbf92f04b Simplify the handling of SCT and OCSP sending in the server.
If we're not going to send one of these, then drop it as early as
possible to reduce memory overhead, so that at the time of sending,
`CertifiedKey` will only contain it if it is to be sent. This makes
the boolean flags that previously controlled this redundant, so
remove them.

In the process, remove some unwrapping.
2021-02-14 16:10:50 +00:00
Brian Smith 47495672e5 Client: Lookup session once per connection.
Only do the lookup of the session during the initial client hello.
Otherwise, if we do a session lookup during retries, the session cache
may have changed and we might get back a different session, e.g. because
a different connection modified the session cache in the interim.
2021-02-14 15:55:54 +00:00
Brian Smith 0d6b612104 Client: Thread hash_at_client_recvd_server_hello through the state machine.
Clarify the exact lifetime of this value, removing the `unwraps()` currently
in the code.
2021-02-14 15:48:46 +00:00
Joseph Birr-Pixton 7117a805e0 Adjust default cipher suite order:
- prefer aes to not-aes
- prefer ecdsa to rsa (in fact this doesn't make much of a difference,
  unless your peer has both kinds of cert).
- prefer aes-256 to aes-128

Add a rationale section to the manual for this.
2021-02-14 15:39:50 +00:00
Thom Wiggers 9c546cf7f6 Prevent panic while panicking in tests/api.rs
While playing around with rustls I broke the `client_cert_resolve` test and if the `ResolvesClientCert` implementation for `ClientCheckCertResolve` panics, then it will panic again in the `drop` call leading to an illegal instruction error.
2021-02-12 20:34:16 +01:00
Dirkjan Ochtman e4655f7983 Clarify that message header decoding doesn't panic 2021-02-11 22:45:12 +01:00
ABGH, C f3086690c8 Remove unwraps from tls13 handle_client_hello 2021-02-11 21:10:37 +01:00
Brian Smith 614c362927 Codec: Add bounds checking to decode functions.
The callers probably already ensured the bounds are correct, but check
ourselves.
2021-02-11 21:03:02 +01:00
Brian Smith 670d34250a Codec: Simplify integer encoding functions & clarify assumptions made.
It isn't clear whether the `pub_*` functions are intended to accept an output
buffer larger than needed, but they definitely don't work when the output
buffer is smaller than needed. Clarify this.

Instead of implementing big-endian encoding manually, use the standard library
implementations.

Removing the use of `try_into()` in these functions is deferred until later.
This is just making the panicking explicit instead of implicit.
2021-02-11 20:56:10 +01:00
ABGH, C 0afa7a55c9 Remove unwraps in ExpectFinished::handle 2021-02-11 09:55:42 +01:00
ABGH, C 112a54577b Remove unwraps in ExpectServerDone::handle 2021-02-11 09:55:17 +01:00
ABGH, C edf2d18d11 Remove unwraps in save_session 2021-02-11 09:50:39 +01:00
ABGH, C 52cb4920a6 Refactor ExpectServerHelloOrHelloRetryRequest::handle_hello_retry_request to avoid unwrapping 2021-02-11 09:23:04 +01:00
ABGH, C 0532bcdbd3 Remove unwrap in process_alpn_protocol 2021-02-11 09:22:13 +01:00
ABGH, C e3d91af432 Remove unwrap in emit_certverify_tls13 2021-02-11 09:21:24 +01:00
ABGH, C 8b2fea3918 Remove unwrap in tls13 emit_stateless_ticket 2021-02-10 22:35:30 +01:00
ABGH, C 48447d2d14 Remove unwraps in ExpectClientHello::handle 2021-02-10 20:56:08 +01:00
ABGH, C 5e2d6e2773 Remove unwrap in has_keyshare_extension_with_duplicates 2021-02-10 20:46:38 +01:00