mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-09 03:39:56 +00:00
Test DTLS renegotiation when badmac_seen_or_in_hsfraglen != 0
Non-regression test for a bug introduced with TLS handshake defragmentation support in Mbed TLS 3.6.2, whereby the confusion between the `badmac_seen` meaning and the `in_hsfraglen` meaning of `ssl->badmac_seen_or_in_hsfraglen` causes renegotiation to be processed incorrectly after receiving a message with a bad MAC. This bug will be fixed in a subsequent commit. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -669,13 +669,19 @@ Sending app data via DTLS, without MFL and with fragmentation
|
||||
app_data_dtls:MBEDTLS_SSL_MAX_FRAG_LEN_NONE:16385:100000:0:0
|
||||
|
||||
DTLS renegotiation: no legacy renegotiation
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION:-1
|
||||
|
||||
DTLS renegotiation: legacy renegotiation
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION:-1
|
||||
|
||||
DTLS renegotiation: legacy break handshake
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE:-1
|
||||
|
||||
DTLS renegotiation: after bad MAC on client
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION:MBEDTLS_SSL_IS_CLIENT
|
||||
|
||||
DTLS renegotiation: after bad MAC on server
|
||||
renegotiation:MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION:MBEDTLS_SSL_IS_SERVER
|
||||
|
||||
DTLS serialization with MFL=512
|
||||
resize_buffers_serialize_mfl:MBEDTLS_SSL_MAX_FRAG_LEN_512
|
||||
|
||||
@@ -63,6 +63,31 @@ exit:
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED) && \
|
||||
defined(MBEDTLS_PKCS1_V15) && \
|
||||
defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
|
||||
defined(MBEDTLS_RSA_C) && \
|
||||
defined(MBEDTLS_ECP_HAVE_SECP384R1) && \
|
||||
defined(MBEDTLS_SSL_PROTO_DTLS) && \
|
||||
defined(MBEDTLS_SSL_RENEGOTIATION) && \
|
||||
defined(MBEDTLS_MD_CAN_SHA256) && \
|
||||
defined(MBEDTLS_CAN_HANDLE_RSA_TEST_KEY)
|
||||
static void simulate_badmac_seen_on(mbedtls_test_ssl_endpoint *client,
|
||||
mbedtls_test_ssl_endpoint *server,
|
||||
void *param)
|
||||
{
|
||||
int on = *(int *) param;
|
||||
switch (on) {
|
||||
case MBEDTLS_SSL_IS_CLIENT:
|
||||
client->ssl.badmac_seen_or_in_hsfraglen = 1;
|
||||
break;
|
||||
case MBEDTLS_SSL_IS_SERVER:
|
||||
server->ssl.badmac_seen_or_in_hsfraglen = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
RECOMBINE_NOMINAL, /* param: ignored */
|
||||
RECOMBINE_SPLIT_FIRST, /* param: offset of split (<=0 means from end) */
|
||||
@@ -3303,7 +3328,7 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SSL_PROTO_TLS1_2:MBEDTLS_RSA_C:MBEDTLS_ECP_HAVE_SECP384R1:MBEDTLS_SSL_PROTO_DTLS:MBEDTLS_SSL_RENEGOTIATION:MBEDTLS_MD_CAN_SHA256:MBEDTLS_CAN_HANDLE_RSA_TEST_KEY */
|
||||
void renegotiation(int legacy_renegotiation)
|
||||
void renegotiation(int legacy_renegotiation, int badmac_seen_on)
|
||||
{
|
||||
mbedtls_test_handshake_test_options options;
|
||||
mbedtls_test_init_handshake_options(&options);
|
||||
@@ -3312,6 +3337,8 @@ void renegotiation(int legacy_renegotiation)
|
||||
options.legacy_renegotiation = legacy_renegotiation;
|
||||
options.dtls = 1;
|
||||
options.expected_negotiated_version = MBEDTLS_SSL_VERSION_TLS1_2;
|
||||
options.post_data_fun = &simulate_badmac_seen_on;
|
||||
options.post_data_param = &badmac_seen_on;
|
||||
|
||||
mbedtls_test_ssl_perform_handshake(&options);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user