mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Merge branch 'development_3.0' into drop_old_tls_options
This commit is contained in:
@ -683,8 +683,7 @@ int main( int argc, char *argv[] )
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
|
||||
#endif
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
rng_context_t rng;
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ssl_config conf;
|
||||
mbedtls_ssl_session saved_session;
|
||||
@ -701,7 +700,7 @@ int main( int argc, char *argv[] )
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
psa_key_id_t key_slot = 0; /* invalid key slot */
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
char *p, *q;
|
||||
const int *list;
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
@ -732,6 +731,10 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
test_hooks_init( );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
/*
|
||||
* Make sure memory references are valid.
|
||||
*/
|
||||
@ -739,7 +742,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ssl_config_init( &conf );
|
||||
memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
rng_init( &rng );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
@ -758,7 +761,10 @@ int main( int argc, char *argv[] )
|
||||
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||
|
||||
if( argc == 0 )
|
||||
{
|
||||
@ -1499,31 +1505,9 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if (opt.reproducible)
|
||||
{
|
||||
srand( 1 );
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
ret = rng_seed( &rng, opt.reproducible, pers );
|
||||
if( ret != 0 )
|
||||
goto exit;
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
@ -1546,7 +1530,6 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
{
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
for( i = 0; mbedtls_test_cas[i] != NULL; i++ )
|
||||
@ -1568,12 +1551,6 @@ int main( int argc, char *argv[] )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
if( ret < 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
|
||||
@ -1599,16 +1576,9 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
ret = mbedtls_x509_crt_parse( &clicert,
|
||||
(const unsigned char *) mbedtls_test_cli_crt,
|
||||
mbedtls_test_cli_crt_len );
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
|
||||
@ -1624,16 +1594,9 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, opt.key_pwd );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
ret = mbedtls_pk_parse_key( &pkey,
|
||||
(const unsigned char *) mbedtls_test_cli_key,
|
||||
mbedtls_test_cli_key_len, NULL, 0 );
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
|
||||
@ -1648,7 +1611,7 @@ int main( int argc, char *argv[] )
|
||||
PSA_ALG_SHA_256 ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! "
|
||||
"mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", -ret );
|
||||
"mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -1867,9 +1830,9 @@ int main( int argc, char *argv[] )
|
||||
#else
|
||||
fprintf( stderr, "Warning: reproducible option used without constant time\n" );
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
}
|
||||
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||
mbedtls_ssl_conf_rng( &conf, rng_get, &rng );
|
||||
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
|
||||
|
||||
mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout );
|
||||
@ -1908,7 +1871,7 @@ int main( int argc, char *argv[] )
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
if( opt.curves != NULL &&
|
||||
@ -2980,20 +2943,7 @@ exit:
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
psa_destroy_key( key_slot );
|
||||
#endif
|
||||
#endif
|
||||
mbedtls_ssl_session_free( &saved_session );
|
||||
mbedtls_ssl_free( &ssl );
|
||||
mbedtls_ssl_config_free( &conf );
|
||||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
if( session_data != NULL )
|
||||
mbedtls_platform_zeroize( session_data, session_data_len );
|
||||
mbedtls_free( session_data );
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
if( context_buf != NULL )
|
||||
mbedtls_platform_zeroize( context_buf, context_buf_len );
|
||||
mbedtls_free( context_buf );
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) && \
|
||||
defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
@ -3016,12 +2966,39 @@ exit:
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED &&
|
||||
MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
mbedtls_ssl_session_free( &saved_session );
|
||||
mbedtls_ssl_free( &ssl );
|
||||
mbedtls_ssl_config_free( &conf );
|
||||
rng_free( &rng );
|
||||
if( session_data != NULL )
|
||||
mbedtls_platform_zeroize( session_data, session_data_len );
|
||||
mbedtls_free( session_data );
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
if( context_buf != NULL )
|
||||
mbedtls_platform_zeroize( context_buf, context_buf_len );
|
||||
mbedtls_free( context_buf );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
mbedtls_psa_crypto_free( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
if( test_hooks_failure_detected( ) )
|
||||
{
|
||||
if( ret == 0 )
|
||||
ret = 1;
|
||||
mbedtls_printf( "Test hooks detected errors.\n" );
|
||||
}
|
||||
test_hooks_free( );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_memory_buffer_alloc_status();
|
||||
#endif
|
||||
mbedtls_memory_buffer_alloc_free();
|
||||
#endif
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
|
||||
#if defined(_WIN32)
|
||||
if( opt.query_config_mode == DFL_QUERY_CONFIG_MODE )
|
||||
|
Reference in New Issue
Block a user