Add "profile" arg to X.509 test function

Unused yet, tests using it will be added in the next commit
This commit is contained in:
Manuel Pégourié-Gonnard
2017-05-22 12:04:25 +02:00
parent 26b9f7d33b
commit e54931f489
2 changed files with 24 additions and 15 deletions

View File

@@ -546,14 +546,15 @@ exit:
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
void mbedtls_x509_crt_verify_chain( char *chain_paths, char *trusted_ca, int flags_result )
void mbedtls_x509_crt_verify_chain( char *chain_paths, char *trusted_ca,
int flags_result, int result,
char *profile_name )
{
char* act;
uint32_t flags;
int result, res;
int res;
mbedtls_x509_crt trusted, chain;
result= flags_result?MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:0;
const mbedtls_x509_crt_profile *profile = NULL;
mbedtls_x509_crt_init( &chain );
mbedtls_x509_crt_init( &trusted );
@@ -562,7 +563,15 @@ void mbedtls_x509_crt_verify_chain( char *chain_paths, char *trusted_ca, int fl
TEST_ASSERT( mbedtls_x509_crt_parse_file( &chain, act ) == 0 );
TEST_ASSERT( mbedtls_x509_crt_parse_file( &trusted, trusted_ca ) == 0 );
res = mbedtls_x509_crt_verify( &chain, &trusted, NULL, NULL, &flags, NULL, NULL );
if( strcmp(profile_name, "") == 0 )
profile = &mbedtls_x509_crt_profile_default;
else if( strcmp(profile_name, "next") == 0 )
profile = &mbedtls_x509_crt_profile_next;
else if( strcmp(profile_name, "suiteb") == 0 )
profile = &mbedtls_x509_crt_profile_suiteb;
res = mbedtls_x509_crt_verify_with_profile( &chain, &trusted, NULL, profile,
NULL, &flags, NULL, NULL );
TEST_ASSERT( res == ( result ) );
TEST_ASSERT( flags == (uint32_t)( flags_result ) );