Add test for bad name and callback

This ensures that the callback can actually clear that flag, and that it is
seen by the callback at the right level. This flag is not set at the same
place than others, and this difference will get bigger in the upcoming
refactor, so let's ensure we don't break anything here.
This commit is contained in:
Manuel Pégourié-Gonnard 2017-07-05 18:14:38 +02:00
parent 2d825d42bb
commit a656825aef
2 changed files with 31 additions and 20 deletions

View file

@ -316,7 +316,7 @@ exit:
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
void x509_verify_callback( char *crt_file, char *ca_file,
void x509_verify_callback( char *crt_file, char *ca_file, char *name,
int exp_ret, char *exp_vrfy_out )
{
int ret;
@ -332,9 +332,12 @@ void x509_verify_callback( char *crt_file, char *ca_file,
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 );
if( strcmp( name, "NULL" ) == 0 )
name = NULL;
ret = mbedtls_x509_crt_verify_with_profile( &crt, &ca, NULL,
&compat_profile,
NULL, &flags,
name, &flags,
verify_print, &vrfy_ctx );
TEST_ASSERT( ret == exp_ret );