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 ) 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]; unsigned char session_hash[48];
#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ #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. /* The label for the KDF used for key expansion.
* This is either "master secret" or "extended master secret" * This is either "master secret" or "extended master secret"
* depending on whether the Extended Master Secret extension * 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; unsigned char const *salt = handshake->randbytes;
size_t salt_len = 64; 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 defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
if( ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED ) if( ssl->handshake->extended_ms == MBEDTLS_SSL_EXTENDED_MS_ENABLED )
{ {
@ -1723,7 +1713,6 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
mbedtls_platform_zeroize( handshake->premaster, mbedtls_platform_zeroize( handshake->premaster,
sizeof(handshake->premaster) ); sizeof(handshake->premaster) );
} }
}
return( 0 ); return( 0 );
} }