diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index 62b6ce18f8..d293629857 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -59,7 +59,7 @@ int mbedtls_ssl_handshake_client_step_tls1_3( mbedtls_ssl_context *ssl ) case MBEDTLS_SSL_SERVER_HELLO: // Stop here : we haven't finished whole flow - ret=MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_ENCRYPTED_EXTENSIONS ); break; @@ -88,17 +88,20 @@ static int ssl_client_hello_process( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_PROC_CHK( ssl_client_hello_prepare, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, ( ssl, - MBEDTLS_SSL_HS_CLIENT_HELLO, &buf, &buf_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_start_handshake_msg, + ( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, + &buf, &buf_len ) ); - MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, ( ssl, buf, buf_len, &msg_len ) ); + MBEDTLS_SSL_PROC_CHK( ssl_client_hello_write_partial, + ( ssl, buf, buf_len, &msg_len ) ); mbedtls_ssl_add_hs_hdr_to_checksum( ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, msg_len ); ssl->handshake->update_checksum( ssl, buf, 0 ); MBEDTLS_SSL_PROC_CHK( ssl_client_hello_postprocess, ( ssl ) ); - MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, ( ssl, buf_len, msg_len ) ); + MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_finish_handshake_msg, + ( ssl, buf_len, msg_len ) ); cleanup: @@ -112,8 +115,8 @@ static int ssl_client_hello_prepare( mbedtls_ssl_context *ssl ) { int ret; - if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, - ssl->handshake->randbytes, + if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, + ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_generate_random", ret ); @@ -177,8 +180,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, /* Ciphersuite-related variables */ const int* ciphersuites; const mbedtls_ssl_ciphersuite_t* ciphersuite_info; - size_t i; /* used to iterate through ciphersuite list */ - /* ciphersuite_start points to the start of the ciphersuite list, i.e. to the length field*/ + /* ciphersuite_start points to the start of + the ciphersuite list, i.e. to the length field*/ unsigned char* ciphersuite_start; size_t ciphersuite_count; @@ -220,7 +223,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, /* Write random bytes */ MBEDTLS_SSL_CHK_BUF_PTR( buf, end, CLIENT_HELLO_RAND_BYTES_LEN); memcpy( buf, ssl->handshake->randbytes, CLIENT_HELLO_RAND_BYTES_LEN ); - MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", buf, CLIENT_HELLO_RAND_BYTES_LEN ); + MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, random bytes", + buf, CLIENT_HELLO_RAND_BYTES_LEN ); buf += CLIENT_HELLO_RAND_BYTES_LEN; buflen -= CLIENT_HELLO_RAND_BYTES_LEN; @@ -268,7 +272,7 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, buf += 2; buflen -= 2; - for ( i = 0; ciphersuites[i] != 0; i++ ) + for ( size_t i = 0; ciphersuites[i] != 0; i++ ) { ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( ciphersuites[i] ); @@ -280,7 +284,8 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, continue; MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x, %s", - (unsigned int) ciphersuites[i], ciphersuite_info->name ) ); + (unsigned int) ciphersuites[i], + ciphersuite_info->name ) ); ciphersuite_count++; @@ -301,7 +306,9 @@ static int ssl_client_hello_write_partial( mbedtls_ssl_context *ssl, *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 >> 8 ); *ciphersuite_start++ = (unsigned char)( ciphersuite_count*2 ); - MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", ciphersuite_count ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, + ( "client hello, got %" MBEDTLS_PRINTF_SIZET " ciphersuites", + ciphersuite_count ) ); /* For every TLS 1.3 ClientHello, this vector MUST contain exactly * one byte set to zero, which corresponds to the 'null' compression @@ -421,7 +428,8 @@ static int ssl_write_supported_versions_ext( mbedtls_ssl_context *ssl, mbedtls_ssl_write_version( ssl->conf->max_major_ver, ssl->conf->max_minor_ver, ssl->conf->transport, p ); - MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); + MBEDTLS_SSL_DEBUG_MSG( 3, ( "supported version: [%d:%d]", + ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) ); *olen = 7;