Merge pull request #6537 from yuhaoth/pr/tls13-refactor-early-data-configuration-interface
TLS 1.3: Refactor early data configuration interface.
This commit is contained in:
commit
fbba0e9d75
5 changed files with 116 additions and 0 deletions
|
@ -32,6 +32,8 @@
|
|||
#error "mbed TLS requires a platform with 8-bit chars"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if !defined(MBEDTLS_PLATFORM_C)
|
||||
#error "MBEDTLS_PLATFORM_C is required on Windows"
|
||||
|
@ -849,6 +851,13 @@
|
|||
#error "MBEDTLS_SSL_EARLY_DATA defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_SRV_C) && \
|
||||
( !defined(MBEDTLS_SSL_MAX_EARLY_DATA_SIZE) || \
|
||||
( MBEDTLS_SSL_MAX_EARLY_DATA_SIZE < 0 ) || \
|
||||
( MBEDTLS_SSL_MAX_EARLY_DATA_SIZE > UINT32_MAX ) )
|
||||
#error "MBEDTLS_SSL_MAX_EARLY_DATA_SIZE MUST be defined and in range(0..UINT32_MAX)"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS) && \
|
||||
!defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
#error "MBEDTLS_SSL_PROTO_DTLS defined, but not all prerequisites"
|
||||
|
|
|
@ -1673,6 +1673,23 @@
|
|||
*/
|
||||
//#define MBEDTLS_SSL_EARLY_DATA
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_MAX_EARLY_DATA_SIZE
|
||||
*
|
||||
* The default maximum amount of 0-RTT data. See the documentation of
|
||||
* \c mbedtls_ssl_tls13_conf_max_early_data_size() for more information.
|
||||
*
|
||||
* It must be positive and smaller than UINT32_MAX.
|
||||
*
|
||||
* If MBEDTLS_SSL_EARLY_DATA is not defined, this default value does not
|
||||
* have any impact on the build.
|
||||
*
|
||||
* This feature is experimental, not completed and thus not ready for
|
||||
* production.
|
||||
*
|
||||
*/
|
||||
#define MBEDTLS_SSL_MAX_EARLY_DATA_SIZE 1024
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_SSL_PROTO_DTLS
|
||||
*
|
||||
|
|
|
@ -1527,6 +1527,12 @@ struct mbedtls_ssl_config
|
|||
int MBEDTLS_PRIVATE(early_data_enabled); /*!< Early data enablement:
|
||||
* - MBEDTLS_SSL_EARLY_DATA_DISABLED,
|
||||
* - MBEDTLS_SSL_EARLY_DATA_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
/* The maximum amount of 0-RTT data. RFC 8446 section 4.6.1 */
|
||||
uint32_t MBEDTLS_PRIVATE(max_early_data_size);
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
|
@ -1964,6 +1970,35 @@ void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
|
|||
*/
|
||||
void mbedtls_ssl_tls13_conf_early_data( mbedtls_ssl_config *conf,
|
||||
int early_data_enabled );
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
/**
|
||||
* \brief Set the maximum amount of 0-RTT data in bytes
|
||||
* Default: #MBEDTLS_SSL_MAX_EARLY_DATA_SIZE
|
||||
*
|
||||
* This function sets the value of the max_early_data_size
|
||||
* field of the early data indication extension included in
|
||||
* the NewSessionTicket messages that the server may send.
|
||||
*
|
||||
* The value defines the maximum amount of 0-RTT data
|
||||
* in bytes that a client will be allowed to send when using
|
||||
* one of the tickets defined by the NewSessionTicket messages.
|
||||
*
|
||||
* \note When resuming a session using a ticket, if the server receives more
|
||||
* early data than allowed for the ticket, it terminates the connection.
|
||||
* The maximum amount of 0-RTT data should thus be large enough
|
||||
* to allow a minimum of early data to be exchanged.
|
||||
*
|
||||
* \param[in] conf The SSL configuration to use.
|
||||
* \param[in] max_early_data_size The maximum amount of 0-RTT data.
|
||||
*
|
||||
* \warning This interface is experimental and may change without notice.
|
||||
*
|
||||
*/
|
||||
void mbedtls_ssl_tls13_conf_max_early_data_size(
|
||||
mbedtls_ssl_config *conf, uint32_t max_early_data_size );
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 && MBEDTLS_SSL_EARLY_DATA */
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue