mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-04 14:08:39 +00:00
Allow compile-time configuration of DTLS badmac limit
Introduces MBEDTLS_SSL_CONF_BADMAC_LIMIT to fix the maximum number of records with bad MAC tolerated in DTLS at compile-time. Impact on code-size: | | GCC | ARMC5 | ARMC6 | | --- | --- | --- | --- | | `libmbedtls.a` before | 23511 | 24049 | 27903 | | `libmbedtls.a` after | 23487 | 24025 | 27885 | | gain in Bytes | 24 | 24 | 18 |
This commit is contained in:
parent
7f376f4ece
commit
de67154658
8 changed files with 53 additions and 10 deletions
|
|
@ -2586,6 +2586,14 @@ int query_config( const char *config )
|
|||
}
|
||||
#endif /* MBEDTLS_SSL_CONF_ANTI_REPLAY */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CONF_BADMAC_LIMIT)
|
||||
if( strcmp( "MBEDTLS_SSL_CONF_BADMAC_LIMIT", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CONF_BADMAC_LIMIT );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_CONF_BADMAC_LIMIT */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
|
||||
if( strcmp( "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET", config ) == 0 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -325,7 +325,8 @@ int main( void )
|
|||
#define USAGE_ANTI_REPLAY ""
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \
|
||||
!defined(MBEDTLS_SSL_CONF_BADMAC_LIMIT)
|
||||
#define USAGE_BADMAC_LIMIT \
|
||||
" badmac_limit=%%d default: (library default: disabled)\n"
|
||||
#else
|
||||
|
|
@ -1898,12 +1899,14 @@ int main( int argc, char *argv[] )
|
|||
goto usage;
|
||||
}
|
||||
#endif /* !MBEDTLS_SSL_CONF_ANTI_REPLAY */
|
||||
#if !defined(MBEDTLS_SSL_CONF_BADMAC_LIMIT)
|
||||
else if( strcmp( p, "badmac_limit" ) == 0 )
|
||||
{
|
||||
opt.badmac_limit = atoi( q );
|
||||
if( opt.badmac_limit < 0 )
|
||||
goto usage;
|
||||
}
|
||||
#endif /* !MBEDTLS_SSL_CONF_BADMAC_LIMIT */
|
||||
else if( strcmp( p, "hs_timeout" ) == 0 )
|
||||
{
|
||||
if( ( p = strchr( q, '-' ) ) == NULL )
|
||||
|
|
@ -2589,7 +2592,8 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_ssl_conf_dtls_anti_replay( &conf, opt.anti_replay );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) && \
|
||||
!defined(MBEDTLS_SSL_CONF_BADMAC_LIMIT)
|
||||
if( opt.badmac_limit != DFL_BADMAC_LIMIT )
|
||||
mbedtls_ssl_conf_dtls_badmac_limit( &conf, opt.badmac_limit );
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue