1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

tls13: Add function to search for a supported_versions extension

Move in a dedicated function the search for the
supported_versions extension in a list of
extensions, to be able to use it on server side
as well.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron
2023-02-08 17:38:29 +01:00
parent f95d169d60
commit 47dce630f4
3 changed files with 86 additions and 41 deletions

View File

@ -2048,6 +2048,32 @@ int mbedtls_ssl_tls13_fetch_handshake_msg(mbedtls_ssl_context *ssl,
unsigned char **buf,
size_t *buf_len);
/**
* \brief Detect if a list of extensions contains a supported_versions
* extension or not.
*
* \param[in] ssl SSL context
* \param[in] buf Address of the first byte of the extensions vector.
* \param[in] end End of the buffer containing the list of extensions.
* \param[out] extension_data If the extension is present, address of its first
* byte of data, NULL otherwise.
* \param[out] extension_data_end If the extension is present, address of the
* first byte immediately following the extension
* data, NULL otherwise.
* \return 0 if the list of extensions does not contain a supported_versions
* extension.
* \return 1 if the list of extensions contains a supported_versions
* extension.
* \return A negative value if an error occurred while parsing the
* extensions.
*/
MBEDTLS_CHECK_RETURN_CRITICAL
int mbedtls_ssl_tls13_is_supported_versions_ext_present_in_exts(
mbedtls_ssl_context *ssl,
const unsigned char *buf, const unsigned char *end,
const unsigned char **extension_data,
const unsigned char **extension_data_end);
/*
* Handler of TLS 1.3 server certificate message
*/