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
parent 7edd5876ce
commit dafe5227d4

View File

@ -1094,7 +1094,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 )
{ {
@ -1103,18 +1103,12 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
const mbedtls_ssl_ciphersuite_t *ciphersuite_info = handshake->ciphersuite_info; const mbedtls_ssl_ciphersuite_t *ciphersuite_info = handshake->ciphersuite_info;
mbedtls_ssl_session *session = ssl->session_negotiate; mbedtls_ssl_session *session = ssl->session_negotiate;
/* if( handshake->resume != 0 )
* 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)" ) );
return( 0 );
}
MBEDTLS_SSL_DEBUG_BUF( 3, "premaster secret", handshake->premaster, MBEDTLS_SSL_DEBUG_BUF( 3, "premaster secret", handshake->premaster,
handshake->pmslen ); handshake->pmslen );
@ -1171,9 +1165,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) );
}
else
MBEDTLS_SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) );
return( 0 ); return( 0 );
} }