Use new tools for all cases with TLS-specific code
This commit handles occurrences of case 2 and 3 in the following list: 1. Some DTLS-specific code with no TLS-specific code (most frequent) 2. Some specific code for each protocol 3. Some TLS-specific code with no DTLS-specific code (least frequent) Case 3 previously had a weird structure in that the TLS-specific code was always present, but the if structure was conditional on DTLS being enabled. This is changed by this commit to a more logical structure where both the code and the test are conditional on TLS being enabled. Case 2 doesn't require any change in the code structure in general. However, there is one occurrence where the if/else structure is simplified to assigning the result of a boolean operation, and one occurrence where I also noticed a useless use of `ssl_ep_len()` in a TLS-specific branch, that I turned to the constant 0 as it makes more sense. Case 1 will be handled in the next commit, as it can easily be handled in an automated way - only cases 2 and 3 (sometimes) required manual intervention. The list of occurrences for cases 2 and 3 was established manually by looking for occurrences of '= MBEDTLS_SSL_TRANSPORT_' in the code and manually checking if there was a TLS-specific branch. New sizes (see previous commit for the measuring script): ``` both text data bss dec hex filename 1820 0 4 1824 720 debug.o (ex library/libmbedtls.a) 0 0 0 0 0 net_sockets.o (ex library/libmbedtls.a) 548 0 0 548 224 ssl_cache.o (ex library/libmbedtls.a) 11155 0 596 11751 2de7 ssl_ciphersuites.o (ex library/libmbedtls.a) 17156 0 0 17156 4304 ssl_cli.o (ex library/libmbedtls.a) 460 0 0 460 1cc ssl_cookie.o (ex library/libmbedtls.a) 17649 0 0 17649 44f1 ssl_srv.o (ex library/libmbedtls.a) 800 0 0 800 320 ssl_ticket.o (ex library/libmbedtls.a) 39286 60 0 39346 99b2 ssl_tls.o (ex library/libmbedtls.a) 88874 60 600 89534 15dbe (TOTALS) DTLS-only text data bss dec hex filename 1820 0 4 1824 720 debug.o (ex library/libmbedtls.a) 0 0 0 0 0 net_sockets.o (ex library/libmbedtls.a) 548 0 0 548 224 ssl_cache.o (ex library/libmbedtls.a) 11155 0 596 11751 2de7 ssl_ciphersuites.o (ex library/libmbedtls.a) 17068 0 0 17068 42ac ssl_cli.o (ex library/libmbedtls.a) 460 0 0 460 1cc ssl_cookie.o (ex library/libmbedtls.a) 17553 0 0 17553 4491 ssl_srv.o (ex library/libmbedtls.a) 800 0 0 800 320 ssl_ticket.o (ex library/libmbedtls.a) 38499 60 0 38559 969f ssl_tls.o (ex library/libmbedtls.a) 87903 60 600 88563 159f3 (TOTALS) TLS-only text data bss dec hex filename 1820 0 4 1824 720 debug.o (ex library/libmbedtls.a) 0 0 0 0 0 net_sockets.o (ex library/libmbedtls.a) 548 0 0 548 224 ssl_cache.o (ex library/libmbedtls.a) 11155 0 596 11751 2de7 ssl_ciphersuites.o (ex library/libmbedtls.a) 14912 0 0 14912 3a40 ssl_cli.o (ex library/libmbedtls.a) 460 0 0 460 1cc ssl_cookie.o (ex library/libmbedtls.a) 15868 0 0 15868 3dfc ssl_srv.o (ex library/libmbedtls.a) 800 0 0 800 320 ssl_ticket.o (ex library/libmbedtls.a) 27619 60 0 27679 6c1f ssl_tls.o (ex library/libmbedtls.a) 73182 60 600 73842 12072 (TOTALS) ```
This commit is contained in:
parent
25838b795f
commit
ff4bd9f405
3 changed files with 116 additions and 71 deletions
|
@ -1762,12 +1762,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
|||
|
||||
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
||||
/* See comments in ssl_write_client_hello() */
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
|
||||
accept_comp = 0;
|
||||
else
|
||||
#endif
|
||||
accept_comp = 1;
|
||||
accept_comp = MBEDTLS_SSL_TRANSPORT_IS_TLS( ssl->conf->transport );
|
||||
|
||||
if( comp != MBEDTLS_SSL_COMPRESS_NULL &&
|
||||
( comp != MBEDTLS_SSL_COMPRESS_DEFLATE || accept_comp == 0 ) )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue