x509: slightly more compact style in verify_name

This commit is contained in:
Manuel Pégourié-Gonnard 2016-01-28 17:56:33 +01:00
parent 80c8786bfc
commit e9d8c09791

View File

@ -2239,29 +2239,25 @@ static int x509_crt_verify_name( const mbedtls_x509_crt *crt,
if( crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME ) if( crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME )
{ {
const mbedtls_x509_sequence *cur = &crt->subject_alt_names; const mbedtls_x509_sequence *cur;
while( cur != NULL ) for( cur = &crt->subject_alt_names; cur != NULL; cur = cur->next )
{ {
if( x509_check_dns_name( exp_name, exp_len, &cur->buf ) == 0 ) if( x509_check_dns_name( exp_name, exp_len, &cur->buf ) == 0 )
return( 0 ); return( 0 );
cur = cur->next;
} }
} }
else else
{ {
const mbedtls_x509_name *name = &crt->subject; const mbedtls_x509_name *cur;
while( name != NULL ) for( cur = &crt->subject; cur != NULL; cur = cur->next )
{ {
if( MBEDTLS_OID_CMP( MBEDTLS_OID_AT_CN, &name->oid ) == 0 ) if( MBEDTLS_OID_CMP( MBEDTLS_OID_AT_CN, &cur->oid ) == 0 &&
x509_check_dns_name( exp_name, exp_len, &cur->val ) == 0 )
{ {
if( x509_check_dns_name( exp_name, exp_len, &name->val ) == 0 ) return( 0 );
return( 0 );
} }
name = name->next;
} }
} }