mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-31 10:20:45 +00:00
tls13: srv: Postpone client random copy
To avoid doing it twice in case we eventually negotiate the version 1.2 of the protocol, postpone the copy of the client random bytes. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
6458239b36
commit
d540d995b2
@ -1241,6 +1241,7 @@ static int ssl_tls13_parse_client_hello(mbedtls_ssl_context *ssl,
|
|||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
const unsigned char *p = buf;
|
const unsigned char *p = buf;
|
||||||
|
const unsigned char *random;
|
||||||
size_t legacy_session_id_len;
|
size_t legacy_session_id_len;
|
||||||
size_t cipher_suites_len;
|
size_t cipher_suites_len;
|
||||||
const unsigned char *cipher_suites_end;
|
const unsigned char *cipher_suites_end;
|
||||||
@ -1297,10 +1298,7 @@ static int ssl_tls13_parse_client_hello(mbedtls_ssl_context *ssl,
|
|||||||
* with Random defined as:
|
* with Random defined as:
|
||||||
* opaque Random[32];
|
* opaque Random[32];
|
||||||
*/
|
*/
|
||||||
MBEDTLS_SSL_DEBUG_BUF(3, "client hello, random bytes",
|
random = p;
|
||||||
p, MBEDTLS_CLIENT_HELLO_RANDOM_LEN);
|
|
||||||
|
|
||||||
memcpy(&handshake->randbytes[0], p, MBEDTLS_CLIENT_HELLO_RANDOM_LEN);
|
|
||||||
p += MBEDTLS_CLIENT_HELLO_RANDOM_LEN;
|
p += MBEDTLS_CLIENT_HELLO_RANDOM_LEN;
|
||||||
|
|
||||||
/* ...
|
/* ...
|
||||||
@ -1372,6 +1370,14 @@ static int ssl_tls13_parse_client_hello(mbedtls_ssl_context *ssl,
|
|||||||
ssl->session_negotiate->endpoint = ssl->conf->endpoint;
|
ssl->session_negotiate->endpoint = ssl->conf->endpoint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are negotiation the version 1.3 of the protocol. Do what we have
|
||||||
|
* postponed: copy of the client random bytes.
|
||||||
|
*/
|
||||||
|
MBEDTLS_SSL_DEBUG_BUF(3, "client hello, random bytes",
|
||||||
|
random, MBEDTLS_CLIENT_HELLO_RANDOM_LEN);
|
||||||
|
memcpy(&handshake->randbytes[0], random, MBEDTLS_CLIENT_HELLO_RANDOM_LEN);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search for a matching ciphersuite
|
* Search for a matching ciphersuite
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user