mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-26 03:40:26 +00:00
Make query API for state of MFL extension internal
This commit makes the API - mbedtls_ssl_get_output_max_frag_len() - mbedtls_ssl_get_input_max_frag_len() - mbedtls_ssl_get__max_frag_len() for querying the state of the Maximum Fragment Length extension internal. Rationale: The value those APIs provide to the user is in upper bounds for the size of incoming and outgoing records, which can be used to size application data buffers apporpriately before passing them to mbedtls_ssl_{read,write}(). However, there are other factors which influence such upper bounds, such as the MTU or other extensions (specifically, the record_size_limit extension which is still to be implemented) which should be taken into account. There should be more general APIs for querying the maximum size of incoming and outgoing records. For the maximum size of outgoing records, we already have such, namely mbedtls_ssl_get_max_out_record_payload(). For the maximum size of incoming records, a new API will be added in a subsequent commit. Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
f823722af4
commit
9752aadd85
@ -3645,39 +3645,6 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
|
||||
*/
|
||||
int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
/**
|
||||
* \brief Return the maximum fragment length (payload, in bytes) for
|
||||
* the output buffer. For the client, this is the configured
|
||||
* value. For the server, it is the minimum of two - the
|
||||
* configured value and the negotiated one.
|
||||
*
|
||||
* \sa mbedtls_ssl_conf_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_max_record_payload()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum fragment length for the output buffer.
|
||||
*/
|
||||
size_t mbedtls_ssl_get_output_max_frag_len( const mbedtls_ssl_context *ssl );
|
||||
|
||||
/**
|
||||
* \brief Return the maximum fragment length (payload, in bytes) for
|
||||
* the input buffer. This is the negotiated maximum fragment
|
||||
* length, or, if there is none, MBEDTLS_SSL_IN_CONTENT_LEN.
|
||||
* If it is not defined either, the value is 2^14. This function
|
||||
* works as its predecessor, \c mbedtls_ssl_get_max_frag_len().
|
||||
*
|
||||
* \sa mbedtls_ssl_conf_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_max_record_payload()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum fragment length for the output buffer.
|
||||
*/
|
||||
size_t mbedtls_ssl_get_input_max_frag_len( const mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
/**
|
||||
* \brief Return the current maximum outgoing record payload in bytes.
|
||||
* This takes into account the config.h setting \c
|
||||
|
@ -270,6 +270,39 @@
|
||||
+ ( MBEDTLS_SSL_CID_OUT_LEN_MAX ) )
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
/**
|
||||
* \brief Return the maximum fragment length (payload, in bytes) for
|
||||
* the output buffer. For the client, this is the configured
|
||||
* value. For the server, it is the minimum of two - the
|
||||
* configured value and the negotiated one.
|
||||
*
|
||||
* \sa mbedtls_ssl_conf_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_max_out_record_payload()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum fragment length for the output buffer.
|
||||
*/
|
||||
size_t mbedtls_ssl_get_output_max_frag_len( const mbedtls_ssl_context *ssl );
|
||||
|
||||
/**
|
||||
* \brief Return the maximum fragment length (payload, in bytes) for
|
||||
* the input buffer. This is the negotiated maximum fragment
|
||||
* length, or, if there is none, MBEDTLS_SSL_MAX_CONTENT_LEN.
|
||||
* If it is not defined either, the value is 2^14. This function
|
||||
* works as its predecessor, \c mbedtls_ssl_get_max_frag_len().
|
||||
*
|
||||
* \sa mbedtls_ssl_conf_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_max_in_record_payload()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum fragment length for the output buffer.
|
||||
*/
|
||||
size_t mbedtls_ssl_get_input_max_frag_len( const mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
|
||||
static inline size_t mbedtls_ssl_get_output_buflen( const mbedtls_ssl_context *ctx )
|
||||
{
|
||||
|
@ -2083,13 +2083,6 @@ int main( int argc, char *argv[] )
|
||||
else
|
||||
mbedtls_printf( " [ Record expansion is unknown ]\n" );
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
mbedtls_printf( " [ Maximum input fragment length is %u ]\n",
|
||||
(unsigned int) mbedtls_ssl_get_input_max_frag_len( &ssl ) );
|
||||
mbedtls_printf( " [ Maximum output fragment length is %u ]\n",
|
||||
(unsigned int) mbedtls_ssl_get_output_max_frag_len( &ssl ) );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
if( opt.alpn_string != NULL )
|
||||
{
|
||||
|
@ -3164,13 +3164,6 @@ handshake:
|
||||
else
|
||||
mbedtls_printf( " [ Record expansion is unknown ]\n" );
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
mbedtls_printf( " [ Maximum input fragment length is %u ]\n",
|
||||
(unsigned int) mbedtls_ssl_get_input_max_frag_len( &ssl ) );
|
||||
mbedtls_printf( " [ Maximum output fragment length is %u ]\n",
|
||||
(unsigned int) mbedtls_ssl_get_output_max_frag_len( &ssl ) );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
if( opt.alpn_string != NULL )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user