mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 15:35:48 +01:00
Factor repeated preprocessor condition to a macro
The condition is a complex and repeated a few times. There were already some inconsistencies in the repetitions as some of them forgot about DES. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
a586099fd3
commit
a60d0f2acb
@ -152,6 +152,15 @@
|
|||||||
#define MBEDTLS_SSL_RETRANS_WAITING 2
|
#define MBEDTLS_SSL_RETRANS_WAITING 2
|
||||||
#define MBEDTLS_SSL_RETRANS_FINISHED 3
|
#define MBEDTLS_SSL_RETRANS_FINISHED 3
|
||||||
|
|
||||||
|
/* For CBC-specific encrypt/decrypt code */
|
||||||
|
#if defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
||||||
|
( defined(MBEDTLS_AES_C) || \
|
||||||
|
defined(MBEDTLS_CAMELLIA_C) || \
|
||||||
|
defined(MBEDTLS_ARIA_C) || \
|
||||||
|
defined(MBEDTLS_DES_C) )
|
||||||
|
#define MBEDTLS_SSL_SOME_SUITES_USE_CBC
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allow extra bytes for record, authentication and encryption overhead:
|
* Allow extra bytes for record, authentication and encryption overhead:
|
||||||
* counter (8) + header (5) + IV(16) + MAC (16-48) + padding (0-256)
|
* counter (8) + header (5) + IV(16) + MAC (16-48) + padding (0-256)
|
||||||
|
@ -1433,8 +1433,7 @@ static void ssl_mac( mbedtls_md_context_t *md_ctx,
|
|||||||
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
|
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \
|
#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \
|
||||||
( defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
defined(MBEDTLS_SSL_SOME_SUITES_USE_CBC)
|
||||||
( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) || defined(MBEDTLS_ARIA_C)) )
|
|
||||||
#define SSL_SOME_MODES_USE_MAC
|
#define SSL_SOME_MODES_USE_MAC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1669,8 +1668,7 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */
|
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_CBC)
|
||||||
( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) || defined(MBEDTLS_ARIA_C) )
|
|
||||||
if( mode == MBEDTLS_MODE_CBC )
|
if( mode == MBEDTLS_MODE_CBC )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@ -1789,8 +1787,7 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl )
|
|||||||
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_CIPHER_MODE_CBC &&
|
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_CBC */
|
||||||
( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C || MBEDTLS_ARIA_C ) */
|
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||||
@ -1962,8 +1959,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */
|
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */
|
||||||
#if defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
#if defined(MBEDTLS_SSL_SOME_SUITES_USE_CBC)
|
||||||
( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) || defined(MBEDTLS_ARIA_C) )
|
|
||||||
if( mode == MBEDTLS_MODE_CBC )
|
if( mode == MBEDTLS_MODE_CBC )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -2176,8 +2172,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
|
|||||||
ssl->in_msglen -= padlen;
|
ssl->in_msglen -= padlen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_CIPHER_MODE_CBC &&
|
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_CBC) */
|
||||||
( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C || MBEDTLS_ARIA_C ) */
|
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||||
|
Loading…
Reference in New Issue
Block a user