Reverse meaning of OID_CMP

This commit is contained in:
Manuel Pégourié-Gonnard 2015-03-19 16:54:56 +00:00
parent 852a6d3d8f
commit 6e0643762d
5 changed files with 9 additions and 11 deletions

View file

@ -99,12 +99,10 @@
*
* Only works for 'defined' oid_str values (OID_HMAC_SHA1), you cannot use a
* 'unsigned char *oid' here!
*
* Warning: returns true when the OIDs are equal (unlike memcmp)!
*/
#define OID_CMP(oid_str, oid_buf) \
( ( OID_SIZE(oid_str) == (oid_buf)->len ) && \
memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) == 0 )
( ( OID_SIZE(oid_str) != (oid_buf)->len ) || \
memcmp( (oid_str), (oid_buf)->p, (oid_buf)->len) != 0 )
#ifdef __cplusplus
extern "C" {

View file

@ -97,7 +97,7 @@ static int pkcs5_parse_pbkdf2_params( const asn1_buf *params,
if( ( ret = asn1_get_alg_null( &p, end, &prf_alg_oid ) ) != 0 )
return( POLARSSL_ERR_PKCS5_INVALID_FORMAT + ret );
if( !OID_CMP( OID_HMAC_SHA1, &prf_alg_oid ) )
if( OID_CMP( OID_HMAC_SHA1, &prf_alg_oid ) != 0 )
return( POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE );
*md_type = POLARSSL_MD_SHA1;
@ -145,7 +145,7 @@ int pkcs5_pbes2( const asn1_buf *pbe_params, int mode,
// Only PBKDF2 supported at the moment
//
if( !OID_CMP( OID_PKCS5_PBKDF2, &kdf_alg_oid ) )
if( OID_CMP( OID_PKCS5_PBKDF2, &kdf_alg_oid ) != 0 )
return( POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE );
if( ( ret = pkcs5_parse_pbkdf2_params( &kdf_alg_params,

View file

@ -997,7 +997,7 @@ static int pk_parse_key_pkcs8_encrypted_der(
decrypted = 1;
}
else if( OID_CMP( OID_PKCS12_PBE_SHA1_RC4_128, &pbe_alg_oid ) )
else if( OID_CMP( OID_PKCS12_PBE_SHA1_RC4_128, &pbe_alg_oid ) == 0 )
{
if( ( ret = pkcs12_pbe_sha1_rc4_128( &pbe_params,
PKCS12_PBE_DECRYPT,
@ -1018,7 +1018,7 @@ static int pk_parse_key_pkcs8_encrypted_der(
else
#endif /* POLARSSL_PKCS12_C */
#if defined(POLARSSL_PKCS5_C)
if( OID_CMP( OID_PKCS5_PBES2, &pbe_alg_oid ) )
if( OID_CMP( OID_PKCS5_PBES2, &pbe_alg_oid ) == 0 )
{
if( ( ret = pkcs5_pbes2( &pbe_params, PKCS5_DECRYPT, pwd, pwdlen,
p, len, buf ) ) != 0 )

View file

@ -269,7 +269,7 @@ int x509_get_rsassa_pss_params( const x509_buf *params,
return( ret );
/* Only MFG1 is recognised for now */
if( ! OID_CMP( OID_MGF1, &alg_id ) )
if( OID_CMP( OID_MGF1, &alg_id ) != 0 )
return( POLARSSL_ERR_X509_FEATURE_UNAVAILABLE +
POLARSSL_ERR_OID_NOT_FOUND );

View file

@ -1417,7 +1417,7 @@ int x509_crt_check_extended_key_usage( const x509_crt *crt,
return( 0 );
}
if( OID_CMP( OID_ANY_EXTENDED_KEY_USAGE, cur_oid ) )
if( OID_CMP( OID_ANY_EXTENDED_KEY_USAGE, cur_oid ) == 0 )
return( 0 );
}
@ -1961,7 +1961,7 @@ int x509_crt_verify( x509_crt *crt,
{
while( name != NULL )
{
if( OID_CMP( OID_AT_CN, &name->oid ) )
if( OID_CMP( OID_AT_CN, &name->oid ) == 0 )
{
if( name->val.len == cn_len &&
x509_memcasecmp( name->val.p, cn, cn_len ) == 0 )