Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile when few options are set #292

Open
wants to merge 14 commits into
base: tls13-prototype
Choose a base branch
from
6 changes: 6 additions & 0 deletions library/ssl_tls13_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,13 @@ int ssl_write_early_data_process( mbedtls_ssl_context* ssl )
#endif /* MBEDTLS_SSL_USE_MPS */

#else /* MBEDTLS_ZERO_RTT */
#if defined(MBEDTLS_SSL_USE_MPS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISTM that we should rather guard the declarations of buf, buf_len, ... by MBEDTLS_SSL_USE_MPS && MBEDTLS_ZERO_RTT.

((void) buf);
((void) buf_len);
((void) msg);
((void) msg_len);
#endif /* MBEDTLS_SSL_USE_MPS */

/* Should never happen */
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );

Expand Down Expand Up @@ -2725,6 +2728,9 @@ static int ssl_encrypted_extensions_parse( mbedtls_ssl_context* ssl,
size_t ext_len;
const unsigned char *ext;

/* ssl structure is not used when ALPN, 0RTT, and MFL extensions are not used. */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should be replaced by the appropriate compile-time guard.

((void) ssl);

if( buflen < 2 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "EncryptedExtension message too short" ) );
Expand Down
13 changes: 11 additions & 2 deletions library/ssl_tls13_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,19 +871,24 @@ int mbedtls_ssl_tls1_3_generate_resumption_master_secret(
int ret = 0;

mbedtls_md_type_t md_type;

#if defined(MBEDTLS_DEBUG_C)
mbedtls_md_info_t const *md_info;
size_t md_size;

#endif

unsigned char transcript[MBEDTLS_MD_MAX_SIZE];
size_t transcript_len;

MBEDTLS_SSL_DEBUG_MSG( 2,
( "=> mbedtls_ssl_tls1_3_generate_resumption_master_secret" ) );

md_type = ssl->handshake->ciphersuite_info->mac;
#if defined(MBEDTLS_DEBUG_C)
md_info = mbedtls_md_info_from_type( md_type );
md_size = mbedtls_md_get_size( md_info );

#endif

ret = mbedtls_ssl_get_handshake_transcript( ssl, md_type,
transcript, sizeof( transcript ),
&transcript_len );
Expand Down Expand Up @@ -1153,6 +1158,10 @@ int mbedtls_ssl_tls1_3_create_psk_binder( mbedtls_ssl_context *ssl,
mbedtls_md_info_t const *md_info = mbedtls_md_info_from_type( md_type );
size_t const md_size = mbedtls_md_get_size( md_info );

#if !defined(MBEDTLS_DEBUG_C)
((void) ssl);
#endif

ret = mbedtls_ssl_tls1_3_evolve_secret( md_type,
NULL, /* Old secret */
psk, psk_len, /* Input */
Expand Down
4 changes: 4 additions & 0 deletions library/ssl_tls13_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,10 @@ static int ssl_client_hello_fetch( mbedtls_ssl_context* ssl,

static void ssl_debug_print_client_hello_exts( mbedtls_ssl_context *ssl )
{
#if !defined(MBEDTLS_DEBUG_C)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISTM that the entire function could be guarded by MBEDTLS_DEBUG_C and defined as a dummy if !MBEDTLS_DEBUG_C.

((void) ssl);
#endif

MBEDTLS_SSL_DEBUG_MSG( 3, ( "Supported Extensions:" ) );
MBEDTLS_SSL_DEBUG_MSG( 3, ( "- KEY_SHARE_EXTENSION ( %s )",
( ( ssl->handshake->extensions_present & MBEDTLS_SSL_EXT_KEY_SHARE ) > 0 ) ?
Expand Down