Modify existing X.509 test for also test new copyless API
The existing test `x509parse_crt()` for X.509 CRT parsing so far used the generic parsing API `mbedtls_x509_crt_parse()` capable of parsing both PEM encoded and DER encoded certficates, but was actually only used with DER encoded input data. Moreover, as the purpose of the test is the testing of the core DER X.509 parsing functionality, not the PEM vs. DER dispatch (which is now already tested in the various `x509_crt_info()` tests), the call can be replaced with a direct call to `mbedtls_x509_parse_crt_der()`. This commit does that, and further adds to the test an analogous call to the new API `mbedtls_x509_parse_crt_der_nocopy()` to test copyless parsing of X.509 certificates.
This commit is contained in:
parent
462c3e5210
commit
2d8a2c0852
1 changed files with 15 additions and 1 deletions
|
@ -505,8 +505,22 @@ void x509parse_crt( data_t * buf, char * result_str, int result )
|
|||
mbedtls_x509_crt_init( &crt );
|
||||
memset( output, 0, 2000 );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_der( &crt, buf->x, buf->len ) == ( result ) );
|
||||
if( ( result ) == 0 )
|
||||
{
|
||||
res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf->x, buf->len ) == ( result ) );
|
||||
TEST_ASSERT( res != -1 );
|
||||
TEST_ASSERT( res != -2 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) output, result_str ) == 0 );
|
||||
}
|
||||
|
||||
mbedtls_x509_crt_free( &crt );
|
||||
mbedtls_x509_crt_init( &crt );
|
||||
memset( output, 0, 2000 );
|
||||
|
||||
TEST_ASSERT( mbedtls_x509_crt_parse_der_nocopy( &crt, buf->x, buf->len ) == ( result ) );
|
||||
if( ( result ) == 0 )
|
||||
{
|
||||
res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt );
|
||||
|
|
Loading…
Reference in a new issue