mirror of
https://github.com/reactos/reactos.git
synced 2025-07-05 06:41:21 +00:00
[MBEDTLS] Update to version 2.7.15. CORE-16869
This commit is contained in:
parent
4efff7f463
commit
c58d7a6df6
6 changed files with 94 additions and 18 deletions
28
dll/3rdparty/mbedtls/ecp.c
vendored
28
dll/3rdparty/mbedtls/ecp.c
vendored
|
@ -1446,6 +1446,20 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||||
* Now get m * P from M * P and normalize it
|
* Now get m * P from M * P and normalize it
|
||||||
*/
|
*/
|
||||||
MBEDTLS_MPI_CHK( ecp_safe_invert_jac( grp, R, ! m_is_odd ) );
|
MBEDTLS_MPI_CHK( ecp_safe_invert_jac( grp, R, ! m_is_odd ) );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Knowledge of the jacobian coordinates may leak the last few bits of the
|
||||||
|
* scalar [1], and since our MPI implementation isn't constant-flow,
|
||||||
|
* inversion (used for coordinate normalization) may leak the full value
|
||||||
|
* of its input via side-channels [2].
|
||||||
|
*
|
||||||
|
* [1] https://eprint.iacr.org/2003/191
|
||||||
|
* [2] https://eprint.iacr.org/2020/055
|
||||||
|
*
|
||||||
|
* Avoid the leak by randomizing coordinates before we normalize them.
|
||||||
|
*/
|
||||||
|
if( f_rng != 0 )
|
||||||
|
MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, R, f_rng, p_rng ) );
|
||||||
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
|
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -1666,6 +1680,20 @@ static int ecp_mul_mxz( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_swap( &R->Z, &RP.Z, b ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_swap( &R->Z, &RP.Z, b ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Knowledge of the projective coordinates may leak the last few bits of the
|
||||||
|
* scalar [1], and since our MPI implementation isn't constant-flow,
|
||||||
|
* inversion (used for coordinate normalization) may leak the full value
|
||||||
|
* of its input via side-channels [2].
|
||||||
|
*
|
||||||
|
* [1] https://eprint.iacr.org/2003/191
|
||||||
|
* [2] https://eprint.iacr.org/2020/055
|
||||||
|
*
|
||||||
|
* Avoid the leak by randomizing coordinates before we normalize them.
|
||||||
|
*/
|
||||||
|
if( f_rng != NULL )
|
||||||
|
MBEDTLS_MPI_CHK( ecp_randomize_mxz( grp, R, f_rng, p_rng ) );
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK( ecp_normalize_mxz( grp, R ) );
|
MBEDTLS_MPI_CHK( ecp_normalize_mxz( grp, R ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
16
dll/3rdparty/mbedtls/ssl_cli.c
vendored
16
dll/3rdparty/mbedtls/ssl_cli.c
vendored
|
@ -1413,6 +1413,19 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) );
|
||||||
|
|
||||||
|
/* Check that there is enough room for:
|
||||||
|
* - 2 bytes of version
|
||||||
|
* - 1 byte of cookie_len
|
||||||
|
*/
|
||||||
|
if( mbedtls_ssl_hs_hdr_len( ssl ) + 3 > ssl->in_msglen )
|
||||||
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||||
|
( "incoming HelloVerifyRequest message is too short" ) );
|
||||||
|
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
|
||||||
|
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
|
||||||
|
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* struct {
|
* struct {
|
||||||
* ProtocolVersion server_version;
|
* ProtocolVersion server_version;
|
||||||
|
@ -1441,8 +1454,6 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie_len = *p++;
|
cookie_len = *p++;
|
||||||
MBEDTLS_SSL_DEBUG_BUF( 3, "cookie", p, cookie_len );
|
|
||||||
|
|
||||||
if( ( ssl->in_msg + ssl->in_msglen ) - p < cookie_len )
|
if( ( ssl->in_msg + ssl->in_msglen ) - p < cookie_len )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1,
|
MBEDTLS_SSL_DEBUG_MSG( 1,
|
||||||
|
@ -1451,6 +1462,7 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
|
||||||
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
|
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
|
||||||
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
|
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
|
||||||
}
|
}
|
||||||
|
MBEDTLS_SSL_DEBUG_BUF( 3, "cookie", p, cookie_len );
|
||||||
|
|
||||||
mbedtls_free( ssl->handshake->verify_cookie );
|
mbedtls_free( ssl->handshake->verify_cookie );
|
||||||
|
|
||||||
|
|
37
dll/3rdparty/mbedtls/ssl_tls.c
vendored
37
dll/3rdparty/mbedtls/ssl_tls.c
vendored
|
@ -875,8 +875,6 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl )
|
||||||
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
|
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
|
||||||
if( mbedtls_ssl_hw_record_init != NULL )
|
if( mbedtls_ssl_hw_record_init != NULL )
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_init()" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_init()" ) );
|
||||||
|
|
||||||
if( ( ret = mbedtls_ssl_hw_record_init( ssl, key1, key2, transform->keylen,
|
if( ( ret = mbedtls_ssl_hw_record_init( ssl, key1, key2, transform->keylen,
|
||||||
|
@ -2702,15 +2700,18 @@ static void ssl_dtls_replay_reset( mbedtls_ssl_context *ssl );
|
||||||
/*
|
/*
|
||||||
* Swap transform_out and out_ctr with the alternative ones
|
* Swap transform_out and out_ctr with the alternative ones
|
||||||
*/
|
*/
|
||||||
static void ssl_swap_epochs( mbedtls_ssl_context *ssl )
|
static int ssl_swap_epochs( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
mbedtls_ssl_transform *tmp_transform;
|
mbedtls_ssl_transform *tmp_transform;
|
||||||
unsigned char tmp_out_ctr[8];
|
unsigned char tmp_out_ctr[8];
|
||||||
|
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
|
||||||
|
int ret;
|
||||||
|
#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
|
||||||
|
|
||||||
if( ssl->transform_out == ssl->handshake->alt_transform_out )
|
if( ssl->transform_out == ssl->handshake->alt_transform_out )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip swap epochs" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip swap epochs" ) );
|
||||||
return;
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "swap epochs" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "swap epochs" ) );
|
||||||
|
@ -2744,7 +2745,9 @@ static void ssl_swap_epochs( mbedtls_ssl_context *ssl )
|
||||||
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2756,6 +2759,8 @@ static void ssl_swap_epochs( mbedtls_ssl_context *ssl )
|
||||||
*/
|
*/
|
||||||
int mbedtls_ssl_resend( mbedtls_ssl_context *ssl )
|
int mbedtls_ssl_resend( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_resend" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_resend" ) );
|
||||||
|
|
||||||
if( ssl->handshake->retransmit_state != MBEDTLS_SSL_RETRANS_SENDING )
|
if( ssl->handshake->retransmit_state != MBEDTLS_SSL_RETRANS_SENDING )
|
||||||
|
@ -2763,14 +2768,14 @@ int mbedtls_ssl_resend( mbedtls_ssl_context *ssl )
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialise resending" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialise resending" ) );
|
||||||
|
|
||||||
ssl->handshake->cur_msg = ssl->handshake->flight;
|
ssl->handshake->cur_msg = ssl->handshake->flight;
|
||||||
ssl_swap_epochs( ssl );
|
if( ( ret = ssl_swap_epochs( ssl ) ) != 0 )
|
||||||
|
return( ret );
|
||||||
|
|
||||||
ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_SENDING;
|
ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_SENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( ssl->handshake->cur_msg != NULL )
|
while( ssl->handshake->cur_msg != NULL )
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
mbedtls_ssl_flight_item *cur = ssl->handshake->cur_msg;
|
mbedtls_ssl_flight_item *cur = ssl->handshake->cur_msg;
|
||||||
|
|
||||||
/* Swap epochs before sending Finished: we can't do it after
|
/* Swap epochs before sending Finished: we can't do it after
|
||||||
|
@ -2779,7 +2784,8 @@ int mbedtls_ssl_resend( mbedtls_ssl_context *ssl )
|
||||||
if( cur->type == MBEDTLS_SSL_MSG_HANDSHAKE &&
|
if( cur->type == MBEDTLS_SSL_MSG_HANDSHAKE &&
|
||||||
cur->p[0] == MBEDTLS_SSL_HS_FINISHED )
|
cur->p[0] == MBEDTLS_SSL_HS_FINISHED )
|
||||||
{
|
{
|
||||||
ssl_swap_epochs( ssl );
|
if( ( ret = ssl_swap_epochs( ssl ) ) != 0 )
|
||||||
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy( ssl->out_msg, cur->p, cur->len );
|
memcpy( ssl->out_msg, cur->p, cur->len );
|
||||||
|
@ -3594,29 +3600,38 @@ static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl )
|
||||||
int ret;
|
int ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
/* Use out_msg as temporary buffer for writing out HelloVerifyRequest,
|
||||||
|
* because the output buffer's already around. Don't use out_buf though,
|
||||||
|
* as we don't want to overwrite out_ctr. */
|
||||||
ret = ssl_check_dtls_clihlo_cookie(
|
ret = ssl_check_dtls_clihlo_cookie(
|
||||||
ssl->conf->f_cookie_write,
|
ssl->conf->f_cookie_write,
|
||||||
ssl->conf->f_cookie_check,
|
ssl->conf->f_cookie_check,
|
||||||
ssl->conf->p_cookie,
|
ssl->conf->p_cookie,
|
||||||
ssl->cli_id, ssl->cli_id_len,
|
ssl->cli_id, ssl->cli_id_len,
|
||||||
ssl->in_buf, ssl->in_left,
|
ssl->in_buf, ssl->in_left,
|
||||||
ssl->out_buf, MBEDTLS_SSL_MAX_CONTENT_LEN, &len );
|
ssl->out_msg, MBEDTLS_SSL_MAX_CONTENT_LEN, &len );
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_RET( 2, "ssl_check_dtls_clihlo_cookie", ret );
|
MBEDTLS_SSL_DEBUG_RET( 2, "ssl_check_dtls_clihlo_cookie", ret );
|
||||||
|
|
||||||
if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED )
|
if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED )
|
||||||
{
|
{
|
||||||
|
int send_ret;
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "sending HelloVerifyRequest" ) );
|
||||||
|
MBEDTLS_SSL_DEBUG_BUF( 4, "output record sent to network",
|
||||||
|
ssl->out_msg, len );
|
||||||
/* Don't check write errors as we can't do anything here.
|
/* Don't check write errors as we can't do anything here.
|
||||||
* If the error is permanent we'll catch it later,
|
* If the error is permanent we'll catch it later,
|
||||||
* if it's not, then hopefully it'll work next time. */
|
* if it's not, then hopefully it'll work next time. */
|
||||||
(void) ssl->f_send( ssl->p_bio, ssl->out_buf, len );
|
send_ret = ssl->f_send( ssl->p_bio, ssl->out_msg, len );
|
||||||
|
MBEDTLS_SSL_DEBUG_RET( 2, "ssl->f_send", send_ret );
|
||||||
|
(void) send_ret;
|
||||||
|
|
||||||
return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED );
|
return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ret == 0 )
|
if( ret == 0 )
|
||||||
{
|
{
|
||||||
/* Got a valid cookie, partially reset context */
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "cookie is valid, resetting context" ) );
|
||||||
if( ( ret = ssl_session_reset_int( ssl, 1 ) ) != 0 )
|
if( ( ret = ssl_session_reset_int( ssl, 1 ) ) != 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_RET( 1, "reset", ret );
|
MBEDTLS_SSL_DEBUG_RET( 1, "reset", ret );
|
||||||
|
|
2
dll/3rdparty/mbedtls/x509.c
vendored
2
dll/3rdparty/mbedtls/x509.c
vendored
|
@ -1089,7 +1089,7 @@ cleanup:
|
||||||
mbedtls_x509_crt_free( &clicert );
|
mbedtls_x509_crt_free( &clicert );
|
||||||
#else
|
#else
|
||||||
((void) verbose);
|
((void) verbose);
|
||||||
#endif /* MBEDTLS_CERTS_C && MBEDTLS_SHA1_C */
|
#endif /* MBEDTLS_CERTS_C && MBEDTLS_SHA256_C */
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -527,6 +527,23 @@
|
||||||
#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
|
#error "MBEDTLS_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
|
||||||
|
defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2)) && \
|
||||||
|
!(defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
|
||||||
|
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) )
|
||||||
|
#error "One or more versions of the TLS protocol are enabled " \
|
||||||
|
"but no key exchange methods defined with MBEDTLS_KEY_EXCHANGE_xxxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
|
#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
|
||||||
!defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
|
!defined(MBEDTLS_SSL_PROTO_TLS1_1) && \
|
||||||
!defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
!defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||||
|
@ -650,6 +667,10 @@
|
||||||
#error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites"
|
#error "MBEDTLS_X509_CREATE_C defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_CERTS_C) && !defined(MBEDTLS_X509_USE_C)
|
||||||
|
#error "MBEDTLS_CERTS_C defined, but not all prerequisites"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
|
#if defined(MBEDTLS_X509_CRT_PARSE_C) && ( !defined(MBEDTLS_X509_USE_C) )
|
||||||
#error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites"
|
#error "MBEDTLS_X509_CRT_PARSE_C defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,16 +42,16 @@
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_VERSION_MAJOR 2
|
#define MBEDTLS_VERSION_MAJOR 2
|
||||||
#define MBEDTLS_VERSION_MINOR 7
|
#define MBEDTLS_VERSION_MINOR 7
|
||||||
#define MBEDTLS_VERSION_PATCH 14
|
#define MBEDTLS_VERSION_PATCH 15
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The single version number has the following structure:
|
* The single version number has the following structure:
|
||||||
* MMNNPP00
|
* MMNNPP00
|
||||||
* Major version | Minor version | Patch version
|
* Major version | Minor version | Patch version
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_VERSION_NUMBER 0x02070E00
|
#define MBEDTLS_VERSION_NUMBER 0x02070F00
|
||||||
#define MBEDTLS_VERSION_STRING "2.7.14"
|
#define MBEDTLS_VERSION_STRING "2.7.15"
|
||||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.7.14"
|
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.7.15"
|
||||||
|
|
||||||
#if defined(MBEDTLS_VERSION_C)
|
#if defined(MBEDTLS_VERSION_C)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue