]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls_x509_dn_oid_name() was extended with a flags option that accepts currently...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 9 Jan 2012 23:49:27 +0000 (00:49 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 9 Jan 2012 23:49:55 +0000 (00:49 +0100)
lib/includes/gnutls/x509.h
lib/x509/common.c
lib/x509/dn.c

index e34f372140343cef17a2d5946767503a24bc5795..5b20bef3e4d01585d2ab8d01db8a4f0d2613c8d8 100644 (file)
@@ -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,
index ce84d379eea37216b23f9e99a39535a081d2ac42..0bed0e76c2409202d02e359f7f5d5cfdf5b7db55 100644 (file)
@@ -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 *
index 32f52ba4e9b4bd3161c8a682889af0d31c380a6a..bf349c9a439b7faf82ba66bd70ebc9a6cec8ef1d 100644 (file)
  * 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 */