From 0a6417041e16f527d904c7ab468d849ba4f8021b Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 24 Jun 2019 11:19:58 +0100 Subject: [PATCH] Remove redundant check in mbedtls_ssl_set_calc_verify_md() mbedtls_ssl_set_calc_verify_md() is only called from places where it has been checked that TLS 1.2 is being used. The corresponding compile-time and runtime guards checking the version in mbedtls_ssl_set_calc_verify_md() are therefore redundant and can be removed. --- library/ssl_tls.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 0b1ebddcf..3cc0cb3f6 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -11412,12 +11412,9 @@ int mbedtls_ssl_check_cert_usage( const mbedtls_x509_crt *cert, } #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md ) { -#if defined(MBEDTLS_SSL_PROTO_TLS1_2) - if( mbedtls_ssl_get_minor_ver( ssl ) != MBEDTLS_SSL_MINOR_VERSION_3 ) - return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH; - switch( md ) { #if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) @@ -11446,13 +11443,8 @@ int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md ) } return 0; -#else /* !MBEDTLS_SSL_PROTO_TLS1_2 */ - (void) ssl; - (void) md; - - return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH; -#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ #if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_1)