diff --git a/ChangeLog.d/mbedtls_tlsver_enum.txt b/ChangeLog.d/mbedtls_tlsver_enum.txt new file mode 100644 index 0000000000..b6f63577f0 --- /dev/null +++ b/ChangeLog.d/mbedtls_tlsver_enum.txt @@ -0,0 +1,2 @@ +Features + * Unify internal/external TLS protocol version enums diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h index 9be083a82e..384068a1ab 100644 --- a/include/mbedtls/ssl.h +++ b/include/mbedtls/ssl.h @@ -1099,6 +1099,14 @@ mbedtls_dtls_srtp_info; #endif /* MBEDTLS_SSL_DTLS_SRTP */ +/** Human-friendly representation of the (D)TLS protocol version. */ +typedef enum +{ + MBEDTLS_SSL_VERSION_UNKNOWN, /*!< Context not in use or version not yet negotiated. */ + MBEDTLS_SSL_VERSION_TLS1_2 = 0x0303, /*!< (D)TLS 1.2 */ + MBEDTLS_SSL_VERSION_TLS1_3 = 0x0304, /*!< (D)TLS 1.3 */ +} mbedtls_ssl_protocol_version; + /* * This structure is used for storing current session data. * @@ -1161,14 +1169,6 @@ struct mbedtls_ssl_session #endif }; -/** Human-friendly representation of the (D)TLS protocol version. */ -typedef enum -{ - MBEDTLS_SSL_VERSION_UNKNOWN, /*!< Context not in use or version not yet negotiated. */ - MBEDTLS_SSL_VERSION_1_2, /*!< (D)TLS 1.2 */ - MBEDTLS_SSL_VERSION_1_3, /*!< (D)TLS 1.3 */ -} mbedtls_ssl_protocol_version; - /* * Identifiers for PRFs used in various versions of TLS. */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 32b9799429..63442eb6ac 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -2328,9 +2328,9 @@ mbedtls_ssl_protocol_version mbedtls_ssl_get_version_number( switch( ssl->minor_ver ) { case MBEDTLS_SSL_MINOR_VERSION_3: - return( MBEDTLS_SSL_VERSION_1_2 ); + return( MBEDTLS_SSL_VERSION_TLS1_2 ); case MBEDTLS_SSL_MINOR_VERSION_4: - return( MBEDTLS_SSL_VERSION_1_3 ); + return( MBEDTLS_SSL_VERSION_TLS1_3 ); default: return( MBEDTLS_SSL_VERSION_UNKNOWN ); } diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 1a31573624..692efbe42b 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -1879,12 +1879,12 @@ int check_ssl_version( int expected_negotiated_version, switch( expected_negotiated_version ) { case MBEDTLS_SSL_MINOR_VERSION_3: - TEST_EQUAL( version_number, MBEDTLS_SSL_VERSION_1_2 ); + TEST_EQUAL( version_number, MBEDTLS_SSL_VERSION_TLS1_2 ); TEST_ASSERT( strcmp( version_string, "TLSv1.2" ) == 0 ); break; case MBEDTLS_SSL_MINOR_VERSION_4: - TEST_EQUAL( version_number, MBEDTLS_SSL_VERSION_1_3 ); + TEST_EQUAL( version_number, MBEDTLS_SSL_VERSION_TLS1_3 ); TEST_ASSERT( strcmp( version_string, "TLSv1.3" ) == 0 ); break;