tls13: Remove unnecessary cast from size_t to uint32_t
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c
index eec2bb4..9fbd3ac 100644
--- a/library/ssl_tls13_generic.c
+++ b/library/ssl_tls13_generic.c
@@ -1459,8 +1459,6 @@
int mbedtls_ssl_tls13_check_early_data_len(mbedtls_ssl_context *ssl,
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
* and thus a session under negotiation. Add a sanity check to detect a
@@ -1475,13 +1473,13 @@
* A server receiving more than max_early_data_size bytes of 0-RTT data
* 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->total_early_data_size)) {
MBEDTLS_SSL_DEBUG_MSG(
- 2, ("EarlyData: Too much early data received, %u > %u",
- ssl->total_early_data_size + uint32_early_data_len,
+ 2, ("EarlyData: Too much early data received, %u + %" MBEDTLS_PRINTF_SIZET " > %u",
+ ssl->total_early_data_size, early_data_len,
ssl->session_negotiate->max_early_data_size));
MBEDTLS_SSL_PEND_FATAL_ALERT(
@@ -1490,7 +1488,13 @@
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;
}