mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 19:41:09 +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;
|
mbedtls_x509_crt crt;
|
||||||
char buf[2000];
|
char buf[2000];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
mbedtls_x509_name *subject = NULL, *issuer = NULL;
|
||||||
|
|
||||||
mbedtls_x509_crt_init( &crt );
|
mbedtls_x509_crt_init( &crt );
|
||||||
memset( buf, 0, 2000 );
|
memset( buf, 0, 2000 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
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 )
|
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 )
|
else if( strcmp( entity, "issuer" ) == 0 )
|
||||||
res = mbedtls_x509_dn_gets( buf, 2000, &crt.issuer );
|
res = mbedtls_x509_dn_gets( buf, 2000, issuer );
|
||||||
else
|
else
|
||||||
TEST_ASSERT( "Unknown entity" == 0 );
|
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 );
|
TEST_ASSERT( strcmp( buf, result_str ) == 0 );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
mbedtls_x509_name_free( issuer );
|
||||||
|
mbedtls_x509_name_free( subject );
|
||||||
mbedtls_x509_crt_free( &crt );
|
mbedtls_x509_crt_free( &crt );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
@ -494,16 +500,18 @@ exit:
|
||||||
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
|
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
|
||||||
void mbedtls_x509_time_is_past( char * crt_file, char * entity, int result )
|
void mbedtls_x509_time_is_past( char * crt_file, char * entity, int result )
|
||||||
{
|
{
|
||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
mbedtls_x509_crt_frame frame;
|
||||||
|
|
||||||
mbedtls_x509_crt_init( &crt );
|
mbedtls_x509_crt_init( &crt );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
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 )
|
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 )
|
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
|
else
|
||||||
TEST_ASSERT( "Unknown entity" == 0 );
|
TEST_ASSERT( "Unknown entity" == 0 );
|
||||||
|
|
||||||
|
@ -515,16 +523,18 @@ exit:
|
||||||
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
|
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
|
||||||
void mbedtls_x509_time_is_future( char * crt_file, char * entity, int result )
|
void mbedtls_x509_time_is_future( char * crt_file, char * entity, int result )
|
||||||
{
|
{
|
||||||
mbedtls_x509_crt crt;
|
mbedtls_x509_crt crt;
|
||||||
|
mbedtls_x509_crt_frame frame;
|
||||||
|
|
||||||
mbedtls_x509_crt_init( &crt );
|
mbedtls_x509_crt_init( &crt );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
|
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 )
|
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 )
|
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
|
else
|
||||||
TEST_ASSERT( "Unknown entity" == 0 );
|
TEST_ASSERT( "Unknown entity" == 0 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue