diff options
author | Janos Follath <janos.follath@arm.com> | 2016-05-06 13:57:50 +0100 |
---|---|---|
committer | Janos Follath <janos.follath@arm.com> | 2016-05-06 14:05:12 +0100 |
commit | 2442255f0d720d76d5016c030dbb4c8113c46c67 (patch) | |
tree | d70497b32d5b992c2efe9d802dc3873def04a16d | |
parent | 00efff74691373b0cfd939d4b824f400d7a8c70e (diff) | |
download | mbedtls-archive/iotssl-719-ssl3-non-compliance.zip mbedtls-archive/iotssl-719-ssl3-non-compliance.tar.gz mbedtls-archive/iotssl-719-ssl3-non-compliance.tar.bz2 |
Fix non compliance SSLv3 in server extension handling.archive/iotssl-719-ssl3-non-compliance
The server code parses the client hello extensions even when the
protocol is SSLv3 and this behaviour is non compliant with rfc6101.
Also the server sends extensions in the server hello and omitting
them may prevent interoperability problems.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | library/ssl_srv.c | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -26,6 +26,7 @@ Bugfix * Fix issue that caused a crash if invalid curves were passed to mbedtls_ssl_conf_curves. #373 * Fix issue in ssl_fork_server which was preventing it from functioning. #429 + * Fix non compliance SSLv3 in server extension handling. Changes * On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5, diff --git a/library/ssl_srv.c b/library/ssl_srv.c index 9fc21a5..5a51cbb 100644 --- a/library/ssl_srv.c +++ b/library/ssl_srv.c @@ -1507,6 +1507,12 @@ read_record_header: ssl->session_negotiate->compression = MBEDTLS_SSL_COMPRESS_NULL; #endif + /* Do not parse the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + /* * Check the extension length */ @@ -1692,8 +1698,13 @@ read_record_header: MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); } + } +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + #if defined(MBEDTLS_SSL_FALLBACK_SCSV) for( i = 0, p = buf + 41 + sess_len; i < ciph_len; i += 2, p += 2 ) { @@ -2363,6 +2374,12 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: 0x%02X", ssl->session_negotiate->compression ) ); + /* Do not write the extensions if the protocol is SSLv3 */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ( ssl->major_ver != 3 ) || ( ssl->minor_ver != 0 ) ) + { +#endif + /* * First write extensions, then the total length */ @@ -2419,6 +2436,10 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) p += ext_len; } +#if defined(MBEDTLS_SSL_PROTO_SSL3) + } +#endif + ssl->out_msglen = p - buf; ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO; |