mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-15 15:39:58 +00:00
Merge duplicated checks between child() and top()
This commit is contained in:
parent
58dcd2d9b2
commit
66fac75f8b
@ -2027,18 +2027,6 @@ static int x509_crt_verify_top(
|
|||||||
|
|
||||||
(void) self_cnt;
|
(void) self_cnt;
|
||||||
|
|
||||||
if( mbedtls_x509_time_is_past( &child->valid_to ) )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_EXPIRED;
|
|
||||||
|
|
||||||
if( mbedtls_x509_time_is_future( &child->valid_from ) )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_FUTURE;
|
|
||||||
|
|
||||||
if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_BAD_MD;
|
|
||||||
|
|
||||||
if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
|
||||||
|
|
||||||
/* Special case #1: no root, stop here */
|
/* Special case #1: no root, stop here */
|
||||||
if( trust_ca == NULL )
|
if( trust_ca == NULL )
|
||||||
{
|
{
|
||||||
@ -2114,6 +2102,18 @@ static int x509_crt_verify_child(
|
|||||||
mbedtls_x509_crt *parent;
|
mbedtls_x509_crt *parent;
|
||||||
uint32_t parent_flags = 0;
|
uint32_t parent_flags = 0;
|
||||||
|
|
||||||
|
if( mbedtls_x509_time_is_past( &child->valid_to ) )
|
||||||
|
*flags |= MBEDTLS_X509_BADCERT_EXPIRED;
|
||||||
|
|
||||||
|
if( mbedtls_x509_time_is_future( &child->valid_from ) )
|
||||||
|
*flags |= MBEDTLS_X509_BADCERT_FUTURE;
|
||||||
|
|
||||||
|
if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 )
|
||||||
|
*flags |= MBEDTLS_X509_BADCERT_BAD_MD;
|
||||||
|
|
||||||
|
if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 )
|
||||||
|
*flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
||||||
|
|
||||||
/* Look for a parent in trusted CAs */
|
/* Look for a parent in trusted CAs */
|
||||||
parent = x509_crt_find_parent( child, trust_ca, 1, path_cnt, self_cnt );
|
parent = x509_crt_find_parent( child, trust_ca, 1, path_cnt, self_cnt );
|
||||||
|
|
||||||
@ -2146,18 +2146,6 @@ static int x509_crt_verify_child(
|
|||||||
return( MBEDTLS_ERR_X509_FATAL_ERROR );
|
return( MBEDTLS_ERR_X509_FATAL_ERROR );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mbedtls_x509_time_is_past( &child->valid_to ) )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_EXPIRED;
|
|
||||||
|
|
||||||
if( mbedtls_x509_time_is_future( &child->valid_from ) )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_FUTURE;
|
|
||||||
|
|
||||||
if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_BAD_MD;
|
|
||||||
|
|
||||||
if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 )
|
|
||||||
*flags |= MBEDTLS_X509_BADCERT_BAD_PK;
|
|
||||||
|
|
||||||
if( x509_crt_check_signature( child, parent ) != 0 )
|
if( x509_crt_check_signature( child, parent ) != 0 )
|
||||||
*flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED;
|
*flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user