Rename boolean functions to be clearer

parent 3eb50fa5
......@@ -49,7 +49,7 @@ extern "C" {
*
* \return 1 if CPU has support for the feature, 0 otherwise
*/
int mbedtls_aesni_supports( unsigned int what );
int mbedtls_aesni_has_support( unsigned int what );
/**
* \brief AES-NI AES-ECB block en(de)cryption
......
......@@ -1778,7 +1778,7 @@
#define aesni_gcm_mult mbedtls_aesni_gcm_mult
#define aesni_inverse_key mbedtls_aesni_inverse_key
#define aesni_setkey_enc mbedtls_aesni_setkey_enc
#define aesni_supports mbedtls_aesni_supports
#define aesni_supports mbedtls_aesni_has_support
#define alarmed mbedtls_timing_alarmed
#define arc4_context mbedtls_arc4_context
#define arc4_crypt mbedtls_arc4_crypt
......@@ -2200,7 +2200,7 @@
#define oid_get_sig_alg_desc mbedtls_oid_get_sig_alg_desc
#define oid_get_x509_ext_type mbedtls_oid_get_x509_ext_type
#define operation_t mbedtls_operation_t
#define padlock_supports mbedtls_padlock_supports
#define padlock_supports mbedtls_padlock_has_support
#define padlock_xcryptcbc mbedtls_padlock_xcryptcbc
#define padlock_xcryptecb mbedtls_padlock_xcryptecb
#define pbkdf2_hmac mbedtls_pbkdf2_hmac
......@@ -2575,7 +2575,7 @@
#define x509_crt_parse_der mbedtls_x509_crt_parse_der
#define x509_crt_parse_file mbedtls_x509_crt_parse_file
#define x509_crt_parse_path mbedtls_x509_crt_parse_path
#define x509_crt_revoked mbedtls_x509_crt_revoked
#define x509_crt_revoked mbedtls_x509_crt_is_revoked
#define x509_crt_verify mbedtls_x509_crt_verify
#define x509_csr mbedtls_x509_csr
#define x509_csr_free mbedtls_x509_csr_free
......@@ -2605,8 +2605,8 @@
#define x509_sig_alg_gets mbedtls_x509_sig_alg_gets
#define x509_string_to_names mbedtls_x509_string_to_names
#define x509_time mbedtls_x509_time
#define x509_time_expired mbedtls_x509_time_expired
#define x509_time_future mbedtls_x509_time_future
#define x509_time_expired mbedtls_x509_time_is_past
#define x509_time_future mbedtls_x509_time_is_future
#define x509_write_extensions mbedtls_x509_write_extensions
#define x509_write_names mbedtls_x509_write_names
#define x509_write_sig mbedtls_x509_write_sig
......
......@@ -55,7 +55,7 @@ extern "C" {
*
* \return 1 if CPU has support for the feature, 0 otherwise
*/
int mbedtls_padlock_supports( int feature );
int mbedtls_padlock_has_support( int feature );
/**
* \brief PadLock AES-ECB block en(de)cryption
......
......@@ -238,7 +238,7 @@ int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *se
* \return 0 if the mbedtls_x509_time is still valid,
* 1 otherwise.
*/
int mbedtls_x509_time_expired( const mbedtls_x509_time *time );
int mbedtls_x509_time_is_past( const mbedtls_x509_time *time );
/**
* \brief Check a given mbedtls_x509_time against the system time and check
......@@ -249,7 +249,7 @@ int mbedtls_x509_time_expired( const mbedtls_x509_time *time );
* \return 0 if the mbedtls_x509_time is already valid,
* 1 otherwise.
*/
int mbedtls_x509_time_future( const mbedtls_x509_time *time );
int mbedtls_x509_time_is_future( const mbedtls_x509_time *time );
/**
* \brief Checkup routine
......
......@@ -303,7 +303,7 @@ int mbedtls_x509_crt_check_extended_key_usage( const mbedtls_x509_crt *crt,
* \return 1 if the certificate is revoked, 0 otherwise
*
*/
int mbedtls_x509_crt_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl );
int mbedtls_x509_crt_is_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl );
#endif /* MBEDTLS_X509_CRL_PARSE_C */
/**
......
......@@ -507,7 +507,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16)
if( aes_padlock_ace == -1 )
aes_padlock_ace = mbedtls_padlock_supports( MBEDTLS_PADLOCK_ACE );
aes_padlock_ace = mbedtls_padlock_has_support( MBEDTLS_PADLOCK_ACE );
if( aes_padlock_ace )
ctx->rk = RK = MBEDTLS_PADLOCK_ALIGN16( ctx->buf );
......@@ -516,7 +516,7 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
ctx->rk = RK = ctx->buf;
#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
if( mbedtls_aesni_supports( MBEDTLS_AESNI_AES ) )
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) )
return( mbedtls_aesni_setkey_enc( (unsigned char *) ctx->rk, key, keysize ) );
#endif
......@@ -608,7 +608,7 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
#if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16)
if( aes_padlock_ace == -1 )
aes_padlock_ace = mbedtls_padlock_supports( MBEDTLS_PADLOCK_ACE );
aes_padlock_ace = mbedtls_padlock_has_support( MBEDTLS_PADLOCK_ACE );
if( aes_padlock_ace )
ctx->rk = RK = MBEDTLS_PADLOCK_ALIGN16( ctx->buf );
......@@ -623,7 +623,7 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
ctx->nr = cty.nr;
#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
if( mbedtls_aesni_supports( MBEDTLS_AESNI_AES ) )
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) )
{
mbedtls_aesni_inverse_key( (unsigned char *) ctx->rk,
(const unsigned char *) cty.rk, ctx->nr );
......@@ -830,7 +830,7 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
unsigned char output[16] )
{
#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
if( mbedtls_aesni_supports( MBEDTLS_AESNI_AES ) )
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) )
return( mbedtls_aesni_crypt_ecb( ctx, mode, input, output ) );
#endif
......
......@@ -46,7 +46,7 @@
/*
* AES-NI support detection routine
*/
int mbedtls_aesni_supports( unsigned int what )
int mbedtls_aesni_has_support( unsigned int what )
{
static int done = 0;
static unsigned int c = 0;
......
......@@ -126,7 +126,7 @@ static int gcm_gen_table( mbedtls_gcm_context *ctx )
#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
/* With CLMUL support, we need only h, not the rest of the table */
if( mbedtls_aesni_supports( MBEDTLS_AESNI_CLMUL ) )
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) )
return( 0 );
#endif
......@@ -216,7 +216,7 @@ static void gcm_mult( mbedtls_gcm_context *ctx, const unsigned char x[16],
uint64_t zh, zl;
#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
if( mbedtls_aesni_supports( MBEDTLS_AESNI_CLMUL ) ) {
if( mbedtls_aesni_has_support( MBEDTLS_AESNI_CLMUL ) ) {
unsigned char h[16];
PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 );
......
......@@ -47,7 +47,7 @@
/*
* PadLock detection routine
*/
int mbedtls_padlock_supports( int feature )
int mbedtls_padlock_has_support( int feature )
{
static int flags = -1;
int ebx = 0, edx = 0;
......
......@@ -962,7 +962,7 @@ static int x509_check_time( const mbedtls_x509_time *before, const mbedtls_x509_
return( 0 );
}
int mbedtls_x509_time_expired( const mbedtls_x509_time *to )
int mbedtls_x509_time_is_past( const mbedtls_x509_time *to )
{
mbedtls_x509_time now;
......@@ -972,7 +972,7 @@ int mbedtls_x509_time_expired( const mbedtls_x509_time *to )
return( x509_check_time( &now, to ) );
}
int mbedtls_x509_time_future( const mbedtls_x509_time *from )
int mbedtls_x509_time_is_future( const mbedtls_x509_time *from )
{
mbedtls_x509_time now;
......@@ -984,13 +984,13 @@ int mbedtls_x509_time_future( const mbedtls_x509_time *from )
#else /* MBEDTLS_HAVE_TIME */
int mbedtls_x509_time_expired( const mbedtls_x509_time *to )
int mbedtls_x509_time_is_past( const mbedtls_x509_time *to )
{
((void) to);
return( 0 );
}
int mbedtls_x509_time_future( const mbedtls_x509_time *from )
int mbedtls_x509_time_is_future( const mbedtls_x509_time *from )
{
((void) from);
return( 0 );
......
......@@ -1479,7 +1479,7 @@ int mbedtls_x509_crt_check_extended_key_usage( const mbedtls_x509_crt *crt,
/*
* Return 1 if the certificate is revoked, or 0 otherwise.
*/
int mbedtls_x509_crt_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl )
int mbedtls_x509_crt_is_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl )
{
const mbedtls_x509_crl_entry *cur = &crl->entry;
......@@ -1488,7 +1488,7 @@ int mbedtls_x509_crt_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_cr
if( crt->serial.len == cur->serial.len &&
memcmp( crt->serial.p, cur->serial.p, crt->serial.len ) == 0 )
{
if( mbedtls_x509_time_expired( &cur->revocation_date ) )
if( mbedtls_x509_time_is_past( &cur->revocation_date ) )
return( 1 );
}
......@@ -1565,16 +1565,16 @@ static int x509_crt_verifycrl( mbedtls_x509_crt *crt, mbedtls_x509_crt *ca,
/*
* Check for validity of CRL (Do not drop out)
*/
if( mbedtls_x509_time_expired( &crl_list->next_update ) )
if( mbedtls_x509_time_is_past( &crl_list->next_update ) )
flags |= MBEDTLS_X509_BADCRL_EXPIRED;
if( mbedtls_x509_time_future( &crl_list->this_update ) )
if( mbedtls_x509_time_is_future( &crl_list->this_update ) )
flags |= MBEDTLS_X509_BADCRL_FUTURE;
/*
* Check if certificate is revoked
*/
if( mbedtls_x509_crt_revoked( crt, crl_list ) )
if( mbedtls_x509_crt_is_revoked( crt, crl_list ) )
{
flags |= MBEDTLS_X509_BADCERT_REVOKED;
break;
......@@ -1774,10 +1774,10 @@ static int x509_crt_verify_top(
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
const mbedtls_md_info_t *md_info;
if( mbedtls_x509_time_expired( &child->valid_to ) )
if( mbedtls_x509_time_is_past( &child->valid_to ) )
*flags |= MBEDTLS_X509_BADCERT_EXPIRED;
if( mbedtls_x509_time_future( &child->valid_from ) )
if( mbedtls_x509_time_is_future( &child->valid_from ) )
*flags |= MBEDTLS_X509_BADCERT_FUTURE;
/*
......@@ -1851,10 +1851,10 @@ static int x509_crt_verify_top(
((void) ca_crl);
#endif
if( mbedtls_x509_time_expired( &trust_ca->valid_to ) )
if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) )
ca_flags |= MBEDTLS_X509_BADCERT_EXPIRED;
if( mbedtls_x509_time_future( &trust_ca->valid_from ) )
if( mbedtls_x509_time_is_future( &trust_ca->valid_from ) )
ca_flags |= MBEDTLS_X509_BADCERT_FUTURE;
if( NULL != f_vrfy )
......@@ -1898,10 +1898,10 @@ static int x509_crt_verify_child(
return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED );
}
if( mbedtls_x509_time_expired( &child->valid_to ) )
if( mbedtls_x509_time_is_past( &child->valid_to ) )
*flags |= MBEDTLS_X509_BADCERT_EXPIRED;
if( mbedtls_x509_time_future( &child->valid_from ) )
if( mbedtls_x509_time_is_future( &child->valid_from ) )
*flags |= MBEDTLS_X509_BADCERT_FUTURE;
md_info = mbedtls_md_info_from_type( child->sig_md );
......
......@@ -1310,7 +1310,7 @@ aesni_crypt_ecb mbedtls_aesni_crypt_ecb
aesni_gcm_mult mbedtls_aesni_gcm_mult
aesni_inverse_key mbedtls_aesni_inverse_key
aesni_setkey_enc mbedtls_aesni_setkey_enc
aesni_supports mbedtls_aesni_supports
aesni_supports mbedtls_aesni_has_support
alarmed mbedtls_timing_alarmed
arc4_context mbedtls_arc4_context
arc4_crypt mbedtls_arc4_crypt
......@@ -1732,7 +1732,7 @@ oid_get_sig_alg mbedtls_oid_get_sig_alg
oid_get_sig_alg_desc mbedtls_oid_get_sig_alg_desc
oid_get_x509_ext_type mbedtls_oid_get_x509_ext_type
operation_t mbedtls_operation_t
padlock_supports mbedtls_padlock_supports
padlock_supports mbedtls_padlock_has_support
padlock_xcryptcbc mbedtls_padlock_xcryptcbc
padlock_xcryptecb mbedtls_padlock_xcryptecb
pem_context mbedtls_pem_context
......@@ -2105,7 +2105,7 @@ x509_crt_parse mbedtls_x509_crt_parse
x509_crt_parse_der mbedtls_x509_crt_parse_der
x509_crt_parse_file mbedtls_x509_crt_parse_file
x509_crt_parse_path mbedtls_x509_crt_parse_path
x509_crt_revoked mbedtls_x509_crt_revoked
x509_crt_revoked mbedtls_x509_crt_is_revoked
x509_crt_verify mbedtls_x509_crt_verify
x509_crt_verify_info mbedtls_x509_crt_verify_info
x509_csr mbedtls_x509_csr
......@@ -2136,8 +2136,8 @@ x509_set_extension mbedtls_x509_set_extension
x509_sig_alg_gets mbedtls_x509_sig_alg_gets
x509_string_to_names mbedtls_x509_string_to_names
x509_time mbedtls_x509_time
x509_time_expired mbedtls_x509_time_expired
x509_time_future mbedtls_x509_time_future
x509_time_expired mbedtls_x509_time_is_past
x509_time_future mbedtls_x509_time_is_future
x509_write_extensions mbedtls_x509_write_extensions
x509_write_names mbedtls_x509_write_names
x509_write_sig mbedtls_x509_write_sig
......
......@@ -322,51 +322,51 @@ mbedtls_x509_dn_gets:"data_files/server2.crt":"issuer":"C=NL, O=PolarSSL, CN=Pol
X509 Time Expired #1
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_HAVE_TIME
mbedtls_x509_time_expired:"data_files/server1.crt":"valid_from":1
mbedtls_x509_time_is_past:"data_files/server1.crt":"valid_from":1
X509 Time Expired #2
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_HAVE_TIME
mbedtls_x509_time_expired:"data_files/server1.crt":"valid_to":0
mbedtls_x509_time_is_past:"data_files/server1.crt":"valid_to":0
X509 Time Expired #3
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_HAVE_TIME
mbedtls_x509_time_expired:"data_files/server2.crt":"valid_from":1
mbedtls_x509_time_is_past:"data_files/server2.crt":"valid_from":1
X509 Time Expired #4
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_HAVE_TIME
mbedtls_x509_time_expired:"data_files/server2.crt":"valid_to":0
mbedtls_x509_time_is_past:"data_files/server2.crt":"valid_to":0
X509 Time Expired #5
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_HAVE_TIME
mbedtls_x509_time_expired:"data_files/test-ca.crt":"valid_from":1
mbedtls_x509_time_is_past:"data_files/test-ca.crt":"valid_from":1
X509 Time Expired #6
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_HAVE_TIME
mbedtls_x509_time_expired:"data_files/test-ca.crt":"valid_to":0
mbedtls_x509_time_is_past:"data_files/test-ca.crt":"valid_to":0
X509 Time Future #1
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_HAVE_TIME
mbedtls_x509_time_future:"data_files/server5.crt":"valid_from":0
mbedtls_x509_time_is_future:"data_files/server5.crt":"valid_from":0
X509 Time Future #2
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_HAVE_TIME
mbedtls_x509_time_future:"data_files/server5.crt":"valid_to":1
mbedtls_x509_time_is_future:"data_files/server5.crt":"valid_to":1
X509 Time Future #3
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_HAVE_TIME
mbedtls_x509_time_future:"data_files/server5-future.crt":"valid_from":1
mbedtls_x509_time_is_future:"data_files/server5-future.crt":"valid_from":1
X509 Time Future #4
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_HAVE_TIME
mbedtls_x509_time_future:"data_files/server5-future.crt":"valid_to":1
mbedtls_x509_time_is_future:"data_files/server5-future.crt":"valid_to":1
X509 Time Future #5
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_HAVE_TIME
mbedtls_x509_time_future:"data_files/test-ca2.crt":"valid_from":0
mbedtls_x509_time_is_future:"data_files/test-ca2.crt":"valid_from":0
X509 Time Future #6
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_HAVE_TIME
mbedtls_x509_time_future:"data_files/test-ca2.crt":"valid_to":1
mbedtls_x509_time_is_future:"data_files/test-ca2.crt":"valid_to":1
X509 Certificate verification #1 (Revoked Cert, Expired CRL, no CN)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
......
......@@ -192,7 +192,7 @@ exit:
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
void mbedtls_x509_time_expired( char *crt_file, char *entity, int result )
void mbedtls_x509_time_is_past( char *crt_file, char *entity, int result )
{
mbedtls_x509_crt crt;
......@@ -201,9 +201,9 @@ void mbedtls_x509_time_expired( char *crt_file, char *entity, int result )
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
if( strcmp( entity, "valid_from" ) == 0 )
TEST_ASSERT( mbedtls_x509_time_expired( &crt.valid_from ) == result );
TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_from ) == result );
else if( strcmp( entity, "valid_to" ) == 0 )
TEST_ASSERT( mbedtls_x509_time_expired( &crt.valid_to ) == result );
TEST_ASSERT( mbedtls_x509_time_is_past( &crt.valid_to ) == result );
else
TEST_ASSERT( "Unknown entity" == 0 );
......@@ -213,7 +213,7 @@ exit:
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
void mbedtls_x509_time_future( char *crt_file, char *entity, int result )
void mbedtls_x509_time_is_future( char *crt_file, char *entity, int result )
{
mbedtls_x509_crt crt;
......@@ -222,9 +222,9 @@ void mbedtls_x509_time_future( char *crt_file, char *entity, int result )
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
if( strcmp( entity, "valid_from" ) == 0 )
TEST_ASSERT( mbedtls_x509_time_future( &crt.valid_from ) == result );
TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_from ) == result );
else if( strcmp( entity, "valid_to" ) == 0 )
TEST_ASSERT( mbedtls_x509_time_future( &crt.valid_to ) == result );
TEST_ASSERT( mbedtls_x509_time_is_future( &crt.valid_to ) == result );
else
TEST_ASSERT( "Unknown entity" == 0 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment