Commit 6e064376 authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

Reverse meaning of OID_CMP

parent 852a6d3d
......@@ -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" {
......
......@@ -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,
......
......@@ -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 )
......
......@@ -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 );
......
......@@ -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 )
......
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