Make results of (ext)KeyUsage accessible

This commit is contained in:
Manuel Pégourié-Gonnard 2015-04-17 16:55:53 +02:00
parent 0c6ce2f536
commit 9f98251e72
5 changed files with 44 additions and 7 deletions

View file

@ -2859,7 +2859,8 @@ int ssl_parse_certificate( ssl_context *ssl )
if( ssl_check_cert_usage( ssl->session_negotiate->peer_cert,
ciphersuite_info,
! ssl->endpoint ) != 0 )
! ssl->endpoint,
&ssl->session_negotiate->verify_result ) != 0 )
{
SSL_DEBUG_MSG( 1, ( "bad certificate (usage extensions)" ) );
if( ret == 0 )
@ -5199,8 +5200,10 @@ int ssl_curve_is_acceptable( const ssl_context *ssl, ecp_group_id grp_id )
#if defined(POLARSSL_X509_CRT_PARSE_C)
int ssl_check_cert_usage( const x509_crt *cert,
const ssl_ciphersuite_t *ciphersuite,
int cert_endpoint )
int cert_endpoint,
int *flags )
{
int ret = 0;
#if defined(POLARSSL_X509_CHECK_KEY_USAGE)
int usage = 0;
#endif
@ -5213,6 +5216,7 @@ int ssl_check_cert_usage( const x509_crt *cert,
!defined(POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE)
((void) cert);
((void) cert_endpoint);
((void) flags);
#endif
#if defined(POLARSSL_X509_CHECK_KEY_USAGE)
@ -5252,7 +5256,10 @@ int ssl_check_cert_usage( const x509_crt *cert,
}
if( x509_crt_check_key_usage( cert, usage ) != 0 )
return( -1 );
{
*flags |= BADCERT_KEY_USAGE;
ret = -1;
}
#else
((void) ciphersuite);
#endif /* POLARSSL_X509_CHECK_KEY_USAGE */
@ -5270,10 +5277,13 @@ int ssl_check_cert_usage( const x509_crt *cert,
}
if( x509_crt_check_extended_key_usage( cert, ext_oid, ext_len ) != 0 )
return( -1 );
{
*flags |= BADCERT_EXT_KEY_USAGE;
ret = -1;
}
#endif /* POLARSSL_X509_CHECK_EXTENDED_KEY_USAGE */
return( 0 );
return( ret );
}
#endif /* POLARSSL_X509_CRT_PARSE_C */