mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 20:01:03 +00:00
Adapt test_suite_x509parse to new CRT structure
This commit is contained in:
parent
d8eab343d2
commit
c69c4465b6
|
@ -469,15 +469,19 @@ void mbedtls_x509_dn_gets( char * crt_file, char * entity, char * result_str )
|
|||
mbedtls_x509_crt crt;
|
||||
char buf[2000];
|
||||
int res = 0;
|
||||
mbedtls_x509_name *subject = NULL, *issuer = NULL;
|
||||
|
||||
mbedtls_x509_crt_init( &crt );
|
||||
memset( buf, 0, 2000 );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
||||
TEST_ASSERT( mbedtls_x509_crt_get_subject( &crt, &subject ) == 0 );
|
||||
TEST_ASSERT( mbedtls_x509_crt_get_issuer( &crt, &issuer ) == 0 );
|
||||
|
||||
if( strcmp( entity, "subject" ) == 0 )
|
||||
res = mbedtls_x509_dn_gets( buf, 2000, &crt.subject );
|
||||
res = mbedtls_x509_dn_gets( buf, 2000, subject );
|
||||
else if( strcmp( entity, "issuer" ) == 0 )
|
||||
res = mbedtls_x509_dn_gets( buf, 2000, &crt.issuer );
|
||||
res = mbedtls_x509_dn_gets( buf, 2000, issuer );
|
||||
else
|
||||
TEST_ASSERT( "Unknown entity" == 0 );
|
||||
|
||||
|
@ -487,6 +491,8 @@ void mbedtls_x509_dn_gets( char * crt_file, char * entity, char * result_str )
|
|||
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_x509_name_free( issuer );
|
||||
mbedtls_x509_name_free( subject );
|
||||
mbedtls_x509_crt_free( &crt );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -495,15 +501,17 @@ exit:
|
|||
void mbedtls_x509_time_is_past( char * crt_file, char * entity, int result )
|
||||
{
|
||||
mbedtls_x509_crt crt;
|
||||
mbedtls_x509_crt_frame frame;
|
||||
|
||||
mbedtls_x509_crt_init( &crt );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
||||
TEST_ASSERT( mbedtls_x509_crt_get_frame( &crt, &frame ) == 0 );
|
||||
|
||||
if( strcmp( entity, "valid_from" ) == 0 )
|
||||
TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_from ) == result );
|
||||
TEST_ASSERT( mbedtls_x509_time_is_past( &frame.valid_from ) == result );
|
||||
else if( strcmp( entity, "valid_to" ) == 0 )
|
||||
TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_to ) == result );
|
||||
TEST_ASSERT( mbedtls_x509_time_is_past( &frame.valid_to ) == result );
|
||||
else
|
||||
TEST_ASSERT( "Unknown entity" == 0 );
|
||||
|
||||
|
@ -516,15 +524,17 @@ exit:
|
|||
void mbedtls_x509_time_is_future( char * crt_file, char * entity, int result )
|
||||
{
|
||||
mbedtls_x509_crt crt;
|
||||
mbedtls_x509_crt_frame frame;
|
||||
|
||||
mbedtls_x509_crt_init( &crt );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
||||
TEST_ASSERT( mbedtls_x509_crt_get_frame( &crt, &frame ) == 0 );
|
||||
|
||||
if( strcmp( entity, "valid_from" ) == 0 )
|
||||
TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_from ) == result );
|
||||
TEST_ASSERT( mbedtls_x509_time_is_future( &frame.valid_from ) == result );
|
||||
else if( strcmp( entity, "valid_to" ) == 0 )
|
||||
TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_to ) == result );
|
||||
TEST_ASSERT( mbedtls_x509_time_is_future( &frame.valid_to ) == result );
|
||||
else
|
||||
TEST_ASSERT( "Unknown entity" == 0 );
|
||||
|
||||
|
|
Loading…
Reference in a new issue