client: make emit_client_hello_for_retry fallible

In order to support ECH we need to be prepared for
`emit_client_hello_for_retry` to return an `Error` where it was
otherwise infallible - this can occur (for e.g.) if the HPKE provider we
use for ECH encryption fails.

This commit changes `emit_client_hello_for_retry` to return
`NextStateOrError` instead of `NextState` in preparation for that.
This commit is contained in:
Daniel McCarney 2024-04-12 11:04:47 -04:00
parent 1f35ba07a2
commit 1d09958864
1 changed files with 7 additions and 7 deletions

View File

@ -157,7 +157,7 @@ pub(super) fn start_handshake(
Some(())
});
Ok(emit_client_hello_for_retry(
emit_client_hello_for_retry(
transcript_buffer,
None,
key_share,
@ -175,7 +175,7 @@ pub(super) fn start_handshake(
server_name,
},
cx,
))
)
}
struct ExpectServerHello {
@ -211,7 +211,7 @@ fn emit_client_hello_for_retry(
suite: Option<SupportedCipherSuite>,
mut input: ClientHelloInput,
cx: &mut ClientContext<'_>,
) -> NextState<'static> {
) -> NextStateOrError<'static> {
let config = &input.config;
let support_tls12 = config.supports_version(ProtocolVersion::TLSv1_2) && !cx.common.is_quic();
let support_tls13 = config.supports_version(ProtocolVersion::TLSv1_3);
@ -403,11 +403,11 @@ fn emit_client_hello_for_retry(
suite,
};
if support_tls13 && retryreq.is_none() {
Ok(if support_tls13 && retryreq.is_none() {
Box::new(ExpectServerHelloOrHelloRetryRequest { next, extra_exts })
} else {
Box::new(next)
}
})
}
/// Prepare resumption with the session state retrieved from storage.
@ -887,7 +887,7 @@ impl ExpectServerHelloOrHelloRetryRequest {
_ => offered_key_share,
};
Ok(emit_client_hello_for_retry(
emit_client_hello_for_retry(
transcript_buffer,
Some(hrr),
Some(key_share),
@ -895,7 +895,7 @@ impl ExpectServerHelloOrHelloRetryRequest {
Some(cs),
self.next.input,
cx,
))
)
}
}