From: Nikos Mavrogiannopoulos Date: Mon, 9 Jan 2012 23:49:27 +0000 (+0100) Subject: gnutls_x509_dn_oid_name() was extended with a flags option that accepts currently... X-Git-Tag: gnutls-3_0_12~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ad7654f3b06d4ef2810a46289d032e6cd1509b0;p=thirdparty%2Fgnutls.git gnutls_x509_dn_oid_name() was extended with a flags option that accepts currently GNUTLS_X509_DN_OID_RETURN_OID or 0. --- diff --git a/lib/includes/gnutls/x509.h b/lib/includes/gnutls/x509.h index e34f372140..5b20bef3e4 100644 --- a/lib/includes/gnutls/x509.h +++ b/lib/includes/gnutls/x509.h @@ -295,7 +295,8 @@ extern "C" int gnutls_x509_dn_oid_known (const char *oid); - const char* gnutls_x509_dn_oid_name (const char *oid); +#define GNUTLS_X509_DN_OID_RETURN_OID 1 + const char* gnutls_x509_dn_oid_name (const char *oid, unsigned int flags); /* Read extensions by OID. */ int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, int indx, diff --git a/lib/x509/common.c b/lib/x509/common.c index ce84d379ee..0bed0e76c2 100644 --- a/lib/x509/common.c +++ b/lib/x509/common.c @@ -174,15 +174,19 @@ _gnutls_x509_oid_data_choice (const char *oid) /** * gnutls_x509_dn_oid_name: * @oid: holds an Object Identifier in a null terminated string + * @flags: 0 or %GNUTLS_X509_DN_OID_* * - * This function will return the name of a known DN OID. + * This function will return the name of a known DN OID. If + * %GNUTLS_X509_DN_OID_RETURN_OID is specified this function + * will return the given OID if no descriptive name has been + * found. * * Returns: A null terminated string or NULL otherwise. * * Since: 3.0.0 **/ const char* -gnutls_x509_dn_oid_name (const char *oid) +gnutls_x509_dn_oid_name (const char *oid, unsigned int flags) { int i = 0; @@ -194,7 +198,8 @@ gnutls_x509_dn_oid_name (const char *oid) } while (_oid2str[i].oid != NULL); - return NULL; + if (flags & GNUTLS_X509_DN_OID_RETURN_OID) return oid; + else return NULL; } const char * diff --git a/lib/x509/dn.c b/lib/x509/dn.c index 32f52ba4e9..bf349c9a43 100644 --- a/lib/x509/dn.c +++ b/lib/x509/dn.c @@ -34,22 +34,6 @@ * Name (you need a parser just to read a name in the X.509 protoocols!!!) */ -/* Converts the given OID to an ldap acceptable string or - * a dotted OID. - */ -static const char * -oid2ldap_string (const char *oid) -{ - const char *ret; - - ret = gnutls_x509_dn_oid_name (oid); - if (ret) - return ret; - - /* else return the OID in dotted format */ - return oid; -} - /* Escapes a string following the rules from RFC4514. */ static char * @@ -236,7 +220,7 @@ _gnutls_x509_parse_dn (ASN1_TYPE asn1_struct, } } - ldap_desc = oid2ldap_string (oid); + ldap_desc = gnutls_x509_dn_oid_name (oid, GNUTLS_X509_DN_OID_RETURN_OID); printable = _gnutls_x509_oid_data_printable (oid); /* leading #, hex encoded value and terminating NULL */