mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
tls13: Remove unnecessary cast from size_t to uint32_t
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
@ -1459,8 +1459,6 @@ int mbedtls_ssl_tls13_write_early_data_ext(mbedtls_ssl_context *ssl,
|
|||||||
int mbedtls_ssl_tls13_check_early_data_len(mbedtls_ssl_context *ssl,
|
int mbedtls_ssl_tls13_check_early_data_len(mbedtls_ssl_context *ssl,
|
||||||
size_t early_data_len)
|
size_t early_data_len)
|
||||||
{
|
{
|
||||||
uint32_t uint32_early_data_len = (uint32_t) early_data_len;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function should be called only while an handshake is in progress
|
* This function should be called only while an handshake is in progress
|
||||||
* and thus a session under negotiation. Add a sanity check to detect a
|
* and thus a session under negotiation. Add a sanity check to detect a
|
||||||
@ -1475,13 +1473,13 @@ int mbedtls_ssl_tls13_check_early_data_len(mbedtls_ssl_context *ssl,
|
|||||||
* A server receiving more than max_early_data_size bytes of 0-RTT data
|
* A server receiving more than max_early_data_size bytes of 0-RTT data
|
||||||
* SHOULD terminate the connection with an "unexpected_message" alert.
|
* SHOULD terminate the connection with an "unexpected_message" alert.
|
||||||
*/
|
*/
|
||||||
if (uint32_early_data_len >
|
if (early_data_len >
|
||||||
(ssl->session_negotiate->max_early_data_size -
|
(ssl->session_negotiate->max_early_data_size -
|
||||||
ssl->total_early_data_size)) {
|
ssl->total_early_data_size)) {
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG(
|
MBEDTLS_SSL_DEBUG_MSG(
|
||||||
2, ("EarlyData: Too much early data received, %u > %u",
|
2, ("EarlyData: Too much early data received, %u + %" MBEDTLS_PRINTF_SIZET " > %u",
|
||||||
ssl->total_early_data_size + uint32_early_data_len,
|
ssl->total_early_data_size, early_data_len,
|
||||||
ssl->session_negotiate->max_early_data_size));
|
ssl->session_negotiate->max_early_data_size));
|
||||||
|
|
||||||
MBEDTLS_SSL_PEND_FATAL_ALERT(
|
MBEDTLS_SSL_PEND_FATAL_ALERT(
|
||||||
@ -1490,7 +1488,13 @@ int mbedtls_ssl_tls13_check_early_data_len(mbedtls_ssl_context *ssl,
|
|||||||
return MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE;
|
return MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl->total_early_data_size += uint32_early_data_len;
|
/*
|
||||||
|
* The check just above implies that early_data_len is lower than
|
||||||
|
* UINT32_MAX thus its cast to an uint32_t below is safe. We need it
|
||||||
|
* to appease some compilers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ssl->total_early_data_size += (uint32_t) early_data_len;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user