mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 12:45:45 +01:00
Test for ca list callback
This commit is contained in:
parent
8bf74f37dc
commit
03cd120ce4
@ -68,6 +68,25 @@ int verify_all( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||||
|
int verify_cb( void *data, mbedtls_x509_crt *child, mbedtls_x509_crt **candidates)
|
||||||
|
{
|
||||||
|
mbedtls_x509_crt *ca = (mbedtls_x509_crt *) data;
|
||||||
|
|
||||||
|
mbedtls_x509_crt *first = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) );
|
||||||
|
TEST_ASSERT( first != NULL);
|
||||||
|
TEST_ASSERT( mbedtls_x509_crt_init( first ) == 0 );
|
||||||
|
TEST_ASSERT( mbedtls_x509_crt_parse_der( first, ca->raw.p, ca->raw.len ) == 0);
|
||||||
|
while( ca->next != NULL )
|
||||||
|
{
|
||||||
|
ca = ca->next;
|
||||||
|
TEST_ASSERT( mbedtls_x509_crt_parse_der( first, ca->raw.p, ca->raw.len ) == 0);
|
||||||
|
}
|
||||||
|
*candidates = first;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
|
||||||
|
|
||||||
int verify_fatal( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags )
|
int verify_fatal( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags )
|
||||||
{
|
{
|
||||||
int *levels = (int *) data;
|
int *levels = (int *) data;
|
||||||
@ -374,6 +393,14 @@ void x509_verify( char *crt_file, char *ca_file, char *crl_file,
|
|||||||
TEST_ASSERT( res == ( result ) );
|
TEST_ASSERT( res == ( result ) );
|
||||||
TEST_ASSERT( flags == (uint32_t)( flags_result ) );
|
TEST_ASSERT( flags == (uint32_t)( flags_result ) );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||||
|
flags = 0;
|
||||||
|
|
||||||
|
res = mbedtls_x509_crt_verify_with_cb( &crt, verify_cb, &ca, profile, cn_name, &flags, f_vrfy, NULL );
|
||||||
|
|
||||||
|
TEST_ASSERT( res == ( result ) );
|
||||||
|
TEST_ASSERT( flags == (uint32_t)( flags_result ) );
|
||||||
|
#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
|
||||||
exit:
|
exit:
|
||||||
mbedtls_x509_crt_free( &crt );
|
mbedtls_x509_crt_free( &crt );
|
||||||
mbedtls_x509_crt_free( &ca );
|
mbedtls_x509_crt_free( &ca );
|
||||||
|
Loading…
Reference in New Issue
Block a user