mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 14:15:35 +00: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
22b265b9f2
commit
8ebb88d1e0
|
@ -144,6 +144,14 @@
|
||||||
#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_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)
|
||||||
|
|
|
@ -1301,8 +1301,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) ) )
|
|
||||||
#define SSL_SOME_MODES_USE_MAC
|
#define SSL_SOME_MODES_USE_MAC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1523,8 +1522,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) )
|
|
||||||
if( mode == MBEDTLS_MODE_CBC )
|
if( mode == MBEDTLS_MODE_CBC )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -1643,8 +1641,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_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 );
|
||||||
|
@ -1787,8 +1784,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) )
|
|
||||||
if( mode == MBEDTLS_MODE_CBC )
|
if( mode == MBEDTLS_MODE_CBC )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -1999,8 +1995,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_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 a new issue