Skip to content

Commit 195bdde

Browse files
committed
Merge remote-tracking branch 'restricted/pr/528' into development
* restricted/pr/528: Update query_config.c Fix failure in SSLv3 per-version suites test Adjust DES exclude lists in test scripts Clarify 3DES changes in ChangeLog Fix documentation for 3DES removal Exclude 3DES tests in test scripts Fix wording of ChangeLog and 3DES_REMOVE docs Reduce priority of 3DES ciphersuites
2 parents 74ac6e3 + 56b9a93 commit 195bdde

File tree

10 files changed

+94
-31
lines changed

10 files changed

+94
-31
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Features
99
buffer, but at the benefit of reduced RAM consumption.
1010
* Add a new function mbedtls_asn1_write_named_bitstring() to write ASN.1
1111
named bitstring in DER as required by RFC 5280 Appendix B.
12+
* Add MBEDTLS_REMOVE_3DES_CIPHERSUITES to allow removing 3DES ciphersuites
13+
from the default list (enabled by default). See
14+
https://sweet32.info/SWEET32_CCS16.pdf.
1215

1316
API Changes
1417
* Add a new X.509 API call `mbedtls_x509_parse_der_nocopy()`.
@@ -63,6 +66,8 @@ Changes
6366
* Ensure that ssl-opt.h can be run in OS X. #2029
6467
* Re-enable certain interoperability tests in ssl-opt.sh which had previously
6568
been disabled for lack of a sufficiently recent version of GnuTLS on the CI.
69+
* Ciphersuites based on 3DES now have the lowest priority by default when
70+
they are enabled.
6671

6772
= mbed TLS 2.16.0 branch released 2018-12-21
6873

include/mbedtls/config.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,26 @@
687687
*/
688688
#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
689689

690+
/**
691+
* \def MBEDTLS_REMOVE_3DES_CIPHERSUITES
692+
*
693+
* Remove 3DES ciphersuites by default in SSL / TLS.
694+
* This flag removes the ciphersuites based on 3DES from the default list as
695+
* returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible
696+
* to enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including
697+
* them explicitly.
698+
*
699+
* A man-in-the-browser attacker can recover authentication tokens sent through
700+
* a TLS connection using a 3DES based cipher suite (see "On the Practical
701+
* (In-)Security of 64-bit Block Ciphers" by Karthikeyan Bhargavan and Gaëtan
702+
* Leurent, see https://sweet32.info/SWEET32_CCS16.pdf). If this attack falls
703+
* in your threat model or you are unsure, then you should keep this option
704+
* enabled to remove 3DES based cipher suites.
705+
*
706+
* Comment this macro to keep 3DES in the default ciphersuite list.
707+
*/
708+
#define MBEDTLS_REMOVE_3DES_CIPHERSUITES
709+
690710
/**
691711
* \def MBEDTLS_ECP_DP_SECP192R1_ENABLED
692712
*

library/ssl_ciphersuites.c

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
/*
4444
* Ordered from most preferred to least preferred in terms of security.
4545
*
46-
* Current rule (except rc4, weak and null which come last):
46+
* Current rule (except RC4 and 3DES, weak and null which come last):
4747
* 1. By key exchange:
4848
* Forward-secure non-PSK > forward-secure PSK > ECJPAKE > other non-PSK > other PSK
4949
* 2. By key length and cipher:
50-
* ChaCha > AES-256 > Camellia-256 > ARIA-256 > AES-128 > Camellia-128 > ARIA-128 > 3DES
50+
* ChaCha > AES-256 > Camellia-256 > ARIA-256 > AES-128 > Camellia-128 > ARIA-128
5151
* 3. By cipher mode when relevant GCM > CCM > CBC > CCM_8
5252
* 4. By hash function used when relevant
5353
* 5. By key exchange/auth again: EC > non-EC
@@ -126,11 +126,6 @@ static const int ciphersuite_preference[] =
126126
MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256,
127127
MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256,
128128

129-
/* All remaining >= 128-bit ephemeral suites */
130-
MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
131-
MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
132-
MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
133-
134129
/* The PSK ephemeral suites */
135130
MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
136131
MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256,
@@ -162,9 +157,6 @@ static const int ciphersuite_preference[] =
162157
MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256,
163158
MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256,
164159

165-
MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA,
166-
MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA,
167-
168160
/* The ECJPAKE suite */
169161
MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8,
170162

@@ -228,11 +220,6 @@ static const int ciphersuite_preference[] =
228220
MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256,
229221
MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256,
230222

231-
/* All remaining >= 128-bit suites */
232-
MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
233-
MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,
234-
MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,
235-
236223
/* The RSA PSK suites */
237224
MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256,
238225
MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384,
@@ -251,8 +238,6 @@ static const int ciphersuite_preference[] =
251238
MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256,
252239
MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256,
253240

254-
MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA,
255-
256241
/* The PSK suites */
257242
MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256,
258243
MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384,
@@ -275,6 +260,16 @@ static const int ciphersuite_preference[] =
275260
MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256,
276261
MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256,
277262

263+
/* 3DES suites */
264+
MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
265+
MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
266+
MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
267+
MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA,
268+
MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA,
269+
MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
270+
MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,
271+
MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,
272+
MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA,
278273
MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA,
279274

280275
/* RC4 suites */
@@ -2187,6 +2182,26 @@ const int *mbedtls_ssl_list_ciphersuites( void )
21872182
static int supported_ciphersuites[MAX_CIPHERSUITES];
21882183
static int supported_init = 0;
21892184

2185+
static int ciphersuite_is_removed( const mbedtls_ssl_ciphersuite_t *cs_info )
2186+
{
2187+
(void)cs_info;
2188+
2189+
#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES)
2190+
if( cs_info->cipher == MBEDTLS_CIPHER_ARC4_128 )
2191+
return( 1 );
2192+
#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */
2193+
2194+
#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES)
2195+
if( cs_info->cipher == MBEDTLS_CIPHER_DES_EDE3_ECB ||
2196+
cs_info->cipher == MBEDTLS_CIPHER_DES_EDE3_CBC )
2197+
{
2198+
return( 1 );
2199+
}
2200+
#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */
2201+
2202+
return( 0 );
2203+
}
2204+
21902205
const int *mbedtls_ssl_list_ciphersuites( void )
21912206
{
21922207
/*
@@ -2202,14 +2217,12 @@ const int *mbedtls_ssl_list_ciphersuites( void )
22022217
*p != 0 && q < supported_ciphersuites + MAX_CIPHERSUITES - 1;
22032218
p++ )
22042219
{
2205-
#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES)
22062220
const mbedtls_ssl_ciphersuite_t *cs_info;
22072221
if( ( cs_info = mbedtls_ssl_ciphersuite_from_id( *p ) ) != NULL &&
2208-
cs_info->cipher != MBEDTLS_CIPHER_ARC4_128 )
2209-
#else
2210-
if( mbedtls_ssl_ciphersuite_from_id( *p ) != NULL )
2211-
#endif
2222+
!ciphersuite_is_removed( cs_info ) )
2223+
{
22122224
*(q++) = *p;
2225+
}
22132226
}
22142227
*q = 0;
22152228

library/version_features.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ static const char *features[] = {
303303
#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES)
304304
"MBEDTLS_REMOVE_ARC4_CIPHERSUITES",
305305
#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */
306+
#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES)
307+
"MBEDTLS_REMOVE_3DES_CIPHERSUITES",
308+
#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */
306309
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
307310
"MBEDTLS_ECP_DP_SECP192R1_ENABLED",
308311
#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */

programs/ssl/query_config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,14 @@ int query_config( const char *config )
850850
}
851851
#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */
852852

853+
#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES)
854+
if( strcmp( "MBEDTLS_REMOVE_3DES_CIPHERSUITES", config ) == 0 )
855+
{
856+
MACRO_EXPANSION_TO_STR( MBEDTLS_REMOVE_3DES_CIPHERSUITES );
857+
return( 0 );
858+
}
859+
#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */
860+
853861
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
854862
if( strcmp( "MBEDTLS_ECP_DP_SECP192R1_ENABLED", config ) == 0 )
855863
{

scripts/config.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# MBEDTLS_NO_PLATFORM_ENTROPY
3131
# MBEDTLS_PSA_CRYPTO_C
3232
# MBEDTLS_REMOVE_ARC4_CIPHERSUITES
33+
# MBEDTLS_REMOVE_3DES_CIPHERSUITES
3334
# MBEDTLS_SSL_HW_RECORD_ACCEL
3435
# MBEDTLS_RSA_NO_CRT
3536
# MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
@@ -98,6 +99,7 @@
9899
MBEDTLS_PSA_CRYPTO_C
99100
MBEDTLS_RSA_NO_CRT
100101
MBEDTLS_REMOVE_ARC4_CIPHERSUITES
102+
MBEDTLS_REMOVE_3DES_CIPHERSUITES
101103
MBEDTLS_SSL_HW_RECORD_ACCEL
102104
MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
103105
MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION

tests/compat.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ FILTER=""
6262
# avoid plain DES but keep 3DES-EDE-CBC (mbedTLS), DES-CBC3 (OpenSSL)
6363
# - ARIA: not in default config.h + requires OpenSSL >= 1.1.1
6464
# - ChachaPoly: requires OpenSSL >= 1.1.0
65-
EXCLUDE='NULL\|DES-CBC-\|RC4\|ARCFOUR\|ARIA\|CHACHA20-POLY1305'
65+
# - 3DES: not in default config
66+
EXCLUDE='NULL\|DES\|RC4\|ARCFOUR\|ARIA\|CHACHA20-POLY1305'
6667
VERBOSE=""
6768
MEMCHECK=0
6869
PEERS="OpenSSL$PEER_GNUTLS mbedTLS"

tests/scripts/all.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ component_test_full_cmake_clang () {
730730
msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
731731
if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
732732

733-
msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
734-
if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
733+
msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min
734+
if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR'
735735

736736
msg "test: compat.sh ARIA + ChachaPoly"
737737
if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'

tests/scripts/basic-build-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ OPENSSL_CMD="$OPENSSL_LEGACY" \
9191
OPENSSL_CMD="$OPENSSL_LEGACY" \
9292
GNUTLS_CLI="$GNUTLS_LEGACY_CLI" \
9393
GNUTLS_SERV="$GNUTLS_LEGACY_SERV" \
94-
sh compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR' | \
94+
sh compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR' | \
9595
tee -a compat-test-$TEST_OUTPUT
9696
OPENSSL_CMD="$OPENSSL_NEXT" \
9797
sh compat.sh -e '^$' -f 'ARIA\|CHACHA' | \

tests/ssl-opt.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4341,26 +4341,37 @@ run_test "ECJPAKE: working, DTLS, nolog" \
43414341
# Tests for ciphersuites per version
43424342

43434343
requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
4344+
requires_config_enabled MBEDTLS_CAMELLIA_C
4345+
requires_config_enabled MBEDTLS_AES_C
43444346
run_test "Per-version suites: SSL3" \
4345-
"$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
4347+
"$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
43464348
"$P_CLI force_version=ssl3" \
43474349
0 \
4348-
-c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA"
4350+
-c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA"
43494351

4352+
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1
4353+
requires_config_enabled MBEDTLS_CAMELLIA_C
4354+
requires_config_enabled MBEDTLS_AES_C
43504355
run_test "Per-version suites: TLS 1.0" \
4351-
"$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
4356+
"$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
43524357
"$P_CLI force_version=tls1 arc4=1" \
43534358
0 \
43544359
-c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA"
43554360

4361+
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1
4362+
requires_config_enabled MBEDTLS_CAMELLIA_C
4363+
requires_config_enabled MBEDTLS_AES_C
43564364
run_test "Per-version suites: TLS 1.1" \
4357-
"$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
4365+
"$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
43584366
"$P_CLI force_version=tls1_1" \
43594367
0 \
43604368
-c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA"
43614369

4370+
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
4371+
requires_config_enabled MBEDTLS_CAMELLIA_C
4372+
requires_config_enabled MBEDTLS_AES_C
43624373
run_test "Per-version suites: TLS 1.2" \
4363-
"$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
4374+
"$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \
43644375
"$P_CLI force_version=tls1_2" \
43654376
0 \
43664377
-c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256"

0 commit comments

Comments
 (0)