mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-28 00:35:21 +00:00
tls13: cli: Split early data user status and internal state
Do not use the return values of mbedtls_ssl_get_early_data_status() (MBEDTLS_SSL_EARLY_DATA_STATUS_ macros) for the state of the negotiation and transfer of early data during the handshake. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
ec4ed8eae4
commit
d2884662c1
@ -740,18 +740,37 @@ mbedtls_ssl_states;
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_CLI_C)
|
||||
typedef enum {
|
||||
/*
|
||||
* The client has not sent the first ClientHello yet, it is unknown if the
|
||||
* client will send an early data indication extension or not.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN,
|
||||
|
||||
/*
|
||||
* See documentation of mbedtls_ssl_get_early_data_status().
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED,
|
||||
} mbedtls_ssl_early_data_status;
|
||||
|
||||
typedef enum {
|
||||
/*
|
||||
* The client has not sent the first ClientHello yet, it is unknown if the
|
||||
* client will send an early data indication extension or not.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN,
|
||||
|
||||
/*
|
||||
* The client has not indicated the use of early data to the server.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT,
|
||||
|
||||
/*
|
||||
* The client has indicated the use of early data and the server has accepted
|
||||
* it.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_ACCEPTED,
|
||||
|
||||
/*
|
||||
* The client has indicated the use of early data but the server has rejected
|
||||
* it.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED,
|
||||
|
||||
/*
|
||||
* The client has sent an early data indication extension in its first
|
||||
@ -759,7 +778,7 @@ typedef enum {
|
||||
* HelloRetryRequest) from the server yet. The transform to protect early data
|
||||
* is not set and early data cannot be sent yet.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SENT,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SENT,
|
||||
|
||||
/*
|
||||
* The client has sent an early data indication extension in its first
|
||||
@ -767,16 +786,15 @@ typedef enum {
|
||||
* HelloRetryRequest) from the server yet. The transform to protect early data
|
||||
* has been set and early data can be written now.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE,
|
||||
|
||||
/*
|
||||
* The client has sent an early data indication extension in its first
|
||||
* ClientHello, the server has accepted them and the client has received the
|
||||
* server Finished message. It cannot send early data to the server anymore.
|
||||
*/
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED,
|
||||
} mbedtls_ssl_early_data_status;
|
||||
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED,
|
||||
} mbedtls_ssl_early_data_state;
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA && MBEDTLS_SSL_CLI_C */
|
||||
|
||||
/**
|
||||
@ -1737,10 +1755,10 @@ struct mbedtls_ssl_context {
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_CLI_C)
|
||||
/**
|
||||
* Status of the negotiation of the use of early data. Reset to
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN when the context is reset.
|
||||
* State of the negotiation and transfer of early data. Reset to
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN when the context is reset.
|
||||
*/
|
||||
mbedtls_ssl_early_data_status MBEDTLS_PRIVATE(early_data_status);
|
||||
mbedtls_ssl_early_data_state MBEDTLS_PRIVATE(early_data_state);
|
||||
#endif
|
||||
|
||||
unsigned MBEDTLS_PRIVATE(badmac_seen); /*!< records with a bad MAC received */
|
||||
|
@ -23,6 +23,7 @@ const char *mbedtls_ssl_states_str(mbedtls_ssl_states in);
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_CLI_C)
|
||||
const char *mbedtls_ssl_early_data_status_str(mbedtls_ssl_early_data_status in);
|
||||
const char *mbedtls_ssl_early_data_state_str(mbedtls_ssl_early_data_state in);
|
||||
#endif
|
||||
|
||||
const char *mbedtls_ssl_protocol_version_str(mbedtls_ssl_protocol_version in);
|
||||
|
@ -6097,21 +6097,21 @@ int mbedtls_ssl_write_early_data(mbedtls_ssl_context *ssl,
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are at the beginning of the handshake, the early data status being
|
||||
* equal to MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN or
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATUS_SENT advance the handshake just
|
||||
* If we are at the beginning of the handshake, the early data state being
|
||||
* equal to MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN or
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATE_SENT advance the handshake just
|
||||
* enough to be able to send early data if possible. That way, we can
|
||||
* guarantee that when starting the handshake with this function we will
|
||||
* send at least one record of early data. Note that when the status is
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATUS_SENT and not yet
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE, we cannot send early data yet
|
||||
* send at least one record of early data. Note that when the state is
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATE_SENT and not yet
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE, we cannot send early data yet
|
||||
* as the early data outbound transform has not been set as we may have to
|
||||
* first send a dummy CCS in clear.
|
||||
*/
|
||||
if ((ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN) ||
|
||||
(ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_SENT)) {
|
||||
while ((ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN) ||
|
||||
(ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_SENT)) {
|
||||
if ((ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN) ||
|
||||
(ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_SENT)) {
|
||||
while ((ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN) ||
|
||||
(ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_SENT)) {
|
||||
ret = mbedtls_ssl_handshake_step(ssl);
|
||||
if (ret != 0) {
|
||||
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_handshake_step", ret);
|
||||
@ -6133,8 +6133,8 @@ int mbedtls_ssl_write_early_data(mbedtls_ssl_context *ssl,
|
||||
* it too much. If we reach a point where we can still send early data,
|
||||
* then we will send some.
|
||||
*/
|
||||
if ((ssl->early_data_status != MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE) &&
|
||||
(ssl->early_data_status != MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED)) {
|
||||
if ((ssl->early_data_state != MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE) &&
|
||||
(ssl->early_data_state != MBEDTLS_SSL_EARLY_DATA_STATE_ACCEPTED)) {
|
||||
return MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA;
|
||||
}
|
||||
|
||||
@ -6152,8 +6152,8 @@ int mbedtls_ssl_write_early_data(mbedtls_ssl_context *ssl,
|
||||
}
|
||||
}
|
||||
|
||||
if (((ssl->early_data_status != MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE) &&
|
||||
(ssl->early_data_status != MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED))
|
||||
if (((ssl->early_data_state != MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE) &&
|
||||
(ssl->early_data_state != MBEDTLS_SSL_EARLY_DATA_STATE_ACCEPTED))
|
||||
|| (remaining == 0)) {
|
||||
return MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA;
|
||||
}
|
||||
|
@ -1096,7 +1096,7 @@ static int ssl_handshake_init(mbedtls_ssl_context *ssl)
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
#if defined(MBEDTLS_SSL_CLI_C)
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN;
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
ssl->discard_early_data_record = MBEDTLS_SSL_EARLY_DATA_NO_DISCARD;
|
||||
|
@ -1181,12 +1181,12 @@ int mbedtls_ssl_tls13_write_client_hello_exts(mbedtls_ssl_context *ssl,
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
/* In the first ClientHello, write the early data indication extension if
|
||||
* necessary and update the early data status.
|
||||
* necessary and update the early data state.
|
||||
* If an HRR has been received and thus we are currently writing the
|
||||
* second ClientHello, the second ClientHello must not contain an early
|
||||
* data extension and the early data status must stay as it is:
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT or
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED.
|
||||
* data extension and the early data state must stay as it is:
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT or
|
||||
* MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED.
|
||||
*/
|
||||
if (!ssl->handshake->hello_retry_request_flag) {
|
||||
if (mbedtls_ssl_conf_tls13_is_some_psk_enabled(ssl) &&
|
||||
@ -1199,9 +1199,9 @@ int mbedtls_ssl_tls13_write_client_hello_exts(mbedtls_ssl_context *ssl,
|
||||
}
|
||||
p += ext_len;
|
||||
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_SENT;
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_SENT;
|
||||
} else {
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT;
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT;
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
@ -1239,7 +1239,7 @@ int mbedtls_ssl_tls13_finalize_client_hello(mbedtls_ssl_context *ssl)
|
||||
size_t psk_len;
|
||||
const mbedtls_ssl_ciphersuite_t *ciphersuite_info;
|
||||
|
||||
if (ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_SENT) {
|
||||
if (ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_SENT) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(
|
||||
1, ("Set hs psk for early data when writing the first psk"));
|
||||
|
||||
@ -1302,7 +1302,7 @@ int mbedtls_ssl_tls13_finalize_client_hello(mbedtls_ssl_context *ssl)
|
||||
1, ("Switch to early data keys for outbound traffic"));
|
||||
mbedtls_ssl_set_outbound_transform(
|
||||
ssl, ssl->handshake->transform_earlydata);
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE;
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE;
|
||||
#endif
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
@ -1919,7 +1919,7 @@ static int ssl_tls13_postprocess_server_hello(mbedtls_ssl_context *ssl)
|
||||
* cases we compute it here.
|
||||
*/
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
if (ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT ||
|
||||
if (ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT ||
|
||||
handshake->key_exchange_mode ==
|
||||
MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL)
|
||||
#endif
|
||||
@ -1975,8 +1975,8 @@ static int ssl_tls13_postprocess_hrr(mbedtls_ssl_context *ssl)
|
||||
ssl->session_negotiate->ciphersuite = ssl->handshake->ciphersuite_info->id;
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
if (ssl->early_data_status != MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT) {
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED;
|
||||
if (ssl->early_data_state != MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT) {
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2238,9 +2238,9 @@ static int ssl_tls13_process_encrypted_extensions(mbedtls_ssl_context *ssl)
|
||||
return MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED;
|
||||
} else if (ssl->early_data_status != MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT) {
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED;
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_ACCEPTED;
|
||||
} else if (ssl->early_data_state != MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT) {
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2324,16 +2324,16 @@ int mbedtls_ssl_get_early_data_status(mbedtls_ssl_context *ssl)
|
||||
return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
switch (ssl->early_data_status) {
|
||||
case MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT:
|
||||
switch (ssl->early_data_state) {
|
||||
case MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT:
|
||||
return MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT;
|
||||
break;
|
||||
|
||||
case MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED:
|
||||
case MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED:
|
||||
return MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED;
|
||||
break;
|
||||
|
||||
case MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED:
|
||||
case MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED:
|
||||
return MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED;
|
||||
break;
|
||||
|
||||
@ -2604,8 +2604,8 @@ static int ssl_tls13_process_server_finished(mbedtls_ssl_context *ssl)
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
if (ssl->early_data_status == MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED) {
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED;
|
||||
if (ssl->early_data_state == MBEDTLS_SSL_EARLY_DATA_STATE_ACCEPTED) {
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED;
|
||||
mbedtls_ssl_handshake_set_state(ssl, MBEDTLS_SSL_END_OF_EARLY_DATA);
|
||||
} else
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
@ -3123,7 +3123,7 @@ int mbedtls_ssl_tls13_handshake_client_step(mbedtls_ssl_context *ssl)
|
||||
1, ("Switch to early data keys for outbound traffic"));
|
||||
mbedtls_ssl_set_outbound_transform(
|
||||
ssl, ssl->handshake->transform_earlydata);
|
||||
ssl->early_data_status = MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE;
|
||||
ssl->early_data_state = MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE;
|
||||
}
|
||||
break;
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
|
@ -3286,17 +3286,17 @@ tls13_read_early_data:TEST_EARLY_DATA_SERVER_REJECTS
|
||||
TLS 1.3 read early data, discard after HRR
|
||||
tls13_read_early_data:TEST_EARLY_DATA_HRR
|
||||
|
||||
TLS 1.3 cli, early data status, early data accepted
|
||||
tls13_cli_early_data_status:TEST_EARLY_DATA_ACCEPTED
|
||||
TLS 1.3 cli, early data state, early data accepted
|
||||
tls13_cli_early_data_state:TEST_EARLY_DATA_ACCEPTED
|
||||
|
||||
TLS 1.3 cli, early data status, no early data indication
|
||||
tls13_cli_early_data_status:TEST_EARLY_DATA_NO_INDICATION_SENT
|
||||
TLS 1.3 cli, early data state, no early data indication
|
||||
tls13_cli_early_data_state:TEST_EARLY_DATA_NO_INDICATION_SENT
|
||||
|
||||
TLS 1.3 cli, early data status, server rejects early data
|
||||
tls13_cli_early_data_status:TEST_EARLY_DATA_SERVER_REJECTS
|
||||
TLS 1.3 cli, early data state, server rejects early data
|
||||
tls13_cli_early_data_state:TEST_EARLY_DATA_SERVER_REJECTS
|
||||
|
||||
TLS 1.3 cli, early data status, hello retry request
|
||||
tls13_cli_early_data_status:TEST_EARLY_DATA_HRR
|
||||
TLS 1.3 cli, early data state, hello retry request
|
||||
tls13_cli_early_data_state:TEST_EARLY_DATA_HRR
|
||||
|
||||
TLS 1.3 write early data, early data accepted
|
||||
tls13_write_early_data:TEST_EARLY_DATA_ACCEPTED
|
||||
|
@ -3738,8 +3738,8 @@ void tls13_read_early_data(int scenario)
|
||||
(unsigned char *) early_data,
|
||||
early_data_len);
|
||||
|
||||
if (client_ep.ssl.early_data_status !=
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT) {
|
||||
if (client_ep.ssl.early_data_state !=
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT) {
|
||||
TEST_EQUAL(ret, early_data_len);
|
||||
} else {
|
||||
TEST_EQUAL(ret, MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA);
|
||||
@ -3790,7 +3790,7 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SSL_EARLY_DATA:MBEDTLS_SSL_CLI_C:MBEDTLS_SSL_SRV_C:MBEDTLS_TEST_AT_LEAST_ONE_TLS1_3_CIPHERSUITE:MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED:MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED:MBEDTLS_MD_CAN_SHA256:MBEDTLS_ECP_HAVE_SECP256R1:MBEDTLS_ECP_HAVE_SECP384R1:MBEDTLS_PK_CAN_ECDSA_VERIFY:MBEDTLS_SSL_SESSION_TICKETS */
|
||||
void tls13_cli_early_data_status(int scenario)
|
||||
void tls13_cli_early_data_state(int scenario)
|
||||
{
|
||||
int ret = -1;
|
||||
mbedtls_test_ssl_endpoint client_ep, server_ep;
|
||||
@ -3903,17 +3903,17 @@ void tls13_cli_early_data_status(int scenario)
|
||||
case TEST_EARLY_DATA_ACCEPTED: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
if (!client_ep.ssl.handshake->hello_retry_request_flag) {
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_UNKNOWN);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_UNKNOWN);
|
||||
} else {
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3926,22 +3926,22 @@ void tls13_cli_early_data_status(int scenario)
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_ACCEPTED: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
if (!client_ep.ssl.handshake->hello_retry_request_flag) {
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE);
|
||||
} else {
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3954,18 +3954,18 @@ void tls13_cli_early_data_status(int scenario)
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_ACCEPTED: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -3976,19 +3976,19 @@ void tls13_cli_early_data_status(int scenario)
|
||||
case MBEDTLS_SSL_SERVER_FINISHED:
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_ACCEPTED:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_ACCEPTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_ACCEPTED);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -3998,26 +3998,26 @@ void tls13_cli_early_data_status(int scenario)
|
||||
|
||||
case MBEDTLS_SSL_END_OF_EARLY_DATA:
|
||||
TEST_EQUAL(scenario, TEST_EARLY_DATA_ACCEPTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED);
|
||||
break;
|
||||
|
||||
case MBEDTLS_SSL_CLIENT_CERTIFICATE:
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_ACCEPTED:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4028,19 +4028,19 @@ void tls13_cli_early_data_status(int scenario)
|
||||
case MBEDTLS_SSL_CLIENT_FINISHED:
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_ACCEPTED:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4054,8 +4054,8 @@ void tls13_cli_early_data_status(int scenario)
|
||||
case TEST_EARLY_DATA_ACCEPTED: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SENT);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4065,21 +4065,21 @@ void tls13_cli_early_data_status(int scenario)
|
||||
|
||||
case MBEDTLS_SSL_CLIENT_CCS_BEFORE_2ND_CLIENT_HELLO:
|
||||
TEST_ASSERT(scenario == TEST_EARLY_DATA_HRR);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
case MBEDTLS_SSL_CLIENT_CCS_AFTER_SERVER_FINISHED:
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4093,19 +4093,19 @@ void tls13_cli_early_data_status(int scenario)
|
||||
case MBEDTLS_SSL_HANDSHAKE_OVER:
|
||||
switch (scenario) {
|
||||
case TEST_EARLY_DATA_ACCEPTED:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_SERVER_FINISHED_RECEIVED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_SERVER_FINISHED_RECEIVED);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_NO_INDICATION_SENT:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
break;
|
||||
|
||||
case TEST_EARLY_DATA_SERVER_REJECTS: /* Intentional fallthrough */
|
||||
case TEST_EARLY_DATA_HRR:
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_REJECTED);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_REJECTED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -4606,8 +4606,8 @@ void tls13_cli_max_early_data_size(int max_early_data_size_arg)
|
||||
ret = mbedtls_ssl_write_early_data(&(client_ep.ssl), buf, 1);
|
||||
TEST_EQUAL(ret, MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA);
|
||||
TEST_EQUAL(client_ep.ssl.total_early_data_size, max_early_data_size);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_status,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_CAN_WRITE);
|
||||
TEST_EQUAL(client_ep.ssl.early_data_state,
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_CAN_WRITE);
|
||||
|
||||
/*
|
||||
* Now, check data on server side. It is not done in the previous loop as
|
||||
@ -4780,8 +4780,8 @@ void tls13_srv_max_early_data_size(int scenario, int max_early_data_size_arg, in
|
||||
&(client_ep.ssl), &(server_ep.ssl),
|
||||
MBEDTLS_SSL_SERVER_HELLO), 0);
|
||||
|
||||
TEST_ASSERT(client_ep.ssl.early_data_status !=
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT);
|
||||
TEST_ASSERT(client_ep.ssl.early_data_state !=
|
||||
MBEDTLS_SSL_EARLY_DATA_STATE_NOT_SENT);
|
||||
|
||||
ret = mbedtls_ssl_handshake(&(server_ep.ssl));
|
||||
TEST_EQUAL(ret, MBEDTLS_ERR_SSL_WANT_READ);
|
||||
|
Loading…
x
Reference in New Issue
Block a user