mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Merge pull request #4811 from hanno-arm/tls13_ciphersuite_api
Add TLS 1.3 ciphersuite and key exchange identifiers and API
This commit is contained in:
@ -169,6 +169,35 @@
|
||||
/** Invalid value in SSL config */
|
||||
#define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80
|
||||
|
||||
/*
|
||||
* TLS 1.3 Key Exchange Modes
|
||||
*
|
||||
* Mbed TLS internal identifiers for use with the SSL configuration API
|
||||
* mbedtls_ssl_conf_tls13_key_exchange_modes().
|
||||
*/
|
||||
|
||||
#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ( 1u << 0 ) /*!< Pure-PSK TLS 1.3 key exchange,
|
||||
* encompassing both externally agreed PSKs
|
||||
* as well as resumption PSKs. */
|
||||
#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ( 1u << 1 ) /*!< Pure-Ephemeral TLS 1.3 key exchanges,
|
||||
* including for example ECDHE and DHE
|
||||
* key exchanges. */
|
||||
#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ( 1u << 2 ) /*!< PSK-Ephemeral TLS 1.3 key exchanges,
|
||||
* using both a PSK and an ephemeral
|
||||
* key exchange. */
|
||||
|
||||
/* Convenience macros for sets of key exchanges. */
|
||||
#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL \
|
||||
( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK | \
|
||||
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL | \
|
||||
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) /*!< All TLS 1.3 key exchanges */
|
||||
#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL \
|
||||
( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK | \
|
||||
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) /*!< All PSK-based TLS 1.3 key exchanges */
|
||||
#define MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL \
|
||||
( MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL | \
|
||||
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) /*!< All ephemeral TLS 1.3 key exchanges */
|
||||
|
||||
/*
|
||||
* Various constants
|
||||
*/
|
||||
@ -1111,6 +1140,11 @@ struct mbedtls_ssl_config
|
||||
/** Allowed ciphersuites for (D)TLS 1.2 (0-terminated) */
|
||||
const int *MBEDTLS_PRIVATE(ciphersuite_list);
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
|
||||
/** Allowed TLS 1.3 key exchange modes. */
|
||||
int MBEDTLS_PRIVATE(tls13_kex_modes);
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
|
||||
/** Callback for printing debug output */
|
||||
void (*MBEDTLS_PRIVATE(f_dbg))(void *, int, const char *, int, const char *);
|
||||
void *MBEDTLS_PRIVATE(p_dbg); /*!< context for the debug function */
|
||||
@ -2579,23 +2613,93 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session,
|
||||
/**
|
||||
* \brief Set the list of allowed ciphersuites and the preference
|
||||
* order. First in the list has the highest preference.
|
||||
* (Overrides all version-specific lists)
|
||||
*
|
||||
* The ciphersuites array is not copied, and must remain
|
||||
* valid for the lifetime of the ssl_config.
|
||||
* For TLS 1.2, the notion of ciphersuite determines both
|
||||
* the key exchange mechanism and the suite of symmetric
|
||||
* algorithms to be used during and after the handshake.
|
||||
*
|
||||
* Note: By default, the server chooses its preferred
|
||||
* For TLS 1.3 (in development), the notion of ciphersuite
|
||||
* only determines the suite of symmetric algorithms to be
|
||||
* used during and after the handshake, while key exchange
|
||||
* mechanisms are configured separately.
|
||||
*
|
||||
* In Mbed TLS, ciphersuites for both TLS 1.2 and TLS 1.3
|
||||
* are configured via this function. For users of TLS 1.3,
|
||||
* there will be separate API for the configuration of key
|
||||
* exchange mechanisms.
|
||||
*
|
||||
* The list of ciphersuites passed to this function may
|
||||
* contain a mixture of TLS 1.2 and TLS 1.3 ciphersuite
|
||||
* identifiers. This is useful if negotiation of TLS 1.3
|
||||
* should be attempted, but a fallback to TLS 1.2 would
|
||||
* be tolerated.
|
||||
*
|
||||
* \note By default, the server chooses its preferred
|
||||
* ciphersuite among those that the client supports. If
|
||||
* mbedtls_ssl_conf_preference_order() is called to prefer
|
||||
* the client's preferences, the server instead chooses
|
||||
* the client's preferred ciphersuite among those that
|
||||
* the server supports.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param ciphersuites 0-terminated list of allowed ciphersuites
|
||||
* \warning The ciphersuites array \p ciphersuites is not copied.
|
||||
* It must remain valid for the lifetime of the SSL
|
||||
* configuration \p conf.
|
||||
*
|
||||
* \param conf The SSL configuration to modify.
|
||||
* \param ciphersuites A 0-terminated list of IANA identifiers of supported
|
||||
* ciphersuites, accessible through \c MBEDTLS_TLS_XXX
|
||||
* and \c MBEDTLS_TLS1_3_XXX macros defined in
|
||||
* ssl_ciphersuites.h.
|
||||
*/
|
||||
void mbedtls_ssl_conf_ciphersuites( mbedtls_ssl_config *conf,
|
||||
const int *ciphersuites );
|
||||
const int *ciphersuites );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
|
||||
/**
|
||||
* \brief Set the supported key exchange modes for TLS 1.3 connections.
|
||||
*
|
||||
* In contrast to TLS 1.2, the ciphersuite concept in TLS 1.3 does not
|
||||
* include the choice of key exchange mechanism. It is therefore not
|
||||
* covered by the API mbedtls_ssl_conf_ciphersuites(). See the
|
||||
* documentation of mbedtls_ssl_conf_ciphersuites() for more
|
||||
* information on the ciphersuite concept in TLS 1.2 and TLS 1.3.
|
||||
*
|
||||
* The present function is specific to TLS 1.3 and allows users to
|
||||
* configure the set of supported key exchange mechanisms in TLS 1.3.
|
||||
*
|
||||
* \param conf The SSL configuration the change should apply to.
|
||||
* \param kex_modes A bitwise combination of one or more of the following:
|
||||
* - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK
|
||||
* This flag enables pure-PSK key exchanges.
|
||||
* - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL
|
||||
* This flag enables combined PSK-ephemeral key exchanges.
|
||||
* - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL
|
||||
* This flag enables pure-ephemeral key exchanges.
|
||||
* For convenience, the following pre-defined macros are
|
||||
* available for combinations of the above:
|
||||
* - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_ALL
|
||||
* Includes all of pure-PSK, PSK-ephemeral and pure-ephemeral.
|
||||
* - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL
|
||||
* Includes both pure-PSK and combined PSK-ephemeral
|
||||
* key exchanges, but excludes pure-ephemeral key exchanges.
|
||||
* - MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL
|
||||
* Includes both pure-ephemeral and combined PSK-ephemeral
|
||||
* key exchanges.
|
||||
*
|
||||
* \note If a PSK-based key exchange mode shall be supported, applications
|
||||
* must also use the APIs mbedtls_ssl_conf_psk() or
|
||||
* mbedtls_ssl_conf_psk_cb() or mbedtls_ssl_conf_psk_opaque()
|
||||
* to configure the PSKs to be used.
|
||||
*
|
||||
* \note If a pure-ephemeral key exchange mode shall be supported,
|
||||
* server-side applications must also provide a certificate via
|
||||
* mbedtls_ssl_conf_own_cert().
|
||||
*
|
||||
*/
|
||||
|
||||
void mbedtls_ssl_conf_tls13_key_exchange_modes( mbedtls_ssl_config* conf,
|
||||
const int kex_modes );
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
#define MBEDTLS_SSL_UNEXPECTED_CID_IGNORE 0
|
||||
|
Reference in New Issue
Block a user