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

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

@ -2442,14 +2442,7 @@ int main( int argc, char *argv[] )
mbedtls_printf(" . Saving session for reuse..." );
fflush( stdout );
if( ( ret = mbedtls_ssl_get_session( &ssl, &saved_session ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_get_session returned -0x%x\n\n",
-ret );
goto exit;
}
if( ( ret = mbedtls_ssl_session_save( &saved_session,
if( ( ret = mbedtls_ssl_session_save( mbedtls_ssl_get_session_pointer( &ssl ),
session_data, sizeof( session_data ),
&session_data_len ) ) != 0 )
{
@ -2458,10 +2451,6 @@ int main( int argc, char *argv[] )
goto exit;
}
/* Simulate that serialised state can have a larger lifetime than a
* structure: keep the serialised data but not the structure. */
mbedtls_ssl_session_free( &saved_session );
mbedtls_printf( " ok\n" );
}