mbedtls/tests/suites/test_suite_oid.function
Ron Eldor 685a398a6b Minor fixes in get certificate policies oid test
1. Remove irrelevant  dependency on `MBEDTLS_ASN1_WRITE_C`.
2. Remove whitespace between `*` and parameter.
2019-04-16 13:26:54 +03:00

80 lines
1.7 KiB
Text

/* BEGIN_HEADER */
#include "mbedtls/oid.h"
#include "mbedtls/asn1.h"
#include "mbedtls/asn1write.h"
#include "string.h"
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:MBEDTLS_OID_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
void oid_get_certificate_policies( data_t *oid, char *result_str )
{
mbedtls_asn1_buf asn1_buf = { 0, 0, NULL };
int ret;
const char *desc;
asn1_buf.tag = MBEDTLS_ASN1_OID;
asn1_buf.p = oid->x;
asn1_buf.len = oid->len;
ret = mbedtls_oid_get_certificate_policies( &asn1_buf, &desc );
if( strlen( result_str ) == 0 )
{
TEST_ASSERT( ret == MBEDTLS_ERR_OID_NOT_FOUND );
}
else
{
TEST_ASSERT( strcmp( ( char* )desc, result_str ) == 0 );
}
}
/* END_CASE */
/* BEGIN_CASE */
void oid_get_extended_key_usage( data_t *oid, char *result_str )
{
mbedtls_asn1_buf asn1_buf = { 0, 0, NULL };
int ret;
const char *desc;
asn1_buf.tag = MBEDTLS_ASN1_OID;
asn1_buf.p = oid->x;
asn1_buf.len = oid->len;
ret = mbedtls_oid_get_extended_key_usage( &asn1_buf, &desc );
if( strlen( result_str ) == 0 )
{
TEST_ASSERT( ret == MBEDTLS_ERR_OID_NOT_FOUND );
}
else
{
TEST_ASSERT( strcmp( ( char * )desc, result_str ) == 0 );
}
}
/* END_CASE */
/* BEGIN_CASE */
void oid_get_x509_extension( data_t *oid, int exp_type )
{
mbedtls_asn1_buf ext_oid = { 0, 0, NULL };
int ret;
int ext_type;
ext_oid.tag = MBEDTLS_ASN1_OID;
ext_oid.p = oid->x;
ext_oid.len = oid->len;
ret = mbedtls_oid_get_x509_ext_type( &ext_oid, &ext_type );
if( exp_type == 0 )
{
TEST_ASSERT( ret == MBEDTLS_ERR_OID_NOT_FOUND );
}
else
{
TEST_ASSERT( ext_type == exp_type );
}
}
/* END_CASE */