mirror of
https://github.com/yuzu-mirror/mbedtls.git
synced 2026-04-04 22:19:05 +00:00
Allow compile-time configuration of DTLS anti replay
Introduce MBEDTLS_SSL_CONF_ANTI_REPLAY to allow configuring the use/nonuse of DTLS anti replay protection at compile-time. Impact on code-size, measured with > ./scripts/baremetal.sh --rom --gcc --armc5 --armc6 | | GCC | ARMC5 | ARMC6 | | --- | --- | --- | --- | | `libmbedtls.a` before | 23559 | 24089 | 27921 | | `libmbedtls.a` after | 23511 | 24049 | 27903 | | gain in Bytes | 48 | 40 | 18 |
This commit is contained in:
parent
af5ab918d9
commit
7f376f4ece
8 changed files with 67 additions and 13 deletions
|
|
@ -2578,6 +2578,14 @@ int query_config( const char *config )
|
|||
}
|
||||
#endif /* MBEDTLS_PLATFORM_GMTIME_R_ALT */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CONF_ANTI_REPLAY)
|
||||
if( strcmp( "MBEDTLS_SSL_CONF_ANTI_REPLAY", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CONF_ANTI_REPLAY );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_CONF_ANTI_REPLAY */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET)
|
||||
if( strcmp( "MBEDTLS_SSL_CONF_EXTENDED_MASTER_SECRET", config ) == 0 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -317,7 +317,8 @@ int main( void )
|
|||
#define USAGE_COOKIES ""
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \
|
||||
!defined(MBEDTLS_SSL_CONF_ANTI_REPLAY)
|
||||
#define USAGE_ANTI_REPLAY \
|
||||
" anti_replay=0/1 default: (library default: enabled)\n"
|
||||
#else
|
||||
|
|
@ -1889,12 +1890,14 @@ int main( int argc, char *argv[] )
|
|||
if( opt.cookies < -1 || opt.cookies > 1)
|
||||
goto usage;
|
||||
}
|
||||
#if !defined(MBEDTLS_SSL_CONF_ANTI_REPLAY)
|
||||
else if( strcmp( p, "anti_replay" ) == 0 )
|
||||
{
|
||||
opt.anti_replay = atoi( q );
|
||||
if( opt.anti_replay < 0 || opt.anti_replay > 1)
|
||||
goto usage;
|
||||
}
|
||||
#endif /* !MBEDTLS_SSL_CONF_ANTI_REPLAY */
|
||||
else if( strcmp( p, "badmac_limit" ) == 0 )
|
||||
{
|
||||
opt.badmac_limit = atoi( q );
|
||||
|
|
@ -2580,7 +2583,8 @@ int main( int argc, char *argv[] )
|
|||
; /* Nothing to do */
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) && \
|
||||
!defined(MBEDTLS_SSL_CONF_ANTI_REPLAY)
|
||||
if( opt.anti_replay != DFL_ANTI_REPLAY )
|
||||
mbedtls_ssl_conf_dtls_anti_replay( &conf, opt.anti_replay );
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue