mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-25 17:26:49 +00:00
Remove min/maj version from SSL context if only one version enabled
If the minor/major version is enforced at compile-time, the `major_ver` and `minor_ver` fields in `mbedtls_ssl_context` are redundant and can be removed.
This commit is contained in:
parent
2881d80138
commit
381eaa5976
|
@ -63,6 +63,18 @@
|
||||||
#include "platform_time.h"
|
#include "platform_time.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SSL_CONF_MAX_MAJOR_VER) && \
|
||||||
|
defined(MBEDTLS_SSL_CONF_MIN_MAJOR_VER) && \
|
||||||
|
( MBEDTLS_SSL_CONF_MAX_MAJOR_VER == MBEDTLS_SSL_CONF_MIN_MAJOR_VER )
|
||||||
|
#define MBEDTLS_SSL_CONF_FIXED_MAJOR_VER MBEDTLS_SSL_CONF_MIN_MAJOR_VER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_SSL_CONF_MAX_MINOR_VER) && \
|
||||||
|
defined(MBEDTLS_SSL_CONF_MIN_MINOR_VER) && \
|
||||||
|
( MBEDTLS_SSL_CONF_MAX_MINOR_VER == MBEDTLS_SSL_CONF_MIN_MINOR_VER )
|
||||||
|
#define MBEDTLS_SSL_CONF_FIXED_MINOR_VER MBEDTLS_SSL_CONF_MIN_MINOR_VER
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SSL Error codes
|
* SSL Error codes
|
||||||
*/
|
*/
|
||||||
|
@ -1229,8 +1241,12 @@ struct mbedtls_ssl_context
|
||||||
renego_max_records is < 0 */
|
renego_max_records is < 0 */
|
||||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MAJOR_VER)
|
||||||
int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */
|
int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */
|
||||||
|
#endif /* !MBEDTLS_SSL_CONF_FIXED_MAJOR_VER */
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MINOR_VER)
|
||||||
int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */
|
int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */
|
||||||
|
#endif /* !MBEDTLS_SSL_CONF_FIXED_MINOR_VER */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
||||||
unsigned badmac_seen; /*!< records with a bad MAC received */
|
unsigned badmac_seen; /*!< records with a bad MAC received */
|
||||||
|
|
|
@ -962,12 +962,22 @@ int mbedtls_ssl_check_sig_hash( const mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
static inline int mbedtls_ssl_get_minor_ver( mbedtls_ssl_context const *ssl )
|
static inline int mbedtls_ssl_get_minor_ver( mbedtls_ssl_context const *ssl )
|
||||||
{
|
{
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MINOR_VER)
|
||||||
return( ssl->minor_ver );
|
return( ssl->minor_ver );
|
||||||
|
#else /* !MBEDTLS_SSL_CONF_FIXED_MINOR_VER */
|
||||||
|
((void) ssl);
|
||||||
|
return( MBEDTLS_SSL_CONF_FIXED_MINOR_VER );
|
||||||
|
#endif /* MBEDTLS_SSL_CONF_FIXED_MINOR_VER */
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int mbedtls_ssl_get_major_ver( mbedtls_ssl_context const *ssl )
|
static inline int mbedtls_ssl_get_major_ver( mbedtls_ssl_context const *ssl )
|
||||||
{
|
{
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MAJOR_VER)
|
||||||
return( ssl->major_ver );
|
return( ssl->major_ver );
|
||||||
|
#else /* !MBEDTLS_SSL_CONF_FIXED_MAJOR_VER */
|
||||||
|
((void) ssl);
|
||||||
|
return( MBEDTLS_SSL_CONF_FIXED_MAJOR_VER );
|
||||||
|
#endif /* MBEDTLS_SSL_CONF_FIXED_MAJOR_VER */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
|
|
|
@ -850,8 +850,12 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
if( mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE )
|
if( mbedtls_ssl_get_renego_status( ssl ) == MBEDTLS_SSL_INITIAL_HANDSHAKE )
|
||||||
{
|
{
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MAJOR_VER)
|
||||||
ssl->major_ver = mbedtls_ssl_conf_get_min_major_ver( ssl->conf );
|
ssl->major_ver = mbedtls_ssl_conf_get_min_major_ver( ssl->conf );
|
||||||
|
#endif /* !MBEDTLS_SSL_CONF_FIXED_MAJOR_VER */
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MINOR_VER)
|
||||||
ssl->minor_ver = mbedtls_ssl_conf_get_min_minor_ver( ssl->conf );
|
ssl->minor_ver = mbedtls_ssl_conf_get_min_minor_ver( ssl->conf );
|
||||||
|
#endif /* !MBEDTLS_SSL_CONF_FIXED_MINOR_VER */
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mbedtls_ssl_conf_get_max_major_ver( ssl->conf ) == 0 )
|
if( mbedtls_ssl_conf_get_max_major_ver( ssl->conf ) == 0 )
|
||||||
|
@ -1743,8 +1747,13 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
||||||
return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION );
|
return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MINOR_VER)
|
||||||
ssl->minor_ver = minor_ver;
|
ssl->minor_ver = minor_ver;
|
||||||
|
#endif /* !MBEDTLS_SSL_CONF_FIXED_MINOR_VER */
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MAJOR_VER)
|
||||||
ssl->major_ver = major_ver;
|
ssl->major_ver = major_ver;
|
||||||
|
#endif /* !MBEDTLS_SSL_CONF_FIXED_MAJOR_VER */
|
||||||
}
|
}
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu",
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu",
|
||||||
|
|
|
@ -1654,8 +1654,12 @@ read_record_header:
|
||||||
else if( minor_ver > mbedtls_ssl_conf_get_max_minor_ver( ssl->conf ) )
|
else if( minor_ver > mbedtls_ssl_conf_get_max_minor_ver( ssl->conf ) )
|
||||||
minor_ver = mbedtls_ssl_conf_get_max_minor_ver( ssl->conf );
|
minor_ver = mbedtls_ssl_conf_get_max_minor_ver( ssl->conf );
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MAJOR_VER)
|
||||||
ssl->major_ver = major_ver;
|
ssl->major_ver = major_ver;
|
||||||
|
#endif /* MBEDTLS_SSL_CONF_FIXED_MAJOR_VER */
|
||||||
|
#if !defined(MBEDTLS_SSL_CONF_FIXED_MINOR_VER)
|
||||||
ssl->minor_ver = minor_ver;
|
ssl->minor_ver = minor_ver;
|
||||||
|
#endif /* MBEDTLS_SSL_CONF_FIXED_MINOR_VER */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue