mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 09:35:39 +01:00
Serialize/deserialize for ssl_server2
This commit is contained in:
parent
af30629686
commit
5a3a16cb1b
@ -3918,7 +3918,53 @@ data_exchange:
|
||||
ret = 0;
|
||||
|
||||
/*
|
||||
* 7b. Continue doing data exchanges?
|
||||
* 7b. Simulate serialize/deserialize and go back to data exchange
|
||||
*/
|
||||
if( opt.serialize != 0)
|
||||
{
|
||||
size_t len;
|
||||
unsigned char *buf = NULL;
|
||||
|
||||
opt.serialize = 0;
|
||||
mbedtls_printf( " Serializing live connection..." );
|
||||
|
||||
if( ( ret = mbedtls_ssl_context_save( &ssl, NULL, 0, &len) ) != MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_context_save returned -0x%x\n\n", -ret );
|
||||
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( ( buf = mbedtls_calloc(1, len) ) == NULL )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! Couldn't allocate buffer for serialized context" );
|
||||
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( ( ret = mbedtls_ssl_context_save( &ssl, buf, len, &len ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( "failed\n ! mbedtls_ssl_context_save returned -0x%x\n\n", -ret );
|
||||
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mbedtls_ssl_free( &ssl );
|
||||
|
||||
mbedtls_printf( " Deserializing connection..." );
|
||||
|
||||
mbedtls_ssl_init( &ssl );
|
||||
|
||||
if( ( ret = mbedtls_ssl_context_load( &ssl, buf, len ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( "failed\n ! mbedtls_ssl_context_load returned -0x%x\n\n", -ret );
|
||||
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 7c. Continue doing data exchanges?
|
||||
*/
|
||||
if( --exchanges_left > 0 )
|
||||
goto data_exchange;
|
||||
|
Loading…
Reference in New Issue
Block a user