mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:45:42 +01:00
Merge remote-tracking branch 'upstream-public/pr/1570' into development-proposed
Resolve merge conflict in ChangeLog.
This commit is contained in:
commit
38c42d5afa
@ -95,6 +95,7 @@ Changes
|
||||
by Jiayuan Chen in #1377. Fixes #1437.
|
||||
* Improve security of RSA key generation by including criteria from FIPS
|
||||
186-4. Contributed by Jethro Beekman. #1380
|
||||
* Add platform setup and teardown calls in test suites.
|
||||
|
||||
= mbed TLS 2.8.0 branch released 2018-03-16
|
||||
|
||||
|
@ -109,6 +109,9 @@ static struct
|
||||
}
|
||||
test_info;
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
mbedtls_platform_context platform_ctx;
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Helper flags for complex dependencies */
|
||||
@ -127,6 +130,21 @@ test_info;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
static int platform_setup()
|
||||
{
|
||||
int ret = 0;
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
ret = mbedtls_platform_setup( &platform_ctx );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
return( ret );
|
||||
}
|
||||
|
||||
static void platform_teardown()
|
||||
{
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
mbedtls_platform_teardown( &platform_ctx );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
}
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
static int redirect_output( FILE** out_stream, const char* path )
|
||||
|
@ -281,6 +281,18 @@ int main(int argc, const char *argv[])
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
|
||||
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
|
||||
unsigned char alloc_buf[1000000];
|
||||
#endif
|
||||
/* Platform setup should be called in the beginning */
|
||||
ret = platform_setup();
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"FATAL: Failed to initialize platform - error %d\n",
|
||||
ret );
|
||||
return( -1 );
|
||||
}
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
|
||||
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
|
||||
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
|
||||
#endif
|
||||
|
||||
@ -293,6 +305,7 @@ int main(int argc, const char *argv[])
|
||||
if( pointer != NULL )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" );
|
||||
platform_teardown();
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -302,7 +315,8 @@ int main(int argc, const char *argv[])
|
||||
if( run_test_snprintf() != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "the snprintf implementation is broken\n" );
|
||||
return( 0 );
|
||||
platform_teardown();
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
while( arg_index < argc)
|
||||
@ -318,6 +332,7 @@ int main(int argc, const char *argv[])
|
||||
strcmp(next_arg, "-h" ) == 0 )
|
||||
{
|
||||
mbedtls_fprintf( stdout, USAGE );
|
||||
platform_teardown();
|
||||
mbedtls_exit( EXIT_SUCCESS );
|
||||
}
|
||||
else
|
||||
@ -357,6 +372,7 @@ int main(int argc, const char *argv[])
|
||||
{
|
||||
mbedtls_fprintf( stderr, "Failed to open test file: %s\n",
|
||||
test_filename );
|
||||
platform_teardown();
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -366,6 +382,7 @@ int main(int argc, const char *argv[])
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"FATAL: Dep count larger than zero at start of loop\n" );
|
||||
platform_teardown();
|
||||
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
|
||||
}
|
||||
unmet_dep_count = 0;
|
||||
@ -402,6 +419,7 @@ int main(int argc, const char *argv[])
|
||||
if( unmet_dependencies[ unmet_dep_count ] == NULL )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "FATAL: Out of memory\n" );
|
||||
platform_teardown();
|
||||
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
|
||||
}
|
||||
unmet_dep_count++;
|
||||
@ -427,6 +445,7 @@ int main(int argc, const char *argv[])
|
||||
stdout_fd = redirect_output( &stdout, "/dev/null" );
|
||||
if( stdout_fd == -1 )
|
||||
{
|
||||
platform_teardown();
|
||||
/* Redirection has failed with no stdout so exit */
|
||||
exit( 1 );
|
||||
}
|
||||
@ -439,6 +458,7 @@ int main(int argc, const char *argv[])
|
||||
if( !option_verbose && restore_output( &stdout, stdout_fd ) )
|
||||
{
|
||||
/* Redirection has failed with no stdout so exit */
|
||||
platform_teardown();
|
||||
exit( 1 );
|
||||
}
|
||||
#endif /* __unix__ || __APPLE__ __MACH__ */
|
||||
@ -490,6 +510,7 @@ int main(int argc, const char *argv[])
|
||||
{
|
||||
mbedtls_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
|
||||
fclose( file );
|
||||
platform_teardown();
|
||||
mbedtls_exit( 2 );
|
||||
}
|
||||
else
|
||||
@ -501,6 +522,7 @@ int main(int argc, const char *argv[])
|
||||
{
|
||||
mbedtls_fprintf( stderr, "Should be empty %d\n",
|
||||
(int) strlen( buf ) );
|
||||
platform_teardown();
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
@ -533,5 +555,6 @@ int main(int argc, const char *argv[])
|
||||
close_output( stdout );
|
||||
#endif /* __unix__ || __APPLE__ __MACH__ */
|
||||
|
||||
platform_teardown();
|
||||
return( total_errors != 0 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user