mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-01 04:20:45 +00:00
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
@ -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 defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
||||||
/* If the ciphersuite requires signing, check whether
|
/* If the ciphersuite requires signing, check whether
|
||||||
* a suitable hash algorithm is present. */
|
* 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 );
|
sig_type = mbedtls_ssl_get_ciphersuite_sig_alg( suite_info );
|
||||||
if( sig_type != MBEDTLS_PK_NONE &&
|
if( sig_type != MBEDTLS_PK_NONE &&
|
||||||
mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, sig_type ) == MBEDTLS_MD_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 ) );
|
"for signature algorithm %u", (unsigned) sig_type ) );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
|
#endif /* MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED */
|
||||||
|
|
||||||
@ -1945,8 +1942,6 @@ have_ciphersuite:
|
|||||||
/* Debugging-only output for testsuite */
|
/* Debugging-only output for testsuite */
|
||||||
#if defined(MBEDTLS_DEBUG_C) && \
|
#if defined(MBEDTLS_DEBUG_C) && \
|
||||||
defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED)
|
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 );
|
mbedtls_pk_type_t sig_alg = mbedtls_ssl_get_ciphersuite_sig_alg( ciphersuite_info );
|
||||||
if( sig_alg != MBEDTLS_PK_NONE )
|
if( sig_alg != MBEDTLS_PK_NONE )
|
||||||
{
|
{
|
||||||
@ -1960,7 +1955,6 @@ have_ciphersuite:
|
|||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "no hash algorithm for signature algorithm "
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "no hash algorithm for signature algorithm "
|
||||||
"%u - should not happen", (unsigned) sig_alg ) );
|
"%u - should not happen", (unsigned) sig_alg ) );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello" ) );
|
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) } HashAlgorithm;
|
||||||
* enum { (255) } SignatureAlgorithm;
|
* 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 );
|
const uint16_t *sig_alg = mbedtls_ssl_get_sig_algs( ssl );
|
||||||
if( sig_alg == NULL )
|
if( sig_alg == NULL )
|
||||||
return( MBEDTLS_ERR_SSL_BAD_CONFIG );
|
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 );
|
MBEDTLS_PUT_UINT16_BE( sa_len, p, 0 );
|
||||||
sa_len += 2;
|
sa_len += 2;
|
||||||
p += sa_len;
|
p += sa_len;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DistinguishedName certificate_authorities<0..2^16-1>;
|
* DistinguishedName certificate_authorities<0..2^16-1>;
|
||||||
@ -3243,11 +3231,9 @@ curve_matching_done:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mbedtls_md_type_t md_alg;
|
mbedtls_md_type_t md_alg;
|
||||||
|
|
||||||
mbedtls_pk_type_t sig_alg =
|
mbedtls_pk_type_t sig_alg =
|
||||||
mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info );
|
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
|
/* For TLS 1.2, obey signature-hash-algorithm extension
|
||||||
* (RFC 5246, Sec. 7.4.1.4.1). */
|
* (RFC 5246, Sec. 7.4.1.4.1). */
|
||||||
if( sig_alg == MBEDTLS_PK_NONE ||
|
if( sig_alg == MBEDTLS_PK_NONE ||
|
||||||
@ -3259,12 +3245,6 @@ curve_matching_done:
|
|||||||
* only if there is a matching hash.) */
|
* only if there is a matching hash.) */
|
||||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
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 ) );
|
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
|
* 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
|
* We need to specify signature and hash algorithm explicitly through
|
||||||
* explicitly through a prefix to the signature.
|
* a prefix to the signature.
|
||||||
*
|
*
|
||||||
* struct {
|
* struct {
|
||||||
* HashAlgorithm hash;
|
* HashAlgorithm hash;
|
||||||
@ -3309,11 +3287,8 @@ curve_matching_done:
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ssl->out_msg[ssl->out_msglen++] =
|
ssl->out_msg[ssl->out_msglen++] = mbedtls_ssl_hash_from_md_alg( md_alg );
|
||||||
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_sig_from_pk_alg( sig_alg );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
|
||||||
if( ssl->conf->f_async_sign_start != NULL )
|
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>;
|
* opaque signature<0..2^16-1>;
|
||||||
* } DigitallySigned;
|
* } DigitallySigned;
|
||||||
*/
|
*/
|
||||||
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
|
|
||||||
{
|
|
||||||
if( i + 2 > ssl->in_hslen )
|
if( i + 2 > ssl->in_hslen )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate verify message" ) );
|
||||||
@ -4312,12 +4285,6 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
|
|||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
|
||||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( i + 2 > ssl->in_hslen )
|
if( i + 2 > ssl->in_hslen )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user