Skip to content

Commit 829ef47

Browse files
committed
Add supported_curves/groups extension
This allows us to use a ciphersuite that will still be supported in 4.0. Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
1 parent ec90442 commit 829ef47

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

tests/suites/test_suite_ssl.data

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,31 +3446,45 @@ tls13_srv_max_early_data_size:TEST_EARLY_DATA_HRR:3:3
34463446
TLS 1.3 srv, max early data size, HRR, 98, wsz=49
34473447
tls13_srv_max_early_data_size:TEST_EARLY_DATA_HRR:97:0
34483448

3449-
# 1.2 minimal ClientHello breakdown:
3449+
# (Minimal) ClientHello breakdown:
34503450
# 160303rlrl - record header, 2-byte record contents len
34513451
# 01hlhlhl - handshake header, 3-byte handshake message len
34523452
# 0303 - protocol version: 1.2
34533453
# 0123456789abcdef (repeated, 4 times total) - 32-byte "random"
34543454
# 00 - session ID (empty)
34553455
# 0002cvcv - ciphersuite list: 2-byte len + list of 2-byte values (see below)
34563456
# 0100 - compression methods: 1-byte len then "null" (only legal value now)
3457-
# [then end, or extensions]
3457+
# [then end, or extensions, see notes below]
34583458
# elel - 2-byte extensions length
34593459
# ...
3460+
# 000a - elliptic_curves aka supported_groups
3461+
# 0004 - extension length
3462+
# 0002 - length of named_curve_list / named_group_list
3463+
# 0017 - secp256r1 aka NIST P-256
3464+
# ...
34603465
#
34613466
# Note: currently our TLS "1.3 or 1.2" code requires extension length to be
34623467
# present even it it's 0. This is not strictly compliant but doesn't matter
34633468
# much in practice as these days everyone wants to use signature_algorithms
34643469
# (for hashes better than SHA-1), secure_renego (even if you have renego
34653470
# disabled), and most people want either ECC or PSK related extensions.
3471+
# See https://github.com/Mbed-TLS/mbedtls/issues/9963
3472+
#
3473+
# Also, currently we won't negotiate ECC ciphersuites unless at least the
3474+
# supported_groups extension is present, see
3475+
# https://github.com/Mbed-TLS/mbedtls/issues/7458
34663476
#
34673477
# Note: cccc is currently not assigned, so can be used get a consistent
34683478
# "no matching ciphersuite" behaviour regardless of the configuration.
3469-
# 002f is MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA, MTI in 1.2, but removed in 4.0.
3479+
# c02b is MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (1.2)
3480+
3481+
# See "ClientHello breakdown" above
3482+
# MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 with secp256r1
34703483
Inject ClientHello - TLS 1.2 good (for reference)
3471-
depends_on:MBEDTLS_SSL_PROTO_TLS1_2:MBEDTLS_KEY_EXCHANGE_RSA_ENABLED:MBEDTLS_SSL_HAVE_AES:MBEDTLS_MD_CAN_SHA1:MBEDTLS_SSL_HAVE_CBC
3472-
inject_client_content_on_the_wire:MBEDTLS_SSL_CLIENT_HELLO:"160303002f0100002b03030123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef000002002f01000000":"<= parse client hello":0
3484+
depends_on:MBEDTLS_SSL_PROTO_TLS1_2:MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED:MBEDTLS_SSL_HAVE_AES:MBEDTLS_MD_CAN_SHA256:MBEDTLS_SSL_HAVE_GCM:MBEDTLS_ECP_HAVE_SECP256R1
3485+
inject_client_content_on_the_wire:MBEDTLS_PK_ECDSA:MBEDTLS_SSL_CLIENT_HELLO:"16030300370100003303030123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef000002c02b01000008000a000400020017":"<= parse client hello":0
34733486

3487+
# See "ClientHello breakdown" above
34743488
Inject ClientHello - TLS 1.2 unknown ciphersuite (for reference)
3475-
depends_on:MBEDTLS_SSL_PROTO_TLS1_2
3476-
inject_client_content_on_the_wire:MBEDTLS_SSL_CLIENT_HELLO:"160303002f0100002b03030123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef000002cccc01000000":"got no ciphersuites in common":MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE
3489+
depends_on:MBEDTLS_SSL_PROTO_TLS1_2:MBEDTLS_RSA_C
3490+
inject_client_content_on_the_wire:MBEDTLS_PK_RSA:MBEDTLS_SSL_CLIENT_HELLO:"160303002f0100002b03030123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef000002cccc01000000":"got no ciphersuites in common":MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE

tests/suites/test_suite_ssl.function

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5039,8 +5039,9 @@ exit:
50395039
/* END_CASE */
50405040

50415041
/* BEGIN_CASE */
5042-
void inject_client_content_on_the_wire(int state, data_t *hello, char *log_pattern,
5043-
int expected_ret)
5042+
void inject_client_content_on_the_wire(int pk_alg,
5043+
int state, data_t *data,
5044+
char *log_pattern, int expected_ret)
50445045
{
50455046
/* This function allows us to inject content at a specific state
50465047
* in the handshake, or when it's completed. The content is injected
@@ -5068,7 +5069,9 @@ void inject_client_content_on_the_wire(int state, data_t *hello, char *log_patte
50685069
srv_pattern.pattern = log_pattern;
50695070
options.srv_log_obj = &srv_pattern;
50705071
options.srv_log_fun = mbedtls_test_ssl_log_analyzer;
5071-
mbedtls_debug_set_threshold(3);
5072+
mbedtls_debug_set_threshold(5);
5073+
5074+
options.pk_alg = pk_alg;
50725075

50735076
ret = mbedtls_test_ssl_endpoint_init(&server, MBEDTLS_SSL_IS_SERVER,
50745077
&options, NULL, NULL, NULL);
@@ -5087,8 +5090,8 @@ void inject_client_content_on_the_wire(int state, data_t *hello, char *log_patte
50875090
TEST_EQUAL(ret, 0);
50885091

50895092
/* Send the crafted message */
5090-
ret = mbedtls_test_mock_tcp_send_b(&client.socket, hello->x, hello->len);
5091-
TEST_ASSERT(ret >= 0 && (size_t) ret == hello->len);
5093+
ret = mbedtls_test_mock_tcp_send_b(&client.socket, data->x, data->len);
5094+
TEST_ASSERT(ret >= 0 && (size_t) ret == data->len);
50925095

50935096
/* Have the server process it.
50945097
* Need the loop because a server that support 1.3 and 1.2

0 commit comments

Comments
 (0)