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:
Ronald Cron
2024-03-03 15:03:22 +01:00
parent ec4ed8eae4
commit d2884662c1
7 changed files with 138 additions and 119 deletions

View File

@@ -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 */