mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-06 21:40:11 +00:00
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:
parent
9951b712bd
commit
85680c49ef
@ -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 )
|
||||||
{
|
{
|
||||||
@ -1656,7 +1646,7 @@ static int ssl_compute_master( mbedtls_ssl_context *ssl )
|
|||||||
#endif /* MBEDTLS_SSL_EXTENDED_MS_ENABLED */
|
#endif /* MBEDTLS_SSL_EXTENDED_MS_ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
#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 &&
|
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK &&
|
||||||
ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 &&
|
ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 &&
|
||||||
ssl_use_opaque_psk( ssl ) == 1 )
|
ssl_use_opaque_psk( ssl ) == 1 )
|
||||||
@ -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 );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user