]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
added gnutls_x509_oid_known() to report known OIDs.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 14 Nov 2003 11:42:47 +0000 (11:42 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 14 Nov 2003 11:42:47 +0000 (11:42 +0000)
includes/gnutls/x509.h
lib/x509/common.c
lib/x509/crq.c
lib/x509/x509_write.c

index 3c89aef986c97683e6238ca8f079f9db4d1e373b..59db8800772233ca2b915dc7f8a2129284dac91f 100644 (file)
@@ -82,6 +82,8 @@ int gnutls_x509_crt_get_ca_status(gnutls_x509_crt cert, unsigned int* critical);
 int gnutls_x509_crt_get_key_usage( gnutls_x509_crt cert, unsigned int* key_usage,
        unsigned int* critical);
 
+int gnutls_x509_oid_known(const char* oid);
+
 /* key_usage will be an OR of the following values:
  */
 #define GNUTLS_KEY_DIGITAL_SIGNATURE           256
index 557ab03c1e3b9e5fb4127f5593a9de76cad50c9d..30f8754ae194ac4e893d175ffe0e95e9f73bbb06 100644 (file)
@@ -77,6 +77,33 @@ int i = 0;
        return 0;
 }
 
+/**
+  * gnutls_x509_oid_known - This function will return true if the given OID is known
+  * @oid: holds an Object Identifier in a null terminated string
+  *
+  * This function will inform about known OIDs. This is useful since functions
+  * like gnutls_x509_crt_set_dn_by_oid() use the information on known
+  * OIDs to properly encode their input. Object Identifiers that are not
+  * known are not encoded by these functions, and their input is stored directly
+  * into the ASN.1 structure. In that case of unknown OIDs, you have
+  * the responsibility of DER encoding your data.
+  *
+  * Returns 1 on known OIDs and 0 otherwise.
+  *
+  **/
+int gnutls_x509_oid_known( const char* oid) 
+{
+int i = 0;
+
+       do {
+               if ( strcmp(_oid2str[i].oid, oid)==0)
+                       return 1;
+               i++;
+       } while( _oid2str[i].oid != NULL);
+
+       return 0;
+}
+
 /* Returns 1 if the data defined by the OID are of a choice
  * type.
  */
index a0710863c12b461fdebeb12511646aec6ae66c0e..93f3760976c4633033db1d21b5b1f628d3494c60 100644 (file)
@@ -383,21 +383,24 @@ int gnutls_x509_crq_get_challenge_password(gnutls_x509_crq crq,
 /**
   * gnutls_x509_crq_set_dn_by_oid - This function will set the Certificate request subject's distinguished name
   * @crq: should contain a gnutls_x509_crq structure
-  * @oid: holds an Object Identified in null terminated string
-  * @name: a pointer to the name
-  * @sizeof_name: holds the size of 'name'
+  * @oid: holds an Object Identifier in a null terminated string
+  * @data: a pointer to the input data
+  * @sizeof_data: holds the size of 'data'
   *
   * This function will set the part of the name of the Certificate request subject, specified
   * by the given OID. 
   *
   * Some helper macros with popular OIDs can be found in gnutls/x509.h
-  * With this function you can only set the known OIDs.
+  * With this function you can only set the known OIDs. You can test
+  * for known OIDs using gnutls_x509_oid_known(). For OIDs that are
+  * not known (by gnutls) you should properly DER encode your data before
+  * calling this function.
   *
   * Returns 0 on success.
   *
   **/
 int gnutls_x509_crq_set_dn_by_oid(gnutls_x509_crq crq, const char* oid, 
-       const char *name, unsigned int sizeof_name)
+       const void *data, unsigned int sizeof_data)
 {
        if (sizeof_name == 0 || name == NULL || crq == NULL) {
                return GNUTLS_E_INVALID_REQUEST;
index ab75a0a66bf5e059056abaa1f3044c935732e380..83911aac899626ca84b3a135206736c57d89254a 100644 (file)
@@ -62,7 +62,7 @@ static void disable_optional_stuff( gnutls_x509_crt cert);
   *
   **/
 int gnutls_x509_crt_set_dn_by_oid(gnutls_x509_crt crt, const char* oid, 
-       const char *name, unsigned int sizeof_name)
+       const void *name, unsigned int sizeof_name)
 {
        if (sizeof_name == 0 || name == NULL || crt == NULL) {
                return GNUTLS_E_INVALID_REQUEST;
@@ -92,7 +92,7 @@ int gnutls_x509_crt_set_dn_by_oid(gnutls_x509_crt crt, const char* oid,
   *
   **/
 int gnutls_x509_crt_set_issuer_dn_by_oid(gnutls_x509_crt crt, const char* oid, 
-       const char *name, unsigned int sizeof_name)
+       const void *name, unsigned int sizeof_name)
 {
        if (sizeof_name == 0 || name == NULL || crt == NULL) {
                return GNUTLS_E_INVALID_REQUEST;