Skip to content

Commit ba13d28

Browse files
committed
Merge branch 'bugfix/mbedtls_patches_3.0' into 'release/v3.0'
Bugfix/mbedtls patches 3.0 See merge request idf/esp-idf!2261
2 parents 806d23b + 8de2949 commit ba13d28

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

components/mbedtls/library/ssl_cli.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,10 +2049,16 @@ static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,
20492049
*
20502050
* opaque psk_identity_hint<0..2^16-1>;
20512051
*/
2052+
if( (*p) > end - 2 )
2053+
{
2054+
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message "
2055+
"(psk_identity_hint length)" ) );
2056+
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
2057+
}
20522058
len = (*p)[0] << 8 | (*p)[1];
20532059
*p += 2;
20542060

2055-
if( (*p) + len > end )
2061+
if( (*p) > end - len )
20562062
{
20572063
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message "
20582064
"(psk_identity_hint length)" ) );
@@ -2470,10 +2476,18 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl )
24702476
/*
24712477
* Read signature
24722478
*/
2479+
2480+
if( p > end - 2 )
2481+
{
2482+
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
2483+
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
2484+
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
2485+
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
2486+
}
24732487
sig_len = ( p[0] << 8 ) | p[1];
24742488
p += 2;
24752489

2476-
if( end != p + sig_len )
2490+
if( p != end - sig_len )
24772491
{
24782492
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
24792493
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,

components/mbedtls/library/ssl_srv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,7 +3436,7 @@ static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned cha
34363436
/*
34373437
* Receive client pre-shared key identity name
34383438
*/
3439-
if( *p + 2 > end )
3439+
if( end - *p < 2 )
34403440
{
34413441
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) );
34423442
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );
@@ -3445,7 +3445,7 @@ static int ssl_parse_client_psk_identity( mbedtls_ssl_context *ssl, unsigned cha
34453445
n = ( (*p)[0] << 8 ) | (*p)[1];
34463446
*p += 2;
34473447

3448-
if( n < 1 || n > 65535 || *p + n > end )
3448+
if( n < 1 || n > 65535 || n > (size_t) ( end - *p ) )
34493449
{
34503450
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) );
34513451
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );

components/mbedtls/port/include/mbedtls/esp_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@
926926
*
927927
* This enables support for RSAES-OAEP and RSASSA-PSS operations.
928928
*/
929-
#define MBEDTLS_PKCS1_V21
929+
//#define MBEDTLS_PKCS1_V21
930930

931931
/**
932932
* \def MBEDTLS_RSA_NO_CRT
@@ -1326,7 +1326,7 @@
13261326
*
13271327
* Comment this macro to disable support for truncated HMAC in SSL
13281328
*/
1329-
#define MBEDTLS_SSL_TRUNCATED_HMAC
1329+
//#define MBEDTLS_SSL_TRUNCATED_HMAC
13301330

13311331
/**
13321332
* \def MBEDTLS_THREADING_ALT
@@ -1420,7 +1420,7 @@
14201420
*
14211421
* Comment this macro to disallow using RSASSA-PSS in certificates.
14221422
*/
1423-
#define MBEDTLS_X509_RSASSA_PSS_SUPPORT
1423+
//#define MBEDTLS_X509_RSASSA_PSS_SUPPORT
14241424

14251425
/**
14261426
* \def MBEDTLS_ZLIB_SUPPORT

0 commit comments

Comments
 (0)