From b4e5ddce1b83170c6660a0b18d2951b9de6954f4 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Fri, 9 Oct 2020 09:36:01 +0100 Subject: [PATCH] Fix X.509 CRT parsing test if MBEDTLS_X509_REMOVE_INFO is set Signed-off-by: Hanno Becker --- tests/suites/test_suite_x509parse.function | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function index 82f7da54a..54a39ff7c 100644 --- a/tests/suites/test_suite_x509parse.function +++ b/tests/suites/test_suite_x509parse.function @@ -830,6 +830,8 @@ void x509parse_crt( data_t * buf, char * result_str, int result ) #if !defined(MBEDTLS_X509_REMOVE_INFO) unsigned char output[2000]; int res; +#else + ((void) result_str); #endif mbedtls_x509_crt_init( &crt ); @@ -844,15 +846,11 @@ void x509parse_crt( data_t * buf, char * result_str, int result ) TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 ); } -#else - ((void) result_str); + memset( output, 0, 2000 ); #endif mbedtls_x509_crt_free( &crt ); mbedtls_x509_crt_init( &crt ); -#if !defined(MBEDTLS_X509_REMOVE_INFO) - memset( output, 0, 2000 ); -#endif TEST_ASSERT( mbedtls_x509_crt_parse_der_nocopy( &crt, buf->x, buf->len ) == ( result ) ); #if !defined(MBEDTLS_X509_REMOVE_INFO) @@ -867,15 +865,14 @@ void x509parse_crt( data_t * buf, char * result_str, int result ) TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 ); } -#else - ((void)result_str); -#endif + memset( output, 0, 2000 ); +#endif /* !MBEDTLS_X509_REMOVE_INFO */ mbedtls_x509_crt_free( &crt ); mbedtls_x509_crt_init( &crt ); - memset( output, 0, 2000 ); TEST_ASSERT( mbedtls_x509_crt_parse_der_with_ext_cb( &crt, buf->x, buf->len, 0, NULL, NULL ) == ( result ) ); +#if !defined(MBEDTLS_X509_REMOVE_INFO) if( ( result ) == 0 ) { res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt ); @@ -885,12 +882,14 @@ void x509parse_crt( data_t * buf, char * result_str, int result ) TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 ); } + memset( output, 0, 2000 ); +#endif /* !MBEDTLS_X509_REMOVE_INFO */ mbedtls_x509_crt_free( &crt ); mbedtls_x509_crt_init( &crt ); - memset( output, 0, 2000 ); TEST_ASSERT( mbedtls_x509_crt_parse_der_with_ext_cb( &crt, buf->x, buf->len, 1, NULL, NULL ) == ( result ) ); +#if !defined(MBEDTLS_X509_REMOVE_INFO) if( ( result ) == 0 ) { res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt ); @@ -900,6 +899,7 @@ void x509parse_crt( data_t * buf, char * result_str, int result ) TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 ); } +#endif /* !MBEDTLS_X509_REMOVE_INFO */ exit: mbedtls_x509_crt_free( &crt );