mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-10 19:45:39 +00:00
Various changes to get CI passing after changes in ssl_server and client stack to heap
This commit is contained in:
parent
52c9ecb408
commit
8e0fe19a6a
|
@ -997,18 +997,24 @@ int main( int argc, char *argv[] )
|
||||||
#else
|
#else
|
||||||
hmac_drbg = mbedtls_calloc( 1, sizeof( *hmac_drbg ) );
|
hmac_drbg = mbedtls_calloc( 1, sizeof( *hmac_drbg ) );
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
cacert = mbedtls_calloc( 1, sizeof( *cacert ) );
|
cacert = mbedtls_calloc( 1, sizeof( *cacert ) );
|
||||||
clicert = mbedtls_calloc( 1, sizeof( *clicert ) );
|
clicert = mbedtls_calloc( 1, sizeof( *clicert ) );
|
||||||
pkey = mbedtls_calloc( 1, sizeof( *pkey ) );
|
pkey = mbedtls_calloc( 1, sizeof( *pkey ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( ssl == NULL || conf == NULL ||
|
if( ssl == NULL || entropy == NULL ||
|
||||||
entropy == NULL || cacert == NULL ||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
|
cacert == NULL ||
|
||||||
|
clicert== NULL || pkey == NULL ||
|
||||||
|
#endif
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
ctr_drbg == NULL ||
|
ctr_drbg == NULL ||
|
||||||
#else
|
#else
|
||||||
hmac_drbg == NULL ||
|
hmac_drbg == NULL ||
|
||||||
#endif
|
#endif
|
||||||
clicert == NULL || pkey == NULL )
|
|
||||||
|
conf == NULL)
|
||||||
{
|
{
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -2993,10 +2999,11 @@ exit:
|
||||||
#else
|
#else
|
||||||
mbedtls_free( hmac_drbg );
|
mbedtls_free( hmac_drbg );
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_free( cacert );
|
mbedtls_free( cacert );
|
||||||
mbedtls_free( clicert );
|
mbedtls_free( clicert );
|
||||||
mbedtls_free( pkey );
|
mbedtls_free( pkey );
|
||||||
|
#endif
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
mbedtls_printf( " + Press Enter to exit this program.\n" );
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
|
|
|
@ -1561,16 +1561,16 @@ int main( int argc, char *argv[] )
|
||||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
|
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
|
||||||
#endif
|
#endif
|
||||||
mbedtls_entropy_context *entropy;
|
mbedtls_entropy_context entropy;
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
mbedtls_ctr_drbg_context *ctr_drbg;
|
mbedtls_ctr_drbg_context *ctr_drbg = NULL;
|
||||||
#else
|
#else
|
||||||
mbedtls_hmac_drbg_context *hmac_drbg;
|
mbedtls_hmac_drbg_context *hmac_drbg = NULL;
|
||||||
#endif
|
#endif
|
||||||
mbedtls_ssl_context *ssl = NULL;
|
mbedtls_ssl_context *ssl = NULL;
|
||||||
mbedtls_ssl_config *conf = NULL;
|
mbedtls_ssl_config *conf = NULL;
|
||||||
#if defined(MBEDTLS_TIMING_C)
|
#if defined(MBEDTLS_TIMING_C)
|
||||||
mbedtls_timing_delay_context *timer;
|
mbedtls_timing_delay_context *timer = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||||
unsigned char renego_period[8] = { 0 };
|
unsigned char renego_period[8] = { 0 };
|
||||||
|
@ -1594,7 +1594,7 @@ int main( int argc, char *argv[] )
|
||||||
mbedtls_ssl_cache_context *cache = NULL;
|
mbedtls_ssl_cache_context *cache = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
mbedtls_ssl_ticket_context *ticket_ctx;
|
mbedtls_ssl_ticket_context *ticket_ctx = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(SNI_OPTION)
|
#if defined(SNI_OPTION)
|
||||||
sni_entry *sni_info = NULL;
|
sni_entry *sni_info = NULL;
|
||||||
|
@ -2288,56 +2288,34 @@ int main( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do all necessary allocations and initializations */
|
|
||||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||||
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
|
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssl = mbedtls_calloc( 1, sizeof( *ssl ) );
|
ssl = mbedtls_calloc( 1, sizeof( *ssl ) );
|
||||||
conf = mbedtls_calloc( 1, sizeof( *conf ) );
|
conf = mbedtls_calloc( 1, sizeof( *conf ) );
|
||||||
cacert = mbedtls_calloc( 1, sizeof( *cacert ) );
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
srvcert = mbedtls_calloc( 1, sizeof( *srvcert ) );
|
cacert = mbedtls_calloc( 1, sizeof( *cacert ) );
|
||||||
pkey = mbedtls_calloc( 1, sizeof( *pkey ) );
|
srvcert = mbedtls_calloc( 1, sizeof( *srvcert ) );
|
||||||
srvcert2 = mbedtls_calloc( 1, sizeof( *srvcert2 ) );
|
pkey = mbedtls_calloc( 1, sizeof( *pkey ) );
|
||||||
pkey2 = mbedtls_calloc( 1, sizeof( *pkey2 ) );
|
srvcert2 = mbedtls_calloc( 1, sizeof( *srvcert2 ) );
|
||||||
|
pkey2 = mbedtls_calloc( 1, sizeof( *pkey2 ) );
|
||||||
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||||
cache = mbedtls_calloc( 1, sizeof( *cache ) );
|
cache = mbedtls_calloc( 1, sizeof( *cache ) );
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_TIMING_C)
|
#if defined(MBEDTLS_TIMING_C)
|
||||||
timer = mbedtls_calloc( 1, sizeof( *timer ) );
|
timer = mbedtls_calloc( 1, sizeof( *timer ) );
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
ticket_ctx = mbedtls_calloc( 1, sizeof( *ticket_ctx ) );
|
ticket_ctx = mbedtls_calloc( 1, sizeof( *ticket_ctx ) );
|
||||||
#endif
|
|
||||||
entropy = mbedtls_calloc( 1, sizeof( *entropy ) );
|
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
|
||||||
ctr_drbg = mbedtls_calloc( 1, sizeof( *ctr_drbg ) );
|
|
||||||
#else
|
|
||||||
hmac_drbg = mbedtls_calloc( 1, sizeof( *hmac_drbg ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( ssl == NULL || conf == NULL ||
|
|
||||||
cacert == NULL || srvcert == NULL ||
|
|
||||||
pkey == NULL || srvcert2 == NULL ||
|
|
||||||
pkey2 == NULL ||
|
|
||||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
|
||||||
cache == NULL ||
|
|
||||||
#endif
|
|
||||||
#if defined(MBEDTLS_TIMING_C)
|
|
||||||
timer == NULL ||
|
|
||||||
#endif
|
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
|
||||||
ticket_ctx == NULL ||
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
ctr_drbg == NULL ||
|
ctr_drbg = mbedtls_calloc( 1, sizeof( *ctr_drbg ) );
|
||||||
#else
|
#else
|
||||||
hmac_drbg == NULL ||
|
hmac_drbg = mbedtls_calloc( 1, sizeof( *hmac_drbg ) );
|
||||||
#endif
|
#endif
|
||||||
entropy == NULL )
|
|
||||||
{
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure memory references are valid in case we exit early.
|
* Make sure memory references are valid in case we exit early.
|
||||||
|
@ -2346,6 +2324,7 @@ int main( int argc, char *argv[] )
|
||||||
mbedtls_net_init( &listen_fd );
|
mbedtls_net_init( &listen_fd );
|
||||||
mbedtls_ssl_init( ssl );
|
mbedtls_ssl_init( ssl );
|
||||||
mbedtls_ssl_config_init( conf );
|
mbedtls_ssl_config_init( conf );
|
||||||
|
mbedtls_entropy_init( &entropy );
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
mbedtls_ctr_drbg_init( ctr_drbg );
|
mbedtls_ctr_drbg_init( ctr_drbg );
|
||||||
#else
|
#else
|
||||||
|
@ -2377,8 +2356,31 @@ int main( int argc, char *argv[] )
|
||||||
mbedtls_ssl_cookie_init( &cookie_ctx );
|
mbedtls_ssl_cookie_init( &cookie_ctx );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if( ssl == NULL ||
|
||||||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
|
cacert == NULL || srvcert == NULL ||
|
||||||
|
pkey == NULL || srvcert2 == NULL ||
|
||||||
|
pkey2 == NULL ||
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
|
ticket_ctx == NULL ||
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||||
|
cache == NULL ||
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_TIMING_C)
|
||||||
|
timer == NULL ||
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
|
ctr_drbg == NULL ||
|
||||||
|
#else
|
||||||
|
hmac_drbg == NULL ||
|
||||||
|
#endif
|
||||||
|
conf == NULL)
|
||||||
|
{
|
||||||
|
mbedtls_printf( "Initial allocations failed!\n" );
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||||
|
@ -2504,10 +2506,9 @@ int main( int argc, char *argv[] )
|
||||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
mbedtls_entropy_init( entropy );
|
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
if( ( ret = mbedtls_ctr_drbg_seed( ctr_drbg, mbedtls_entropy_func,
|
if( ( ret = mbedtls_ctr_drbg_seed( ctr_drbg, mbedtls_entropy_func,
|
||||||
entropy, (const unsigned char *) pers,
|
&entropy, (const unsigned char *) pers,
|
||||||
strlen( pers ) ) ) != 0 )
|
strlen( pers ) ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||||
|
@ -2519,7 +2520,7 @@ int main( int argc, char *argv[] )
|
||||||
mbedtls_md_info_from_type(
|
mbedtls_md_info_from_type(
|
||||||
available_hashes[0] ),
|
available_hashes[0] ),
|
||||||
mbedtls_entropy_func,
|
mbedtls_entropy_func,
|
||||||
entropy, (const unsigned char *) pers,
|
&entropy, (const unsigned char *) pers,
|
||||||
strlen( pers ) ) ) != 0 )
|
strlen( pers ) ) ) != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||||
|
@ -2565,7 +2566,7 @@ int main( int argc, char *argv[] )
|
||||||
#endif /* MBEDTLS_PEM_PARSE_C */
|
#endif /* MBEDTLS_PEM_PARSE_C */
|
||||||
for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ )
|
for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ )
|
||||||
{
|
{
|
||||||
ret = mbedtls_x509_crt_parse_der_nocopy( cacert,
|
ret = mbedtls_x509_crt_parse_der( cacert,
|
||||||
(const unsigned char *) mbedtls_test_cas_der[i],
|
(const unsigned char *) mbedtls_test_cas_der[i],
|
||||||
mbedtls_test_cas_der_len[i] );
|
mbedtls_test_cas_der_len[i] );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
|
@ -3922,7 +3923,6 @@ close_notify:
|
||||||
* Cleanup and exit
|
* Cleanup and exit
|
||||||
*/
|
*/
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
#ifdef MBEDTLS_ERROR_C
|
#ifdef MBEDTLS_ERROR_C
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
|
@ -3971,20 +3971,19 @@ exit:
|
||||||
|
|
||||||
mbedtls_ssl_free( ssl );
|
mbedtls_ssl_free( ssl );
|
||||||
mbedtls_ssl_config_free( conf );
|
mbedtls_ssl_config_free( conf );
|
||||||
|
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
mbedtls_ctr_drbg_free( ctr_drbg );
|
mbedtls_ctr_drbg_free( ctr_drbg );
|
||||||
#else
|
#else
|
||||||
mbedtls_hmac_drbg_free( hmac_drbg );
|
mbedtls_hmac_drbg_free( hmac_drbg );
|
||||||
#endif
|
#endif
|
||||||
mbedtls_entropy_free( entropy );
|
mbedtls_entropy_free( &entropy );
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||||
mbedtls_ssl_cache_free( cache );
|
mbedtls_ssl_cache_free( cache );
|
||||||
mbedtls_free( cache );
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
mbedtls_ssl_ticket_free( ticket_ctx );
|
mbedtls_ssl_ticket_free( ticket_ctx );
|
||||||
mbedtls_free( ticket_ctx );
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SSL_COOKIE_C)
|
#if defined(MBEDTLS_SSL_COOKIE_C)
|
||||||
mbedtls_ssl_cookie_free( &cookie_ctx );
|
mbedtls_ssl_cookie_free( &cookie_ctx );
|
||||||
|
@ -4000,15 +3999,22 @@ exit:
|
||||||
|
|
||||||
mbedtls_free( ssl );
|
mbedtls_free( ssl );
|
||||||
mbedtls_free( conf );
|
mbedtls_free( conf );
|
||||||
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||||
mbedtls_free( cacert );
|
mbedtls_free( cacert );
|
||||||
mbedtls_free( srvcert );
|
mbedtls_free( srvcert );
|
||||||
mbedtls_free( pkey );
|
mbedtls_free( pkey );
|
||||||
mbedtls_free( srvcert2 );
|
mbedtls_free( srvcert2 );
|
||||||
mbedtls_free( pkey2 );
|
mbedtls_free( pkey2 );
|
||||||
|
#endif
|
||||||
|
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||||
|
mbedtls_free( cache );
|
||||||
|
#endif
|
||||||
#if defined(MBEDTLS_TIMING_C)
|
#if defined(MBEDTLS_TIMING_C)
|
||||||
mbedtls_free( timer );
|
mbedtls_free( timer );
|
||||||
#endif
|
#endif
|
||||||
mbedtls_free( entropy );
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
|
mbedtls_free( ticket_ctx );
|
||||||
|
#endif
|
||||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||||
mbedtls_free( ctr_drbg );
|
mbedtls_free( ctr_drbg );
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue