Move accessor definition

Move the definition of the accessor so that it is not defined
within the MBEDTLS_X509_CRT_WRITE_C guards. Thus remove the
dependency from the test and test cases.

Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
Thomas Daubney 2022-06-06 15:42:32 +01:00
parent 3d3cfc5553
commit a5f39e0ec2
3 changed files with 18 additions and 20 deletions

View file

@ -955,6 +955,23 @@ void mbedtls_x509_crt_restart_free( mbedtls_x509_crt_restart_ctx *ctx );
#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
#endif /* MBEDTLS_X509_CRT_PARSE_C */
/**
* \brief Query certificate for given extension type
*
* \param[in] ctx Certificate context to be queried, must not be \c NULL
* \param ext_type Extension type being queried for, must be a valid
* extension type. Must be one of the MBEDTLS_X509_EXT_XXX
* values
*
* \return 0 if the given extension type is not present,
* non-zero otherwise
*/
static inline int mbedtls_x509_crt_has_ext_type( const mbedtls_x509_crt *ctx,
int ext_type )
{
return ctx->MBEDTLS_PRIVATE(ext_types) & ext_type;
}
/** \} name Structures and functions for parsing and writing X.509 certificates */
#if defined(MBEDTLS_X509_CRT_WRITE_C)
@ -1137,23 +1154,6 @@ int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx,
int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx,
unsigned char ns_cert_type );
/**
* \brief Query certificate for given extension type
*
* \param[in] ctx Certificate context to be queried, must not be \c NULL
* \param ext_type Extension type being queried for, must be a valid
* extension type. Must be one of the MBEDTLS_X509_EXT_XXX
* values
*
* \return 0 if the given extension type is not present,
* non-zero otherwise
*/
static inline int mbedtls_x509_crt_has_ext_type( const mbedtls_x509_crt *ctx,
int ext_type )
{
return ctx->MBEDTLS_PRIVATE(ext_types) & ext_type;
}
/**
* \brief Free the contents of a CRT write context
*

View file

@ -2793,9 +2793,7 @@ depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_S
x509_verify_restart:"data_files/server10_int3-bs.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:500:25:100
X509 ext types accessor: ext type present
depends_on:MBEDTLS_X509_CRT_WRITE_C
x509_accessor_ext_types:MBEDTLS_X509_EXT_KEY_USAGE:MBEDTLS_X509_EXT_KEY_USAGE
X509 ext types accessor: ext type not present
depends_on:MBEDTLS_X509_CRT_WRITE_C
x509_accessor_ext_types:MBEDTLS_X509_EXT_KEY_USAGE:MBEDTLS_X509_EXT_SUBJECT_ALT_NAME

View file

@ -400,7 +400,7 @@ int parse_crt_ext_cb( void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf
* END_DEPENDENCIES
*/
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_WRITE_C */
/* BEGIN_CASE */
void x509_accessor_ext_types( int ext_type, int has_ext_type )
{
mbedtls_x509_crt crt;