ssl_tls12_server.c: Remove some unnecessary checks on TLS minor version
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
b894ac7f99
commit
8457c12127
1 changed files with 95 additions and 128 deletions
|
@ -1103,8 +1103,6 @@ static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id,
|
|||
#if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||
/* If the ciphersuite requires signing, check whether
|
||||
* a suitable hash algorithm is present. */
|
||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
{
|
||||
sig_type = mbedtls_ssl_get_ciphersuite_sig_alg( suite_info );
|
||||
if( sig_type != MBEDTLS_PK_NONE &&
|
||||
mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, sig_type ) == MBEDTLS_MD_NONE )
|
||||
|
@ -1113,7 +1111,6 @@ static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id,
|
|||
"for signature algorithm %u", (unsigned) sig_type ) );
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
|
||||
|
||||
|
@ -1945,8 +1942,6 @@ have_ciphersuite:
|
|||
/* Debugging-only output for testsuite */
|
||||
#if defined(MBEDTLS_DEBUG_C) && \
|
||||
defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
{
|
||||
mbedtls_pk_type_t sig_alg = mbedtls_ssl_get_ciphersuite_sig_alg( ciphersuite_info );
|
||||
if( sig_alg != MBEDTLS_PK_NONE )
|
||||
{
|
||||
|
@ -1960,7 +1955,6 @@ have_ciphersuite:
|
|||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "no hash algorithm for signature algorithm "
|
||||
"%u - should not happen", (unsigned) sig_alg ) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello" ) );
|
||||
|
@ -2794,11 +2788,6 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
|
|||
* enum { (255) } HashAlgorithm;
|
||||
* enum { (255) } SignatureAlgorithm;
|
||||
*/
|
||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
{
|
||||
/*
|
||||
* Supported signature algorithms
|
||||
*/
|
||||
const uint16_t *sig_alg = mbedtls_ssl_get_sig_algs( ssl );
|
||||
if( sig_alg == NULL )
|
||||
return( MBEDTLS_ERR_SSL_BAD_CONFIG );
|
||||
|
@ -2819,7 +2808,6 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
|
|||
MBEDTLS_PUT_UINT16_BE( sa_len, p, 0 );
|
||||
sa_len += 2;
|
||||
p += sa_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* DistinguishedName certificate_authorities<0..2^16-1>;
|
||||
|
@ -3243,11 +3231,9 @@ curve_matching_done:
|
|||
*/
|
||||
|
||||
mbedtls_md_type_t md_alg;
|
||||
|
||||
mbedtls_pk_type_t sig_alg =
|
||||
mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info );
|
||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
{
|
||||
|
||||
/* For TLS 1.2, obey signature-hash-algorithm extension
|
||||
* (RFC 5246, Sec. 7.4.1.4.1). */
|
||||
if( sig_alg == MBEDTLS_PK_NONE ||
|
||||
|
@ -3259,12 +3245,6 @@ curve_matching_done:
|
|||
* only if there is a matching hash.) */
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "pick hash algorithm %u for signing", (unsigned) md_alg ) );
|
||||
|
||||
|
@ -3291,11 +3271,9 @@ curve_matching_done:
|
|||
/*
|
||||
* 2.3: Compute and add the signature
|
||||
*/
|
||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
{
|
||||
/*
|
||||
* For TLS 1.2, we need to specify signature and hash algorithm
|
||||
* explicitly through a prefix to the signature.
|
||||
* We need to specify signature and hash algorithm explicitly through
|
||||
* a prefix to the signature.
|
||||
*
|
||||
* struct {
|
||||
* HashAlgorithm hash;
|
||||
|
@ -3309,11 +3287,8 @@ curve_matching_done:
|
|||
*
|
||||
*/
|
||||
|
||||
ssl->out_msg[ssl->out_msglen++] =
|
||||
mbedtls_ssl_hash_from_md_alg( md_alg );
|
||||
ssl->out_msg[ssl->out_msglen++] =
|
||||
mbedtls_ssl_sig_from_pk_alg( sig_alg );
|
||||
}
|
||||
ssl->out_msg[ssl->out_msglen++] = mbedtls_ssl_hash_from_md_alg( md_alg );
|
||||
ssl->out_msg[ssl->out_msglen++] = mbedtls_ssl_sig_from_pk_alg( sig_alg );
|
||||
|
||||
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
||||
if( ssl->conf->f_async_sign_start != NULL )
|
||||
|
@ -4261,8 +4236,6 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
|
|||
* opaque signature<0..2^16-1>;
|
||||
* } DigitallySigned;
|
||||
*/
|
||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
||||
{
|
||||
if( i + 2 > ssl->in_hslen )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) );
|
||||
|
@ -4312,12 +4285,6 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
|
|||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
if( i + 2 > ssl->in_hslen )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue