mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-24 05:06:56 +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
8ed8694199
commit
2df1f1f16f
|
@ -146,12 +146,16 @@
|
||||||
#define MBEDTLS_SSL_COMPRESSION_ADD 0
|
#define MBEDTLS_SSL_COMPRESSION_ADD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
#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) || \
|
|
||||||
defined(MBEDTLS_DES_C) ) )
|
|
||||||
#define MBEDTLS_SSL_SOME_MODES_USE_MAC
|
#define MBEDTLS_SSL_SOME_MODES_USE_MAC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -609,10 +609,7 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
/* The PRNG is used for dynamic IV generation that's used
|
/* The PRNG is used for dynamic IV generation that's used
|
||||||
* for CBC transformations in TLS 1.1 and TLS 1.2. */
|
* for CBC transformations in TLS 1.1 and TLS 1.2. */
|
||||||
#if !( defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
#if !( defined(MBEDTLS_SSL_SOME_SUITES_USE_CBC) && \
|
||||||
( defined(MBEDTLS_AES_C) || \
|
|
||||||
defined(MBEDTLS_ARIA_C) || \
|
|
||||||
defined(MBEDTLS_CAMELLIA_C) ) && \
|
|
||||||
( defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2) ) )
|
( defined(MBEDTLS_SSL_PROTO_TLS1_1) || defined(MBEDTLS_SSL_PROTO_TLS1_2) ) )
|
||||||
((void) f_rng);
|
((void) f_rng);
|
||||||
((void) p_rng);
|
((void) p_rng);
|
||||||
|
@ -910,8 +907,7 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C || MBEDTLS_CHACHAPOLY_C */
|
#endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C || MBEDTLS_CHACHAPOLY_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 = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
@ -1050,8 +1046,7 @@ int mbedtls_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 );
|
||||||
|
@ -1239,8 +1234,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *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 )
|
||||||
{
|
{
|
||||||
size_t minlen = 0;
|
size_t minlen = 0;
|
||||||
|
@ -1493,8 +1487,7 @@ int mbedtls_ssl_decrypt_buf( mbedtls_ssl_context const *ssl,
|
||||||
rec->data_len -= padlen;
|
rec->data_len -= 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 a new issue