Add mbedtls_ssl_get_session_pointer()

Avoid useless copy with mbedtls_ssl_get_session() before serialising.

Used in ssl_client2 for testing and demonstrating usage, but unfortunately
that means mbedtls_ssl_get_session() is no longer tested, which will be fixed
in the next commit.
This commit is contained in:
Manuel Pégourié-Gonnard 2019-05-20 11:12:28 +02:00 committed by Jarno Lamsa
parent 21548638b7
commit b5e4e0a395
3 changed files with 27 additions and 13 deletions

View file

@ -2387,7 +2387,7 @@ int mbedtls_ssl_session_load( mbedtls_ssl_session *session,
* of session cache or session tickets.
*
* \see mbedtls_ssl_session_load()
* \see mbedtls_ssl_get_session()
* \see mbedtls_ssl_get_session_pointer()
*
* \param session The session structure to be saved.
* \param buf The buffer to write the serialized data to. It must be a
@ -2404,6 +2404,23 @@ int mbedtls_ssl_session_save( const mbedtls_ssl_session *session,
size_t buf_len,
size_t *olen );
/**
* \brief Get a pointer to the current session structure, for example
* to serialise it.
*
* \warning Ownership of the session remains with the SSL context - the
* returned pointer must not be kept after the connection has
* ended or been renegotiated.
*
* \see mbedtls_ssl_session_save()
*
* \param ssl SSL context
*
* \return A pointer to the current session if successful,
* NULL if no session is active.
*/
const mbedtls_ssl_session *mbedtls_ssl_get_session_pointer( const mbedtls_ssl_context *ssl );
/**
* \brief Set the list of allowed ciphersuites and the preference
* order. First in the list has the highest preference.