Skip to content

Commit

Permalink
Split SHA-512 and SHA-384 guards for hash availability code
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed May 19, 2021
1 parent fc9c07f commit c54010c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/ssl_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -6846,8 +6846,10 @@ void mbedtls_ssl_config_init( mbedtls_ssl_config *conf )

#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
static int ssl_preset_default_hashes[] = {
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA512_NO_SHA384)
#if defined(MBEDTLS_SHA512_C)
MBEDTLS_MD_SHA512,
#endif
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA512_NO_SHA384)
MBEDTLS_MD_SHA384,
#endif
#if defined(MBEDTLS_SHA256_C)
Expand Down Expand Up @@ -7210,6 +7212,8 @@ mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash( unsigned char hash )
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA512_NO_SHA384)
case MBEDTLS_SSL_HASH_SHA384:
return( MBEDTLS_MD_SHA384 );
#endif
#if defined(MBEDTLS_SHA512_C)
case MBEDTLS_SSL_HASH_SHA512:
return( MBEDTLS_MD_SHA512 );
#endif
Expand Down Expand Up @@ -7242,6 +7246,8 @@ unsigned char mbedtls_ssl_hash_from_md_alg( int md )
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_SHA512_NO_SHA384)
case MBEDTLS_MD_SHA384:
return( MBEDTLS_SSL_HASH_SHA384 );
#endif
#if defined(MBEDTLS_SHA512_C)
case MBEDTLS_MD_SHA512:
return( MBEDTLS_SSL_HASH_SHA512 );
#endif
Expand Down

0 comments on commit c54010c

Please sign in to comment.