Add a field for application data to TLS structures

In structure types that are passed to user callbacks, add a field that the
library won't ever care about. The application can use this field to either
identify an instance of the structure with a handle, or store a pointer to
extra data.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2022-01-13 01:01:45 +01:00
parent 436b72690d
commit 69477b5706
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,3 @@
Features
* The structures mbedtls_ssl_config and mbedtls_ssl_context have an
extra field user_data which is reserved for the application.

View file

@ -1448,6 +1448,13 @@ struct mbedtls_ssl_config
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_CLI_C)
unsigned int MBEDTLS_PRIVATE(dhm_min_bitlen); /*!< min. bit length of the DHM prime */
#endif
/** User data pointer or handle.
*
* The library sets this to \p 0 when creating a context and does not
* access it afterwards.
*/
uintptr_t user_data;
};
struct mbedtls_ssl_context
@ -1669,6 +1676,13 @@ struct mbedtls_ssl_context
/** Callback to export key block and master secret */
mbedtls_ssl_export_keys_t *MBEDTLS_PRIVATE(f_export_keys);
void *MBEDTLS_PRIVATE(p_export_keys); /*!< context for key export callback */
/** User data pointer or handle.
*
* The library sets this to \p 0 when creating a context and does not
* access it afterwards.
*/
uintptr_t user_data;
};
/**