From: Nikos Mavrogiannopoulos Date: Wed, 6 Mar 2013 10:00:32 +0000 (+0100) Subject: Placed back _gnutls_x509_compare_raw_dn(). X-Git-Tag: gnutls_3_1_10~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9e961b1667b542425db5889f5a86dffe3373894;p=thirdparty%2Fgnutls.git Placed back _gnutls_x509_compare_raw_dn(). --- diff --git a/lib/x509/dn.c b/lib/x509/dn.c index 817f7b9678..640751c70a 100644 --- a/lib/x509/dn.c +++ b/lib/x509/dn.c @@ -1066,7 +1066,30 @@ gnutls_x509_rdn_get_oid (const gnutls_datum_t * idn, asn1_delete_structure (&dn); return result; +} + +/* + * Compares the DER encoded part of a DN. + * + * Returns 1 if the DN's match and (0) if they don't match. Otherwise + * a negative error code is returned to indicate error. + */ +int +_gnutls_x509_compare_raw_dn (const gnutls_datum_t * dn1, + const gnutls_datum_t * dn2) +{ + if (dn1->size != dn2->size) + { + gnutls_assert (); + return 0; + } + if (memcmp (dn1->data, dn2->data, dn2->size) != 0) + { + gnutls_assert (); + return 0; + } + return 1; /* they match */ } /** diff --git a/lib/x509/verify.c b/lib/x509/verify.c index 6e25b07998..e146878abf 100644 --- a/lib/x509/verify.c +++ b/lib/x509/verify.c @@ -209,8 +209,7 @@ is_issuer (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer) size_t id2_size; int ret; - if (cert->raw_issuer_dn.size == issuer->raw_dn.size && - memcmp(cert->raw_issuer_dn.data, issuer->raw_dn.data, issuer->raw_dn.size) == 0) + if (_gnutls_x509_compare_raw_dn(&cert->raw_issuer_dn, &issuer->raw_dn) != 0) ret = 1; else ret = 0; @@ -253,8 +252,7 @@ cleanup: static int is_crl_issuer (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer) { - if (crl->raw_issuer_dn.size == issuer->raw_dn.size && - memcmp(crl->raw_issuer_dn.data, issuer->raw_dn.data, issuer->raw_dn.size) == 0) + if (_gnutls_x509_compare_raw_dn(&crl->raw_issuer_dn, &issuer->raw_dn) != 0) return 1; else return 0; @@ -267,8 +265,7 @@ is_crl_issuer (gnutls_x509_crl_t crl, gnutls_x509_crt_t issuer) int _gnutls_is_same_dn (gnutls_x509_crt_t cert1, gnutls_x509_crt_t cert2) { - if (cert1->raw_dn.size == cert2->raw_dn.size && - memcmp(cert1->raw_dn.data, cert2->raw_dn.data, cert2->raw_dn.size) == 0) + if (_gnutls_x509_compare_raw_dn(&cert1->raw_dn, &cert2->raw_dn) != 0) return 1; else return 0; diff --git a/lib/x509/x509.c b/lib/x509/x509.c index 01455f924c..75806e7a79 100644 --- a/lib/x509/x509.c +++ b/lib/x509/x509.c @@ -2765,8 +2765,7 @@ gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt, unsigned int flags, static int crl_issuer_matches (gnutls_x509_crl_t crl, gnutls_x509_crt_t cert) { - if (crl->raw_issuer_dn.size == cert->raw_issuer_dn.size && - memcmp(crl->raw_issuer_dn.data, cert->raw_issuer_dn.data, cert->raw_issuer_dn.size) == 0) + if (_gnutls_x509_compare_raw_dn(&crl->raw_issuer_dn, &cert->raw_issuer_dn) != 0) return 1; else return 0; diff --git a/lib/x509/x509_int.h b/lib/x509/x509_int.h index 053f00c1ea..8d6f766067 100644 --- a/lib/x509/x509_int.h +++ b/lib/x509/x509_int.h @@ -85,7 +85,8 @@ typedef struct gnutls_x509_privkey_int int _gnutls_x509_crt_cpy (gnutls_x509_crt_t dest, gnutls_x509_crt_t src); - +int _gnutls_x509_compare_raw_dn (const gnutls_datum_t * dn1, + const gnutls_datum_t * dn2); int _gnutls_x509_crl_cpy (gnutls_x509_crl_t dest, gnutls_x509_crl_t src); int _gnutls_x509_crl_get_raw_issuer_dn (gnutls_x509_crl_t crl,