Reduce indentation in ssl_compute_master()

Exit earlier when there's noting to do.

For a small diff, review with 'git show -w'.
This commit is contained in:
Manuel Pégourié-Gonnard 2019-05-03 09:16:16 +02:00 committed by Jarno Lamsa
parent 9951b712bd
commit 85680c49ef

View file

@ -1578,7 +1578,7 @@ static int ssl_set_handshake_prfs( mbedtls_ssl_handshake_params *handshake,
}
/*
* Compute master secret
* Compute master secret if needed
*/
static int ssl_compute_master( mbedtls_ssl_context *ssl )
{
@ -1595,22 +1595,6 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
unsigned char session_hash[48];
#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
/*
* SSLv3:
* master =
* MD5( premaster + SHA1( 'A' + premaster + randbytes ) ) +
* MD5( premaster + SHA1( 'BB' + premaster + randbytes ) ) +
* MD5( premaster + SHA1( 'CCC' + premaster + randbytes ) )
*
* TLSv1+:
* master = PRF( premaster, "master secret", randbytes )[0..47]
*/
if( handshake->resume != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) );
}
else
{
/* The label for the KDF used for key expansion.
* This is either "master secret" or "extended master secret"
* depending on whether the Extended Master Secret extension
@ -1627,6 +1611,12 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
unsigned char const *salt = handshake->randbytes;
size_t salt_len = 64;
if( handshake->resume != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) );
return( 0 );
}
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
if( ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED )
{
@ -1656,7 +1646,7 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
#endif /* MBEDTLS_SSL_EXTENDED_MS_ENABLED */
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK &&
ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 &&
ssl_use_opaque_psk( ssl ) == 1 )
@ -1723,7 +1713,6 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
mbedtls_platform_zeroize( handshake->premaster,
sizeof(handshake->premaster) );
}
}
return( 0 );
}