Reduce indentation in ssl_compute_master()
Exit earlier when there's noting to do.
For a small diff, review with 'git show -w'.
@@ -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 )
{
@@ -1723,7 +1713,6 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
mbedtls_platform_zeroize( handshake->premaster,
sizeof(handshake->premaster) );
}
- }
return( 0 );
}
