Introduce content_len_size variable in ECHDE-PSK part of ssl_write_client_key_exchange()

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
Neil Armstrong 2022-03-23 17:54:38 +01:00
parent 0bdb68a242
commit fc834f2e2c

View file

@ -3025,10 +3025,14 @@ ecdh_calc_secret:
if( ssl_conf_has_static_raw_psk( ssl->conf ) == 0 ) if( ssl_conf_has_static_raw_psk( ssl->conf ) == 0 )
return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );
/* uint16 to store content length */
const size_t content_len_size = 2;
header_len = 4; header_len = 4;
content_len = ssl->conf->psk_identity_len; content_len = ssl->conf->psk_identity_len;
if( header_len + 2 + content_len > MBEDTLS_SSL_OUT_CONTENT_LEN ) if( header_len + content_len_size + content_len
> MBEDTLS_SSL_OUT_CONTENT_LEN )
{ {
MBEDTLS_SSL_DEBUG_MSG( 1, MBEDTLS_SSL_DEBUG_MSG( 1,
( "psk identity too long or SSL buffer too short" ) ); ( "psk identity too long or SSL buffer too short" ) );