mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Split ssl_init() -> ssl_setup()
This commit is contained in:
parent
ec160c0f53
commit
41d479e7df
15 changed files with 57 additions and 41 deletions
|
|
@ -104,7 +104,7 @@ int main( int argc, char *argv[] )
|
|||
/*
|
||||
* 0. Initialize the RNG and the session data
|
||||
*/
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
|
|
@ -160,9 +160,9 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Setting up the DTLS structure..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned %d\n\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ int main( void )
|
|||
mbedtls_ssl_cache_context cache;
|
||||
#endif
|
||||
|
||||
memset( &ssl, 0, sizeof(mbedtls_ssl_context) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ssl_cookie_init( &cookie_ctx );
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
mbedtls_ssl_cache_init( &cache );
|
||||
|
|
@ -190,9 +190,9 @@ int main( void )
|
|||
printf( " . Setting up the DTLS data..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
printf( " failed\n ! mbedtls_ssl_init returned %d\n\n", ret );
|
||||
printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ enum exit_codes
|
|||
{
|
||||
exit_ok = 0,
|
||||
ctr_drbg_seed_failed,
|
||||
ssl_init_failed,
|
||||
ssl_setup_failed,
|
||||
socket_failed,
|
||||
connect_failed,
|
||||
x509_crt_parse_failed,
|
||||
|
|
@ -172,7 +172,7 @@ int main( void )
|
|||
/*
|
||||
* 0. Initialize and setup stuff
|
||||
*/
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &ca );
|
||||
#endif
|
||||
|
|
@ -181,13 +181,13 @@ int main( void )
|
|||
if( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers, strlen( pers ) ) != 0 )
|
||||
{
|
||||
ret = ssl_init_failed;
|
||||
ret = ctr_drbg_seed_failed;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( mbedtls_ssl_init( &ssl ) != 0 )
|
||||
if( mbedtls_ssl_setup( &ssl ) != 0 )
|
||||
{
|
||||
ret = ssl_init_failed;
|
||||
ret = ssl_setup_failed;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ int main( void )
|
|||
/*
|
||||
* 0. Initialize the RNG and the session data
|
||||
*/
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
|
|
@ -148,9 +148,9 @@ int main( void )
|
|||
mbedtls_printf( " . Setting up the SSL/TLS structure..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned %d\n\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
@ -278,8 +278,6 @@ exit:
|
|||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
|
||||
memset( &ssl, 0, sizeof( ssl ) );
|
||||
|
||||
#if defined(_WIN32)
|
||||
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
||||
fflush( stdout ); getchar();
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ int main( int argc, char *argv[] )
|
|||
* Make sure memory references are valid.
|
||||
*/
|
||||
server_fd = 0;
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
|
|
@ -1047,9 +1047,9 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Setting up the SSL/TLS structure..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned -0x%x\n\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,9 +248,9 @@ int main( void )
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned %d\n\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ int main( int argc, char *argv[] )
|
|||
* Make sure memory references are valid in case we exit early.
|
||||
*/
|
||||
server_fd = 0;
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
memset( &buf, 0, sizeof( buf ) );
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
|
|
@ -582,9 +582,9 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Setting up the SSL/TLS structure..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned %d\n\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static void *handle_ssl_connection( void *data )
|
|||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
|
||||
/* Make sure memory references are valid */
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
|
||||
mbedtls_snprintf( pers, sizeof(pers), "SSL Pthread Thread %d", thread_id );
|
||||
|
|
@ -158,9 +158,9 @@ static void *handle_ssl_connection( void *data )
|
|||
*/
|
||||
mbedtls_printf( " [ #%d ] Setting up the SSL data....\n", thread_id );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " [ #%d ] failed: mbedtls_ssl_init returned -0x%04x\n",
|
||||
mbedtls_printf( " [ #%d ] failed: mbedtls_ssl_setup returned -0x%04x\n",
|
||||
thread_id, -ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ int main( void )
|
|||
mbedtls_ssl_cache_context cache;
|
||||
#endif
|
||||
|
||||
memset( &ssl, 0, sizeof(mbedtls_ssl_context) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
mbedtls_ssl_cache_init( &cache );
|
||||
#endif
|
||||
|
|
@ -189,9 +189,9 @@ int main( void )
|
|||
mbedtls_printf( " . Setting up the SSL data...." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned %d\n\n", ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ int main( int argc, char *argv[] )
|
|||
* Make sure memory references are valid in case we exit early.
|
||||
*/
|
||||
listen_fd = 0;
|
||||
memset( &ssl, 0, sizeof( mbedtls_ssl_context ) );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
|
|
@ -1518,9 +1518,9 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Setting up the SSL/TLS structure..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_ssl_init( &ssl ) ) != 0 )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_init returned -0x%x\n\n", -ret );
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue