mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-09 01:13:42 +00:00
TLS 1.3 server: move crypto_init after protocol negotiation
This reduces the workflows where psa_crypto_init is called when not necessary: it won't be called when a dual-version server receives a 1.2-only ClientHello. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
aa6ef7da50
commit
57dbd69945
@ -1412,6 +1412,12 @@ static int ssl_tls13_parse_client_hello(mbedtls_ssl_context *ssl,
|
||||
ssl->session_negotiate->tls_version = MBEDTLS_SSL_VERSION_TLS1_3;
|
||||
ssl->session_negotiate->endpoint = ssl->conf->endpoint;
|
||||
|
||||
/* Before doing any crypto, make sure we can. */
|
||||
ret = mbedtls_ssl_tls13_crypto_init(ssl);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* We are negotiating the version 1.3 of the protocol. Do what we have
|
||||
* postponed: copy of the client random bytes, copy of the legacy session
|
||||
@ -1948,11 +1954,6 @@ static int ssl_tls13_process_client_hello(mbedtls_ssl_context *ssl)
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG(2, ("=> parse client hello"));
|
||||
|
||||
ret = mbedtls_ssl_tls13_crypto_init(ssl);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
MBEDTLS_SSL_PROC_CHK(mbedtls_ssl_tls13_fetch_handshake_msg(
|
||||
ssl, MBEDTLS_SSL_HS_CLIENT_HELLO,
|
||||
&buf, &buflen));
|
||||
|
Loading…
x
Reference in New Issue
Block a user